offline

package
v4.7.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2019 License: BSD-3-Clause, BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RPCCache

type RPCCache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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.

type Value

type Value struct {
	Version Version
	Data    []byte
}

type Version

type Version int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL