示例#1
0
        public Node(Config config)
        {
            _config          = config;
            _stateController = new StateController(config, new FileStateMachine(config.NodeId));
            Peers            = new List <Peer>();
            foreach (string address in config.JoinAddresses)
            {
                if (address == config.LocalAddress)
                {
                    continue;
                }
                string[]    segments = address.Split(':');
                GrpcChannel channel  = new GrpcChannel(segments[0], int.Parse(segments[1]), config.ClusterToken, new DebugConsole());
                Peers.Add(new Peer(address, channel.GetClient <IHost>()));
            }

            _host       = new Host(_stateController, this);
            CurrentRole = new Follower(_stateController, this);
        }