Example #1
0
        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;
        }
Example #2
0
        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 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);
 }
Example #5
0
        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;
        }
Example #6
0
 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;
 }
Example #7
0
 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;
 }
Example #8
0
        /// <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);
        }
Example #9
0
 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);
        }
Example #11
0
 public PingController(INatsClient client)
 {
     _client = client;
 }
Example #12
0
 public ClientConnected(INatsClient client)
 {
     Client = client;
 }
Example #13
0
 public Drain(IBoshConfig config, INatsClient nats)
     : base(config)
 {
     this.nats = nats;
 }
 public ClientAutoReconnectFailed(INatsClient client)
 {
     Client = client;
 }
Example #15
0
 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);
        }
Example #17
0
 public ClientDisconnected(INatsClient client, DisconnectReason reason)
 {
     Client = client;
     Reason = reason;
 }