Documentation ¶
Overview ¶
Package database implements the persistence layer for the gpu debugger tools.
Index ¶
- func Build(ctx context.Context, r Resolvable) (interface{}, error)
- func GetOrBuild(ctx context.Context, r Resolvable) (interface{}, error)
- func Put(ctx context.Context, d Database) context.Context
- func Resolve(ctx context.Context, id id.ID) (interface{}, error)
- func Store(ctx context.Context, v interface{}) (id.ID, error)
- type Database
- type Resolvable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
func Build(ctx context.Context, r Resolvable) (interface{}, error)
Build stores resolvable into d, and then resolves and returns the resolved object.
func GetOrBuild ¶
func GetOrBuild(ctx context.Context, r Resolvable) (interface{}, error)
GetOrBuild stores resolvable into d, if the object is already resolved in the database, returns it. Otherwise it schdules the resource to be build and returns nil.
Types ¶
type Database ¶
type Database interface { // Store adds a key-value pair to the database. // If the id is already mapped to an object, // then nothing is stored. Store(context.Context, interface{}) (id.ID, error) // Resolve attempts to resolve the final value associated with an id. // It will traverse all Resolvable objects, blocking until they are ready. Resolve(context.Context, id.ID) (interface{}, error) // IsResolved returns true if the object is in the database, // and has already been resolved, and false if either the object // is not in the database, or is, but has not been resolved yet. IsResolved(context.Context, id.ID) bool // Contains returns true if the database has an entry for the specified id. Contains(context.Context, id.ID) bool }
Database is the interface to a resource store.
func NewInMemory ¶
NewInMemory builds a new in memory database.
type Resolvable ¶
type Resolvable interface { // Resolve constructs and returns the lazily-built object. Resolve(ctx context.Context) (interface{}, error) }
Resolvable is the interface for types that redirects database resolves to an object lazily built using Resolve(). The Resolve() method will be called the first time the object is resolved, and all subsequent resolves will return the same pre-built object. Resolvable is commonly implemented by objects that generate data that is expensive to calculate but can be deterministically produced using the information stored in the Resolvable.