Exemple #1
0
        private async Task ReportServiceInstancePropertiesAsync(CancellationToken cancellationToken)
        {
            var properties = new AgentOsInfoRequest
            {
                HostName  = DnsHelpers.GetHostName(),
                IpAddress = DnsHelpers.GetIpV4s(),
                OsName    = PlatformInformation.GetOSName(),
                ProcessNo = Process.GetCurrentProcess().Id,
                Language  = "dotnet"
            };
            var request = new ServiceInstancePropertiesRequest
            {
                ServiceId         = _config.ServiceName,
                ServiceInstanceId = _config.ServiceInstanceName,
                Properties        = properties
            };
            var result = await Polling(3,
                                       () => _serviceRegister.ReportInstancePropertiesAsync(request, cancellationToken),
                                       cancellationToken);

            if (result && RuntimeEnvironment is RuntimeEnvironment environment)
            {
                environment.Initialized = true;
                Logger.Information($"Reported Service Instance Properties[Service={request.ServiceId},InstanceId={request.ServiceInstanceId}].");
            }
        }
 public async Task <bool> ReportInstancePropertiesAsync(ServiceInstancePropertiesRequest serviceInstancePropertiesRequest,
                                                        CancellationToken cancellationToken = default(CancellationToken))
 {
     if (_transportConfig.ProtocolVersion == ProtocolVersions.V8)
     {
         return(await _serviceRegisterV8.ReportInstancePropertiesAsync(serviceInstancePropertiesRequest, cancellationToken));
     }
     return(true);
 }