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); }
private Client(ILogger logger) { this.random = new Random(); this.applicationInfo = new TStaticApplicationInfo(); this.configuration = applicationInfo.GetHostConfiguration(); this.logger = new LoggerWrapper(logger, $"[client] ", configuration.HostLogLevel); this.application = Compilation.Compile <TStaticApplicationInfo>(applicationInfo, configuration); this.processId = (uint)random.Next((int)application.NumberProcesses); // we connect to a randomly selected process this.responsePartition = (uint)random.Next(ResponseSender.NumberPartitions); // we receive on a randomly selected partition this.connections = new EventHubsConnections(processId, logger, configuration.EventHubsConnectionString); this.requestSender = new RequestSender(processId, connections, logger, new DataContractSerializer(typeof(List <IMessage>), application.SerializableTypes), configuration); this.responseSenders = new Dictionary <uint, ResponseSender>(); this.continuations = new ConcurrentDictionary <Guid, object>(); this.serializer = new Serializer(application.SerializableTypes); this.responseSerializer = new DataContractSerializer(typeof(List <IResponseMessage>), application.SerializableTypes); var ignoredTask = ListenForResponses(); }