Documentation ¶
Overview ¶
Package database implements the persistence layer for the gpu debugger tools.
Index ¶
- func Build(ctx context.Context, r Resolvable) (interface{}, error)
- func Hash(ctx context.Context, val interface{}) (id.ID, 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 Hash ¶
Hash returns a unique id.ID based on the contents of the object. Two objects of identical content will return the same ID, and the probability of two objects with different content generating the same ID will be ignorable. Objects with a graph structure are allowed. Only members that would be encoded using a binary.Encoder are considered.
Types ¶
type Database ¶
type Database interface { // Store adds a key-value pair to the database. // It is an error if the id is already mapped to an object. Store(context.Context, id.ID, interface{}, proto.Message) 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) // 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.