Documentation ¶
Index ¶
- type DB
- func (d *DB) Backup(w io.Writer, sinceUnix int64) (int64, error)
- func (d *DB) Close() func()
- func (d *DB) FuncMap() template.FuncMap
- func (d *DB) Get(tenant, bucket string) ([]Record, error)
- func (d *DB) GetContains(tenant, bucket, contains string) ([]Record, error)
- func (d *DB) GetKey(tenant, bucket string, key string) (Record, error)
- func (d *DB) GetPattern(tenant, bucket, regex string) ([]Record, error)
- func (d *DB) KeyExists(tenant, bucket string, key string) bool
- func (d *DB) LoadBackup(r io.Reader, maxPendingBytes int64) error
- func (d *DB) Set(r Record) error
- func (d *DB) SetMany(records []Record) error
- func (d *DB) Start(ctx context.Context) error
- func (d *DB) Subscribe(sub SubscriptionOpts) error
- type Opts
- type Record
- type SubscriptionOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is an embedded JSON database
func (*DB) Backup ¶
Backup dumps a protobuf-encoded list of all entries in the database into the given writer, that are newer than the specified version. It returns a timestamp indicating when the entries were dumped which can be passed into a later invocation to generate an incremental dump
func (*DB) Close ¶
func (d *DB) Close() func()
Close closes all channels then shuts down the database
func (*DB) GetContains ¶ added in v1.0.0
GetContains returns a array of records within a bucket that have keys that contain the input string.
func (*DB) GetPattern ¶ added in v1.0.0
GetPattern returns a array of records within a bucket that have keys that match the regex pattern.
func (*DB) KeyExists ¶ added in v1.0.0
KeyExists returns true if the key is within the target bucket
func (*DB) LoadBackup ¶
LoadBackup reads a protobuf-encoded list of all entries from a reader and writes them to the database.
func (*DB) Subscribe ¶ added in v1.0.0
func (d *DB) Subscribe(sub SubscriptionOpts) error
type Record ¶
type Record struct { Key string `json:"key"` Tenant string `json:"tenant"` Bucket string `json:"bucket"` Value gjson.Result `json:"value"` Metadata map[string]string `json:"metadata"` ExpiresUnix int64 `json:"expiresUnix"` }
Record is a stored json object. The key is what may be used later to query the JSON object from the database.
func NewObjectRecord ¶ added in v1.0.0
type SubscriptionOpts ¶ added in v1.0.0
type SubscriptionOpts struct { Id string Tenant string // tenant is required if not global Buckets []string // at least one bucket if not global TargetKeys []string // if specified, only keys within this array will be streamed Global bool // subscribe to all buckets // Handler is executed on filtered records after they are created. Handler func(r Record) }