private static async Task CreateStartAndAddBroker(string brokerName, int brokerNumber, BrokerSocket[] brokerSockets)
        {
            var brokerSocket     = new BrokerSocket();
            var connectionString = EnvironmentVariables.IsDev ? "ws://localhost:5000/ws" : $"ws://{brokerName}.broker.default.svc.cluster.local/ws";
            await brokerSocket.ConnectToBroker(connectionString);

            brokerSockets[brokerNumber] = brokerSocket;
        }
        public static async Task <BrokerSocket[]> UpdateBrokerSockets(EtcdClient client, BrokerSocket[] brokerSockets)
        {
            var rangeResponse = await client.GetRangeValAsync(BrokerTablePrefix);

            var maxBrokerNumber = rangeResponse.Keys.Max(GetBrokerNumber);

            brokerSockets = new BrokerSocket[maxBrokerNumber + 1];
            foreach (var(key, _) in rangeResponse)
            {
                await AddBroker(key, brokerSockets);
            }
            return(brokerSockets);
        }
Beispiel #3
0
        public static async Task <BrokerSocket[]> UpdateSpecificBrokerSockets(EtcdClient client, BrokerSocket[] brokerSockets, BrokerSocket brokerSocket)
        {
            var rangeResponse = await client.GetRangeValAsync(BrokerTablePrefix);

            if (rangeResponse.Count == 0)
            {
                Console.WriteLine("No brokers connected");
                return(new BrokerSocket[] { });
            }
            var maxBrokerNumber = rangeResponse.Keys.Max(GetBrokerNumber);

            brokerSockets = new BrokerSocket[maxBrokerNumber + 1];
            foreach (var(key, _) in rangeResponse)
            {
                await AddBroker(key, brokerSockets);
            }
            return(brokerSockets);
        }
 public async Task InitSocketLocalhost()
 {
     _localhostBrokerSocket = new BrokerSocket();
     await _localhostBrokerSocket.ConnectToBroker("ws://localhost:5000/ws");
 }