Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RPCCache ¶
func NewRPCCache ¶
func NewRPCCache(g *libkb.GlobalContext) *RPCCache
func (*RPCCache) Serve ¶
func (c *RPCCache) Serve(mctx libkb.MetaContext, oa keybase1.OfflineAvailability, version Version, rpcName string, encrypted bool, arg interface{}, resPtr interface{}, handler func(mctx libkb.MetaContext) (interface{}, error)) (res interface{}, err error)
Serve an RPC out of the offline cache. The machinery only kicks into gear if the `oa` OfflineAvailability mode is set to BEST_EFFORT. If not, then just use the function `handler` which does the main work of handling the RPC. Note that `handler` must not modify anything in the caller's stack frame; it might be run in a background goroutine after this function returns, to populate the cache. `handler` also returns the return value for the RPC as an interface, so it can be inserted into the offline cache in the success case. We also pass this function a `version`, which will tell the cache-access machinery to fail if the wrong version of the data is cached. Next, we pass the `rpcName`, the argument, and the pointer to which the result is stored if we hit the cache.
If this function doesn't return an error, and the returned `res` is nil, then `resPtr` will have been filled in already by the cache. Otherwise, `res` should be used by the caller as the response.