Esempio n. 1
0
func (this *GcollectorConfig) LoadConfig(cf *conf.Conf) {
	this.EtcServers = cf.StringList("etc_servers", nil)
	if this.EtcServers == nil {
		panic("No etc servers found")
	}

	this.App = cf.String("app", "")
	if this.App == "" {
		panic("No app specified")
	}

	this.UdpPort = cf.Int("udp_port", 14570)

	this.Inputs = make([]*InputConfig, 0)
	for i, _ := range cf.List("inputs", []interface{}{}) {
		section, err := cf.Section(fmt.Sprintf("inputs[%d]", i))
		if err != nil {
			panic(err)
		}
		input := new(InputConfig)
		input.File = section.StringList("file", nil)
		types := strings.Split(section.String("types", ""), ",")
		for _, tp := range types {
			input.Types = append(input.Types, strings.Trim(tp, " "))
		}
		this.Inputs = append(this.Inputs, input)
	}
}
Esempio n. 2
0
File: redis.go Progetto: cmotc/pushd
func (this *ConfigRedis) LoadConfig(cf *conf.Conf) {
	this.Addr = cf.String("addr", ":6379")
	this.ConnTimeout = cf.Duration("conn_timeout", time.Second*5)
	this.ReadTimeout = cf.Duration("read_timeout", time.Second*5)
	this.WriteTimeout = cf.Duration("write_timeout", time.Second*5)
}
Esempio n. 3
0
File: mongo.go Progetto: cmotc/pushd
func (this *ConfigMongo) LoadConfig(cf *conf.Conf) {
	this.Addr = cf.String("addr", ":27017")
	this.ConnTimeout = cf.Duration("conn_timeout", time.Second*5)
	this.OperationTimeout = cf.Duration("operation_timeout", time.Second*5)
	this.SyncTimeout = cf.Duration("sync_timeout", time.Second*5)
}
Esempio n. 4
0
File: pushd.go Progetto: cmotc/pushd
func (this *ConfigPushd) LoadConfig(cf *conf.Conf) {
	this.TcpListenAddr = cf.String("tcp_listen_addr", ":2222")
	this.SessionTimeout = cf.Duration("session_timeout", time.Minute*2)
	this.ServInitialGoroutineNum = cf.Int("serv_initial_goroutine_num", 200)

	this.LongPollingListenAddr = cf.String("long_polling_listen_addr", "")
	if this.LongPollingListenAddr != "" {
		this.LongPollingSessionTimeout = cf.Duration("long_polling_session_timeout", time.Minute)
	}

	this.StatsListenAddr = cf.String("stats_listen_addr", ":9020")
	this.ProfListenAddr = cf.String("prof_listen_addr", ":9021")

	this.S2sListenAddr = GetS2sAddr(this.TcpListenAddr)
	this.S2sSessionTimeout = cf.Duration("s2s_conn_timeout", time.Minute*2)
	this.S2sIntialGoroutineNum = cf.Int("s2s_initial_goroutine_num", 8)

	this.S2sChannelPeersMaxItems = cf.Int("s2s_channel_peers_max_items", 200000)

	this.EtcServers = cf.StringList("etc_servers", nil)
	if len(this.EtcServers) == 0 {
		this.EtcServers = nil
	}

	this.MetricsLogfile = cf.String("metrics_logfile", "metrics.log")
	this.StatsOutputInterval = cf.Duration("stats_output_interval", time.Minute*10)

	this.PubsubChannelMaxItems = cf.Int("pubsub_channel_max_items", 200000)

	this.MsgStorage = cf.String("msg_storage", "")
	if this.MsgStorage != "" {
		this.MaxStorageOutstandingMsg = cf.Int("max_storage_outstanding_msg", 100)
		this.MsgFlushPolicy = cf.Int("msg_storage_flush_policy", MSG_FLUSH_EVERY_TRX)
		if this.MsgFlushPolicy != MSG_FLUSH_EVERY_TRX && this.MsgFlushPolicy != MSG_FLUSH_EVERY_SECOND {
			panic("invalid msg flush policy")
		}
		this.MsgStorageWriteBufferSize = cf.Int("msg_storage_write_buffer_size", 10000)
		this.MaxCacheMsgsEveryChannel = cf.Int("max_cache_msgs_every_channel", 3000)
	}

	this.Redis = new(ConfigRedis)
	section, err := cf.Section("redis")
	if err == nil {
		this.Redis.LoadConfig(section)
	}

	this.Mongo = new(ConfigMongo)
	section, err = cf.Section("mongodb")
	if err != nil {
		panic("Mongodb config not found")
	}
	this.Mongo.LoadConfig(section)
}