// Connect Connects to RPC
func (r *RPCPurger) Connect() {
	if RPCClientIsConnected {
		if RPCCLientSingleton != nil {
			if RPCFuncClientSingleton != nil {
				log.Info("RPC Analytics client using singleton")
				r.RPCClient = RPCCLientSingleton
				r.Client = RPCFuncClientSingleton
				return
			}
		}
	}

	log.Info("Connecting to RPC Analytics service")
	r.RPCClient = gorpc.NewTCPClient(r.Address)

	if log.Level != logrus.DebugLevel {
		gorpc.SetErrorLogger(gorpc.NilErrorLogger)
	}

	r.RPCClient.Start()
	d := GetDispatcher()
	r.Client = d.NewFuncClient(r.RPCClient)

	return
}
示例#2
0
// Connect will establish a connection to the DB
func (r *RPCStorageHandler) Connect() bool {
	// We don't want to constantly connect
	if r.Connected {
		return true
	}

	// Set up the cache
	r.cache = cache.New(30*time.Second, 15*time.Second)
	r.RPCClient = gorpc.NewTCPClient(r.Address)

	if log.Level != logrus.DebugLevel {
		gorpc.SetErrorLogger(gorpc.NilErrorLogger)
	}

	r.RPCClient.OnConnect = r.OnConnectFunc
	r.RPCClient.Conns = 10
	r.RPCClient.Start()
	d := GetDispatcher()
	r.Client = d.NewFuncClient(r.RPCClient)
	r.Login()

	if !r.SuppressRegister {
		r.Register()
		go r.checkDisconnect()
	}

	return true
}
// Connect will establish a connection to the DB
func (r *RPCStorageHandler) Connect() bool {

	if RPCClientIsConnected {
		log.Debug("Using RPC singleton for connection")
		return true
	}

	// RPC Client is unset
	// Set up the cache
	log.Info("Setting new RPC connection!")
	RPCCLientSingleton = gorpc.NewTCPClient(r.Address)

	if log.Level != logrus.DebugLevel {
		gorpc.SetErrorLogger(gorpc.NilErrorLogger)
	}

	RPCCLientSingleton.OnConnect = r.OnConnectFunc
	RPCCLientSingleton.Conns = 50
	RPCCLientSingleton.Start()
	d := GetDispatcher()

	if RPCFuncClientSingleton == nil {
		RPCFuncClientSingleton = d.NewFuncClient(RPCCLientSingleton)
	}

	r.Login()

	if !r.SuppressRegister {
		r.Register()
		go r.checkDisconnect()
	}

	return true
}
示例#4
0
// Connect Connects to Mongo
func (r *RPCPurger) Connect() {
	log.Info("Connecting to RPC Analytics service")
	r.RPCClient = gorpc.NewTCPClient(r.Address)
	r.RPCClient.Start()
	d := GetDispatcher()
	r.Client = d.NewFuncClient(r.RPCClient)

	return
}
示例#5
0
// Connect Connects to RPC
func (r *RPCPurger) Connect() {
	log.Info("Connecting to RPC Analytics service")
	r.RPCClient = gorpc.NewTCPClient(r.Address)

	if log.Level != logrus.DebugLevel {
		gorpc.SetErrorLogger(gorpc.NilErrorLogger)
	}

	r.RPCClient.Start()
	d := GetDispatcher()
	r.Client = d.NewFuncClient(r.RPCClient)

	return
}
示例#6
0
// Connect will establish a connection to the DB
func (r *RPCStorageHandler) Connect() bool {
	// Set up the cache
	r.cache = cache.New(30*time.Second, 15*time.Second)
	r.RPCClient = gorpc.NewTCPClient(r.Address)
	r.RPCClient.OnConnect = r.OnConnectFunc
	r.RPCClient.Conns = 10
	r.RPCClient.Start()
	d := GetDispatcher()
	r.Client = d.NewFuncClient(r.RPCClient)
	r.Login()

	r.Register()
	go r.checkDisconnect()

	return true
}