예제 #1
0
파일: proxy.go 프로젝트: lucmichalski/fae
func (this *ConfigProxy) LoadConfig(selfAddr string, cf *conf.Conf) {
	if selfAddr == "" {
		panic("proxy self addr unknown")
	}
	this.PoolCapacity = cf.Int("pool_capacity", 10)
	this.IdleTimeout = cf.Duration("idle_timeout", 0)
	this.IoTimeout = cf.Duration("io_timeout", time.Second*10)
	this.BorrowTimeout = cf.Duration("borrow_timeout", time.Second*10)
	this.DiagnosticInterval = cf.Duration("diagnostic_interval", time.Second*5)
	this.TcpNoDelay = cf.Bool("tcp_nodelay", true)
	this.BufferSize = cf.Int("buffer_size", 4<<10)
	this.SelfAddr = selfAddr
	parts := strings.SplitN(this.SelfAddr, ":", 2)
	if parts[0] == "" {
		// auto get local ip when self_addr like ":9001"
		ips, _ := ip.LocalIpv4Addrs()
		if len(ips) == 0 {
			panic("cannot get local ip address")
		}

		this.SelfAddr = ips[0] + ":" + parts[1]
	}

	log.Debug("proxy conf: %+v", *this)
}
예제 #2
0
파일: peer.go 프로젝트: justinblah/fae
func NewPeer(gaddr string, interval int, deadThreshold float64) (this *Peer) {
	this = new(Peer)
	this.RWMutex = new(sync.RWMutex)
	this.groupAddr = gaddr
	this.selfAddr = ip.LocalIpv4Addrs()[0]
	this.picker = newPeerPicker(this.selfAddr)
	this.heartbeatInterval = interval
	this.deadThreshold = deadThreshold
	this.neighbors = make(map[string]time.Time)
	return
}
예제 #3
0
파일: proxy.go 프로젝트: lucmichalski/fae
func New(cf *config.ConfigProxy) *Proxy {
	ips, _ := ip.LocalIpv4Addrs()
	this := &Proxy{
		cf:                   cf,
		remotePeerPools:      make(map[string]*funServantPeerPool),
		selector:             newStandardPeerSelector(),
		myIp:                 ips[0],
		clusterTopologyReady: false,
		clusterTopologyChan:  make(chan bool),
	}

	return this
}
예제 #4
0
파일: engine.go 프로젝트: lucmichalski/fae
func (this *ConfigEngine) LoadConfig(cf *conf.Conf) {
	this.Conf = cf

	this.HttpListenAddr = this.String("http_listen_addr", "")
	this.PprofListenAddr = this.String("pprof_listen_addr", "")
	this.DashboardListenAddr = this.String("dashboard_listen_addr", "")
	this.MetricsLogfile = this.String("metrics_logfile", "metrics.log")
	this.ReloadWatchdogInterval = this.Duration("reload_watchdog_interval", time.Second)
	this.ServerMode = this.Bool("server_mode", true)

	// rpc section
	this.Rpc = new(ConfigRpc)
	section, err := this.Section("rpc")
	if err != nil {
		panic(err)
	}
	this.Rpc.LoadConfig(section)

	// servants section
	this.Servants = new(ConfigServant)
	section, err = this.Section("servants")
	if err != nil {
		panic(err)
	}
	this.Servants.LoadConfig(this.Rpc.ListenAddr, section)

	// after load all configs, calculate EtcdSelfAddr
	this.EtcdServers = cf.StringList("etcd_servers", nil)
	if len(this.EtcdServers) > 0 {
		this.EtcdSelfAddr = this.Rpc.ListenAddr
		if strings.HasPrefix(this.EtcdSelfAddr, ":") {
			// automatically get local ip addr
			ips, _ := ip.LocalIpv4Addrs()
			this.EtcdSelfAddr = ips[0] + this.EtcdSelfAddr
		}
	}

	log.Debug("engine conf: %+v", *this)
}