offline

package
v3.1.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2019 License: BSD-3-Clause, BSD-3-Clause Imports: 9 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{}, res interface{},
	handler func(mctx libkb.MetaContext) (interface{}, error)) (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` already has the argument "baked up", and also, is responsibly for setting a result of the right type in the caller's stack frame. `handler` also returns the return value for the RPC as an inteface, 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. This flow is unfortunately complicated, but the issue is that we're trying to maintain runtime type checking, and it's hard to do without generics.

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