Exemplo n.º 1
0
        public async Task Initialise(string serviceId, string nodeId, string[] tags, string address, int port)
        {
            _stats     = _routingData.GetStats(serviceId);
            _address   = address;
            _port      = port;
            _tags      = tags;
            Routes     = ServiceUtils.RoutesFromTags(tags);
            _serviceId = serviceId;
            NodeId     = nodeId;
            try
            {
                var result = await Dns.GetHostAddressesAsync(address);

                _ipEndPoint = new IPEndPoint(result[0], port);
            }
            catch
            {
                _logger?.LogWarning("Unable to resolve the host address for {address} when adding the service", address);
            }
            _supportedVersions = tags.Where(t => t.StartsWith("version=")).Select(t => new Version(t.Substring(8))).ToArray();
            _protocolScheme    = tags.Where(t => t.StartsWith("protocolScheme-"))
                                 .Select(t => t.Substring("protocolScheme-".Length)).FirstOrDefault() ?? "http";

            _hostString = $"{_address}:{_port}";
            _httpClient = _clientFactory?.Invoke(ServiceId) ?? new HttpClient();
        }
Exemplo n.º 2
0
        public void Visit(VisitableSchemaRoot element)
        {
            _currentns =
                new CodeNamespace(element.SchemaObject.TargetNamespace);

            //Get the current state of the generation process.
            ICurrentState state = (ICurrentState)
                                  Host.GetService(typeof(ICurrentState));

            state.Unit.Namespaces.Add(_currentns);
        }
Exemplo n.º 3
0
        public async Task Initialise(string serviceId, string nodeId, string[] tags, string address, int port)
        {
            _stats = _routingData.GetStats(serviceId);
            _stats.ResetUptime();
            _address    = address;
            _port       = port;
            _tags       = tags;
            Routes      = ServiceUtils.RoutesFromTags(tags);
            _serviceId  = serviceId;
            NodeId      = nodeId;
            _hostHeader = Encoding.UTF8.GetBytes($"Host: {_address}:{_port}\r\n");
            try
            {
                var result = await Dns.GetHostAddressesAsync(address);

                _ipEndPoint = new IPEndPoint(result[0], port);
            }
            catch
            {
                _logger.LogError("Unable to get an ip address for {serverAddress}", address);
            }
            _supportedVersions = tags.Where(t => t.StartsWith("version=")).Select(t => new Version(t.Substring(8))).ToArray();
        }
Exemplo n.º 4
0
 public CurrentStateHolder(ICurrentState initalState)
 {
     _currentState = initalState;
 }
Exemplo n.º 5
0
 public void SetNextState(ICurrentState nextState)
 {
     _currentState = nextState;
 }