Ejemplo n.º 1
0
        public async Task <Result <MasterElectionState> > GetRoleAsync(OperationContext context)
        {
            var result = await _inner.GetRoleAsync(context);

            if (result.Succeeded)
            {
                OnRoleUpdated(context, result.Value.Role);
            }

            return(result);
        }
Ejemplo n.º 2
0
        private async Task <Result <MachineLocation> > GetMasterLocationAsync(OperationContext context)
        {
            var masterElectionState = await _masterElectionMechanism.GetRoleAsync(context);

            if (masterElectionState.Succeeded)
            {
                if (!masterElectionState.Value.Master.IsValid)
                {
                    return(new ErrorResult("Unknown master"));
                }

                return(masterElectionState.Value.Master);
            }
            else
            {
                return(new ErrorResult(masterElectionState));
            }
        }