private static StandardKernel SetupIoc() { var connectionKey = Environment.GetEnvironmentVariable(ApolloConstants.ConnectionKey, EnvironmentVariableTarget.Process) ?? Environment.GetEnvironmentVariable(ApolloConstants.ConnectionKey, EnvironmentVariableTarget.User) ?? Environment.GetEnvironmentVariable(ApolloConstants.ConnectionKey, EnvironmentVariableTarget.Machine) ?? throw new ArgumentException($"Environment variable '{ApolloConstants.ConnectionKey}' is not configured"); var serverIdentifier = Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") == "true" ? $"{Environment.MachineName} {Environment.GetEnvironmentVariable("APOLLO_SERVER_ID")}" // Machine name will be the ID of the container if running in docker : (Environment.GetEnvironmentVariable("APOLLO_SERVER_ID") ?? $"Server {Guid.NewGuid()}"); var configuration = new ServiceBusConfiguration ( new ServiceBusConnectionStringBuilder(connectionKey), serverIdentifier ); var implementations = new ApolloServiceBusImplementations(configuration) { ServerPlugins = new ApolloPlugin[] { new EchoListenerPlugin(), new MessageCounterPlugin() } }; var container = new StandardKernel(implementations); container.Bind <IApolloServerRepository>().To <InMemoryApolloServerRepository>().InSingletonScope(); return(container); }
private static StandardKernel SetupIoc() { var connectionKey = Environment.GetEnvironmentVariable(ApolloConstants.ConnectionKey, EnvironmentVariableTarget.Process) ?? Environment.GetEnvironmentVariable(ApolloConstants.ConnectionKey, EnvironmentVariableTarget.User) ?? Environment.GetEnvironmentVariable(ApolloConstants.ConnectionKey, EnvironmentVariableTarget.Machine) ?? throw new ArgumentException($"Environment variable '{ApolloConstants.ConnectionKey}' is not configured"); var configuration = new ServiceBusConfiguration ( new ServiceBusConnectionStringBuilder(connectionKey) { TransportType = TransportType.Amqp }, Guid.NewGuid().ToString() ); var implementations = new ApolloServiceBusImplementations(configuration) { ClientPlugins = new ApolloPlugin[] { new EchoPlugin() } }; var container = new StandardKernel(implementations); return(container); }