Esempio n. 1
0
        private RelayTunnel ReplaceByNewConnection(RelayTunnel replacing, long idx)
        {
            _log.Information("Replacing {idx} Relay Tunnel", idx);

            replacing.OnDataChannelClosed = OnReplacedTunnelDataChannelClosed;

            return(_tunnels[idx] = new RelayTunnel(_log, _metrics, _serviceNamespace, _portMappings.EntityPath, _portMappings.RemoteConfigurationKey, _portMappings.RelayConnectionTtlSeconds));
        }
Esempio n. 2
0
        private void OnReplacedTunnelDataChannelClosed(RelayTunnel tunnel)
        {
            tunnel.OnDataChannelClosed = null;

            _replacedTunnels.TryRemove(tunnel, out _);

            tunnel.IgnoreException(x => x.Dispose());
        }
Esempio n. 3
0
        public RelayTunnelFactory(ILogger logger, TunnelMetrics metrics, ServiceNamespaceOptions serviceNamespace, PortMappingOptions portMappings)
        {
            _log = logger?.ForContext(GetType());

            _poolLocker       = new object();
            _serviceNamespace = serviceNamespace;
            _portMappings     = portMappings;

            _replacedTunnels = new ConcurrentDictionary <object, RelayTunnel>();

            _tunnels = new RelayTunnel[portMappings.RelayChannelCount];

            _metrics = metrics;

            for (var i = 0; i < portMappings.RelayChannelCount; i++)
            {
                _tunnels[i] = new RelayTunnel(logger, _metrics, serviceNamespace, portMappings.EntityPath, portMappings.RemoteConfigurationKey, portMappings.RelayConnectionTtlSeconds);
            }
        }