Exemple #1
0
func init() {
	timeout := 1 * time.Second
	addr := DefaultAddr

	if a, err := config.RawStringDefault("zookeeper.addr"); err == nil {
		addr = a
	}

	if t, err := config.RawStringDefault("zookeeper.timeout"); err == nil {
		if timeout, err = time.ParseDuration(t); err != nil {
			log.Fatal("Failed to parse Zookeeper timeout", err)
		}
	}

	skynet.SetServiceManager(NewZookeeperServiceManager(addr, timeout))
}
// Helper for validating and testing send logic
// stubs ServiceManager, Pool, Connection, LoadBalancer
func stubForSend(sc ServiceClientProvider, f func(ri *skynet.RequestInfo, fn string, in interface{}, out interface{}) (err error)) {
	sm := &test.ServiceManager{}
	skynet.SetServiceManager(skynet.ServiceManager(sm))

	pool = &test.Pool{
		AcquireFunc: func(s skynet.ServiceInfo) (conn.Connection, error) {
			c := &test.Connection{
				SendTimeoutFunc: func(ri *skynet.RequestInfo, fn string, in interface{}, out interface{}, timeout time.Duration) (err error) {
					return f(ri, fn, in, out)
				},
			}

			return c, nil
		},
	}

	sClient := sc.(*ServiceClient)
	sClient.loadBalancer = &test.LoadBalancer{
		ChooseFunc: func() (s skynet.ServiceInfo, err error) {
			return
		},
	}
}
Exemple #3
0
func init() {
	skynet.SetServiceManager(serviceManager)
}