// newConfig creates new libcentrifugo.Config using viper. func newConfig() *libcentrifugo.Config { cfg := &libcentrifugo.Config{} cfg.Version = VERSION cfg.Name = getApplicationName() cfg.WebPassword = viper.GetString("web_password") cfg.WebSecret = viper.GetString("web_secret") cfg.ChannelPrefix = viper.GetString("channel_prefix") cfg.AdminChannel = libcentrifugo.ChannelID(cfg.ChannelPrefix + "." + "admin") cfg.ControlChannel = libcentrifugo.ChannelID(cfg.ChannelPrefix + "." + "control") cfg.MaxChannelLength = viper.GetInt("max_channel_length") cfg.NodePingInterval = int64(viper.GetInt("node_ping_interval")) cfg.NodeInfoCleanInterval = cfg.NodePingInterval * 3 cfg.NodeInfoMaxDelay = cfg.NodePingInterval*2 + 1 cfg.PresencePingInterval = int64(viper.GetInt("presence_ping_interval")) cfg.PresenceExpireInterval = int64(viper.GetInt("presence_expire_interval")) cfg.MessageSendTimeout = int64(viper.GetInt("message_send_timeout")) cfg.PrivateChannelPrefix = viper.GetString("private_channel_prefix") cfg.NamespaceChannelBoundary = viper.GetString("namespace_channel_boundary") cfg.UserChannelBoundary = viper.GetString("user_channel_boundary") cfg.UserChannelSeparator = viper.GetString("user_channel_separator") cfg.ClientChannelBoundary = viper.GetString("client_channel_boundary") cfg.ExpiredConnectionCloseDelay = int64(viper.GetInt("expired_connection_close_delay")) cfg.Insecure = viper.GetBool("insecure") return cfg }
// newConfig creates new libcentrifugo.Config using viper. func newConfig() *libcentrifugo.Config { cfg := &libcentrifugo.Config{} cfg.Version = VERSION cfg.Name = getApplicationName() cfg.Debug = viper.GetBool("debug") cfg.Web = viper.GetBool("web") cfg.WebPassword = viper.GetString("web_password") cfg.WebSecret = viper.GetString("web_secret") cfg.ChannelPrefix = viper.GetString("channel_prefix") cfg.AdminChannel = libcentrifugo.ChannelID(cfg.ChannelPrefix + "." + "admin") cfg.ControlChannel = libcentrifugo.ChannelID(cfg.ChannelPrefix + "." + "control") cfg.MaxChannelLength = viper.GetInt("max_channel_length") cfg.PingInterval = time.Duration(viper.GetInt("ping_interval")) * time.Second cfg.NodePingInterval = time.Duration(viper.GetInt("node_ping_interval")) * time.Second cfg.NodeInfoCleanInterval = cfg.NodePingInterval * 3 cfg.NodeInfoMaxDelay = cfg.NodePingInterval*2 + 1*time.Second cfg.NodeMetricsInterval = time.Duration(viper.GetInt("node_metrics_interval")) * time.Second cfg.PresencePingInterval = time.Duration(viper.GetInt("presence_ping_interval")) * time.Second cfg.PresenceExpireInterval = time.Duration(viper.GetInt("presence_expire_interval")) * time.Second cfg.MessageSendTimeout = time.Duration(viper.GetInt("message_send_timeout")) * time.Second cfg.PrivateChannelPrefix = viper.GetString("private_channel_prefix") cfg.NamespaceChannelBoundary = viper.GetString("namespace_channel_boundary") cfg.UserChannelBoundary = viper.GetString("user_channel_boundary") cfg.UserChannelSeparator = viper.GetString("user_channel_separator") cfg.ClientChannelBoundary = viper.GetString("client_channel_boundary") cfg.ExpiredConnectionCloseDelay = time.Duration(viper.GetInt("expired_connection_close_delay")) * time.Second cfg.StaleConnectionCloseDelay = time.Duration(viper.GetInt("stale_connection_close_delay")) * time.Second cfg.ClientRequestMaxSize = viper.GetInt("client_request_max_size") cfg.ClientQueueMaxSize = viper.GetInt("client_queue_max_size") cfg.ClientQueueInitialCapacity = viper.GetInt("client_queue_initial_capacity") cfg.ClientChannelLimit = viper.GetInt("client_channel_limit") cfg.Insecure = viper.GetBool("insecure") cfg.InsecureAPI = viper.GetBool("insecure_api") cfg.InsecureWeb = viper.GetBool("insecure_web") cfg.Secret = viper.GetString("secret") cfg.ConnLifetime = int64(viper.GetInt("connection_lifetime")) cfg.Watch = viper.GetBool("watch") cfg.Publish = viper.GetBool("publish") cfg.Anonymous = viper.GetBool("anonymous") cfg.Presence = viper.GetBool("presence") cfg.JoinLeave = viper.GetBool("join_leave") cfg.HistorySize = viper.GetInt("history_size") cfg.HistoryLifetime = viper.GetInt("history_lifetime") cfg.HistoryDropInactive = viper.GetBool("history_drop_inactive") cfg.Recover = viper.GetBool("recover") cfg.Namespaces = namespacesFromConfig(nil) return cfg }