// NewSharedKeybaseConnection returns a connection that tries to // connect to the local keybase daemon. func NewSharedKeybaseConnection(kbCtx *libkb.GlobalContext, config Config, handler rpc.ConnectionHandler) *rpc.Connection { transport := &SharedKeybaseTransport{kbCtx: kbCtx} return rpc.NewConnectionWithTransport(handler, transport, libkb.ErrorUnwrapper{}, true, libkb.WrapError, config.MakeLogger(""), LogTagsFromContext) }
func (g *gregorHandler) connectNoTLS(uri *rpc.FMPURI) error { g.Debug("connecting to gregord without TLS at %s", uri) t := newConnTransport(g.G(), uri.HostPort) g.transportForTesting = t g.connMutex.Lock() g.conn = rpc.NewConnectionWithTransport(g, t, keybase1.ErrorUnwrapper{}, true, keybase1.WrapError, g.G().Log, nil) g.connMutex.Unlock() g.cli = g.conn.GetClient() // Start up ping loop to keep the connection to gregord alive, and to kick // off the reconnect logic in the RPC library go g.pingLoop() return nil }
func PingGregor(g *libkb.GlobalContext) error { var pingError error g.Log.Debug("+ libkb.PingGregor") defer g.Log.Debug("- libkb.PingGregor %#v", pingError) transport := &pingGregorTransport{ Contextified: libkb.NewContextified(g), host: strings.TrimPrefix(g.Env.GetGregorURI(), "fmprpc://"), } rpcHandler := &pingGregorHandler{ Contextified: libkb.NewContextified(g), pingErrors: make(chan error), pingSuccess: make(chan struct{}), } connection := rpc.NewConnectionWithTransport(rpcHandler, transport, keybase1.ErrorUnwrapper{}, true, keybase1.WrapError, g.Log, nil) select { case err := <-rpcHandler.pingErrors: pingError = fmt.Errorf("Gregor ping FAILED: %s", err.Error()) case <-rpcHandler.pingSuccess: } connection.Shutdown() return pingError }