コード例 #1
0
ファイル: Form1.cs プロジェクト: mqkfc123/InjectApm
        private void doPing(Channel channel, string instanceId, int serviceInstanceId)
        {
            var client = new ServiceInstancePing.ServiceInstancePingClient(channel);
            //IObserver<T>

            var reply = Task.Run(async() =>
            {
                return(await client.doPingAsync(new ServiceInstancePingPkg
                {
                    ServiceInstanceId = serviceInstanceId,
                    ServiceInstanceUUID = instanceId,
                    Time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                }));
            }).Result;
        }
コード例 #2
0
        public Task PingAsync(PingRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (!_connectionManager.Ready)
            {
                return(Task.CompletedTask);
            }

            var connection = _connectionManager.GetConnection();

            return(new Call(_logger, _connectionManager).Execute(async() =>
            {
                var client = new ServiceInstancePing.ServiceInstancePingClient(connection);
                await client.doPingAsync(new ServiceInstancePingPkg
                {
                    ServiceInstanceId = request.ServiceInstanceId,
                    ServiceInstanceUUID = request.InstanceId,
                    Time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
                }, _config.GetMeta(), _config.GetTimeout(), cancellationToken);
            },
                                                                 () => ExceptionHelpers.PingError));
        }