示例#1
0
        protected sealed override void DoInitialize(ILog log, IMetricScope rootMetricScope, AirlockEnvironmentVariables environmentVariables, out IRoutingKeyFilter routingKeyFilter, out IAirlockEventProcessorProvider processorProvider)
        {
            airlockClient    = CreateAirlockClient(log, environmentVariables);
            routingKeyFilter = new MetricsAggregatorRotingKeyFilter();
            var settings = new MetricsAggregatorSettings();

            processorProvider = new MetricsAggregatorAirlockEventProcessorProvider(rootMetricScope, airlockClient, settings);
        }
示例#2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Drawing.Load(Content);

            Server      = new AirlockServer(11002);
            Client      = new AirlockClient(IPAddress.Parse("127.0.0.1"), 11002, 11003);
            WorldCamera = new Camera(spriteBatch, Resolution.ToVector2());

            NetTime.Realtime = false;
        }
        private static void RunProducer(ILog log, string[] args)
        {
            var routingKeys = args.Any() ? args : new[] { defaultRoutingKey };

            log.Info($"Producer started for routingKeys: [{string.Join(", ", routingKeys)}]");
            var airlockClient = new AirlockClient(new AirlockConfig
            {
                ApiKey          = airlockApiKey,
                ClusterProvider = new FixedClusterProvider(new Uri(airlockGateEndpoint)),
            }, log.FilterByLevel(LogLevel.Warn));

            do
            {
                foreach (var routingKey in routingKeys)
                {
                    var message = $"msg@{DateTimeOffset.UtcNow:O}";
                    airlockClient.Push(routingKey, new SampleEvent {
                        Message = message
                    });
                    log.Info($"Pushed {message} into {routingKey}");
                }
            } while (!stopSignal.Wait(TimeSpan.FromSeconds(1)));
            log.Info("Producer finished");
        }