private RpcManagedClient NewClient(RemoteEndPoint endPoint) { var addresses = _endPointResolvers.GetOrAdd(endPoint.Host, (host) => new EndPointResolver(host)).Resolve(); if (addresses.IsEmpty()) { return(new RpcManagedClient(OnResponse, null)); } var settings = new RpcClientOptions(). UsingEndPoint(new IPEndPoint(addresses[0], endPoint.Port)); return(new RpcManagedClient(OnResponse, settings)); }
public RpcClient(Func <RemoteMessage, Task> onResponse, RpcClientOptions options) { _id = Interlocked.Increment(ref IdSeed); _circuitForConnection = new CircuitBreaker( policy: new CircuitPolicy(2, TimeSpan.FromSeconds(10000), TimeSpan.FromSeconds(10), 2, false), invoker: new ChainedInvoker(ConnectionValidator), onFailure: (circuitBreaker, exception) => { Interlocked.Exchange(ref _status, RpcClientStatus.Closed); }); _onResponse = onResponse; _options = options?.Clone() ?? RpcClientOptions.Default; _bulkSendLength = _options.BulkSendLength; if (_bulkSendLength < 1) { _bulkSendLength = RpcConstants.DefaultBulkSendLength; } }
public RpcManagedClient(Func <RemoteMessage, Task> onResponse, RpcClientOptions options) : base(onResponse, options) { _creationTime = Environment.TickCount; }