예제 #1
0
        public Host(IStaticApplicationInfo applicationInfo, FunctionsHostConfiguration configuration, ILogger logger, uint processId, Stopwatch stopwatch, Guid invocationId)
        {
            this.processId       = processId;
            this.stopwatch       = stopwatch;
            this.applicationInfo = applicationInfo;
            this.configuration   = configuration;
            this.hostName        = Environment.MachineName;
            bool cloud = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("REACTIVE_MACHINE_DIR"));

            CombinedLogger    = new CombinedLogger(logger, configuration, processId, cloud);
            HostLogger        = new LoggerWrapper(CombinedLogger, $"[p{processId:d3} host] ", configuration.HostLogLevel);
            ApplicationLogger = new LoggerWrapper(CombinedLogger, $"[p{processId:d3} application] ", configuration.ApplicationLogLevel);
            RuntimeLogger     = new LoggerWrapper(CombinedLogger, $"[p{processId:d3} runtime] ", configuration.RuntimeLogLevel);

            this.application = applicationInfo.Build(new ReactiveMachine.ApplicationCompiler().SetConfiguration(configuration));

            this.invocationId              = invocationId;
            this.payloadSerializer         = new DataContractSerializer(typeof(List <KeyValuePair <long, IMessage> >), application.SerializableTypes);
            this.payloadSerializerLoopback = new DataContractSerializer(typeof(List <IMessage>), application.SerializableTypes);
            this.Connections = new EventHubsConnections(processId, HostLogger, configuration.ehConnectionString);

            if (application.TryGetConfiguration <ReactiveMachine.TelemetryBlobWriter.Configuration>(out var config))
            {
                this.collectHostEvents     = config.CollectHostEvents;
                this.blobTelemetryListener = new TelemetryCollector(config, application, processId, this.GetType());
            }
        }
        private ClientConnection(IStaticApplicationInfo applicationInfo, ILogger logger)
        {
            this.applicationInfo = applicationInfo;
            var configuration = applicationInfo.GetHostConfiguration();

            this.logger            = new LoggerWrapper(logger, $"[client] ", configuration.HostLogLevel);
            this.application       = applicationInfo.Build(new ReactiveMachine.ApplicationCompiler().SetConfiguration(configuration));
            this.payloadSerializer = new DataContractSerializer(typeof(List <IMessage>), application.SerializableTypes);
            this.processId         = (uint)new Random().Next((int)application.NumberProcesses); // we connect to a randomly selected process
            this.connections       = new EventHubsConnections(processId, logger, configuration.ehConnectionString);
            this.sender            = new RequestSender(processId, connections, logger, payloadSerializer, configuration);
        }
예제 #3
0
        internal static ICompiledApplication Compile <TApplicationInfo>(IStaticApplicationInfo info, FunctionsHostConfiguration configuration)
            where TApplicationInfo : IStaticApplicationInfo, new()
        {
            var compiler = new ReactiveMachine.ApplicationCompiler();

            compiler
            .SetConfiguration(configuration)
            .AddBuildStep(serviceBuilder =>
            {
                var m = typeof(Compilation).GetMethod(nameof(Compilation.DefineForResultType));
                foreach (var t in info.GetResultTypes())
                {
                    var mg = m.MakeGenericMethod(typeof(TApplicationInfo), t);
                    mg.Invoke(null, new object[] { serviceBuilder });
                }
            })
            ;
            return(info.Build(compiler));
        }