public DeaAgent(ILog log, IDeaConfig config, INatsClient natsClient, IFilesManager filesManager, IConfigManager configManager, IDropletManager dropletManager, IWebServerAdministrationProvider webServerAdministrationProvider, IVarzProvider varzProvider) { this.log = log; this.config = config; this.natsClient = natsClient; this.filesManager = filesManager; this.configManager = configManager; this.dropletManager = dropletManager; this.webServerProvider = webServerAdministrationProvider; this.varzProvider = varzProvider; helloMessage = new Hello(natsClient.UniqueIdentifier, config.LocalIPAddress, config.FilesServicePort); processTask = new Task(ProcessLoop); heartbeatTask = new Task(HeartbeatLoop); advertiseTask = new Task(AdvertiseLoop); varzTask = new Task(SnapshotVarz); monitorAppsTask = new Task(MonitorLoop); this.maxMemoryMB = config.MaxMemoryMB; }
public static async Task Main(string[] args) { var cnInfo = new ConnectionInfo("localhost"); _client = new NatsClient(cnInfo); await _client.ConnectAsync(); _client.Sub("getTemp", stream => stream.Subscribe(msg => { var parts = msg.GetPayloadAsString().Split('@'); _client.Pub(msg.ReplyTo, $"Temp is {TempService.Get(parts[0], parts[1])}C"); })); while (true) { Console.WriteLine("Query? (y=yes;n=no)"); if (Console.ReadKey().KeyChar == 'n') { break; } Console.WriteLine(); Console.WriteLine($"Got reply: {_client.RequestAsync("getTemp", "STOCKHOLM@SWEDEN").Result.GetPayloadAsString()}"); } _client.Disconnect(); }
public HeartbeatProcessor(ILog log, INatsClient natsClient, IBoshConfig config) { this.log = log; this.natsClient = natsClient; this.config = config; this.actionTimer = new ActionTimer(log, config.HeartbeatInterval, this.Beat, false, false); }
public BoshAgent(IContainer ioc, ILog log, INatsClient natsClient, IBoshConfig config, IBlobstoreClientFactory blobstoreClientFactory) { this.ioc = ioc; this.log = log; this.natsClient = natsClient; this.config = config; this.blobstoreClientFactory = blobstoreClientFactory; }
/// <summary> /// Private method, that must be run for the client to work. /// <remarks>See constructor</remarks> /// </summary> private void InitializeEndpoint() { var connectionInfo = new ConnectionInfo(_config.Host, _config.Port) { AutoReconnectOnFailure = _config.AutoReconnectOnFailure, AutoRespondToPing = _config.AutoRespondToPing, Credentials = _config.Credentials, PubFlushMode = _config.PubFlushMode, RequestTimeoutMs = _config.RequestTimeoutMs, SocketOptions = _config.SocketOptions, Verbose = _config.Verbose }; _natsClient = new NatsClient(_config.ClientId, connectionInfo); }
public Drain(IBoshConfig config, INatsClient nats) : base(config) { this.nats = nats; }
public static async Task PubAsJsonAsync <TItem>(this INatsClient client, string subject, TItem item, string replyTo = null) where TItem : class { var payload = JsonEncoding.Default.Encode(item); await client.PubAsync(subject, payload, replyTo).ConfigureAwait(false); }
public PingController(INatsClient client) { _client = client; }
public ClientConnected(INatsClient client) { Client = client; }
public ClientAutoReconnectFailed(INatsClient client) { Client = client; }
public ClientWorkerFailed(INatsClient client, Exception exception) { Client = client; Exception = exception; }
public static void PubAsJson <TItem>(this INatsClient client, string subject, TItem item, string replyTo = null) where TItem : class { var payload = JsonEncoding.Default.Encode(item); client.Pub(subject, payload, replyTo); }
public ClientDisconnected(INatsClient client, DisconnectReason reason) { Client = client; Reason = reason; }