private void setUpPubSubClient() { var pubsubImpl = configReader.GetCheckedValueOrDefault <string, ServiceRunnerConfig>( new[] { "service", "pubSub" }, "dummy"); if (pubsubImpl == "redis") { var host = configReader.GetCheckedValue <string, ServiceRunnerConfig>("redis", "host"); var port = configReader.GetCheckedValue <int, ServiceRunnerConfig>("redis", "port"); var extra = configReader.GetCheckedValueOrDefault <string, ServiceRunnerConfig>(new[] { "redis", "extra" }, ""); var redisClient = new RedisPubSubClient(host, port, extra); logger.InfoFormat("Using pub/sub Redis address at {0}:{1}", host, port); context.InitPubSubClient(redisClient); } else { logger.Info("Using a dummy pub/sub client."); context.InitPubSubClient(); } }
public void LoadFromConfig(ConfigReader config) { List <ServiceAssignmentConfig.ServiceAssignment.ServiceType> serviceNames = config.GetCheckedValueOrDefault <List <ServiceAssignmentConfig.ServiceAssignment.ServiceType>, ServiceAssignmentConfig>(new[] { "serviceAssignment", "static" }, new List <ServiceAssignmentConfig.ServiceAssignment.ServiceType>()); foreach (var name in serviceNames) { var uri = new Uri($"http://{name.host}:{name.port}"); logger.DebugFormat("Added service assignment {0} {1}", name, uri); Add(name, uri); } }
public void InitRestfulServer(IPAddress host = null, int port = 0) { host = IPAddress.Loopback ?? host; RestfulServer = new RestfulServer(host, port); var password = ConfigReader.GetCheckedValueOrDefault <string, ServiceRunnerConfig>( new[] { "restful", "localAuthenticationPassword" }, null); if (password != null) { RestfulServer.SetPassword(password); } }