public TcpConnection(string id, string address, int port, ExponentialDelayPolicy policy, ILogger logger = null) { this.id = id; this.address = address; this.port = port; this.policy = policy; this.logger = logger; }
public SlaveChannel(Slave slave, ILogger logger = null) { this.slave = slave; this.logger = logger; SlaveId = slave.UnitId; mapper = new MbapMapper(Guid.NewGuid().ToString()); delayPolicy = new ExponentialDelayPolicy(30000, 2, true); retryPolicy = new BasicRetryPolicy(delayPolicy, 5); CreateChannelAsync().GetAwaiter(); }
public async Task RunAsync() { if (config == null || string.IsNullOrEmpty(config.Hostname)) { return; } ExponentialDelayPolicy policy = new ExponentialDelayPolicy(180); foreach (var slave in config.Slaves) { string id = Guid.NewGuid().ToString(); TcpConnection connection = new TcpConnection(id, slave.IPAddress, slave.Port, policy, logger); connection.OnReceived += Connection_OnReceived; connections.Add(slave.UnitId, new Tuple <TcpConnection, byte?>(connection, slave.Alias)); await connection.OpenAsync(); } }
public BasicRetryPolicy(ExponentialDelayPolicy delayPolicy, int maxRetries) { this.delayPolicy = delayPolicy; max = maxRetries; }