Exemple #1
0
        public async Task <SystemRegistration> QueryAsync(string name, VectorTimeStamp vts, string nsEndpoint = null)
        {
            nsEndpoint = nsEndpoint ?? NsEndpoint;
            if (string.IsNullOrWhiteSpace(nsEndpoint))
            {
                return(null);
            }
            RegClient.Connect(nsEndpoint, ZeroMQ.ZSocketType.REQ);
            Logger?.WriteLine($"Connected to NameServer at {nsEndpoint}");
            var packet = new Packet <NsQuery> {
                Payload = new NsQuery {
                    Name = name
                }, VectorTimeStamp = vts
            };
            var json = JsonConvert.SerializeObject(packet);
            SystemRegistration result = null;
            await RegClient.SendAsync($"QRY: {json}", (ZFrame frame) =>
            {
                if (frame == null)
                {
                    return;
                }
                var responseJson   = frame.ToString();
                var responsePacket = JsonConvert.DeserializeObject <Packet <SystemRegistration> >(responseJson);
                result             = responsePacket.Payload;
            });

            Logger?.WriteLine($"Queried for {SystemRegistration.Name}, Endpoint: {SystemRegistration.EndPoint}");

            await Awaiter.AwaitTrueAsync(() => { return(result != null); }, 5000);

            return(result);
        }
Exemple #2
0
 public RegistrationClient(string nsEndpoint, SystemRegistration systemRegistration, bool retryOnFailure, ILogger logger)
 {
     Logger             = logger;
     NsEndpoint         = nsEndpoint;
     SystemRegistration = systemRegistration;
     RegClient          = new SendClient(true, retryOnFailure);
 }