dsstore

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package dsstore is a Datastore-based storage for DAM/IC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entity added in v0.8.7

type Entity struct {
	Key      *datastore.Key `datastore:"__key__"`
	Service  string         `datastore:"service"`
	Datatype string         `datastore:"type"`
	Realm    string         `datastore:"realm"`
	User     string         `datastore:"user_id"`
	ID       string         `datastore:"id"`
	Rev      int64          `datastore:"rev"`
	Version  string         `datastore:"version,noindex"`
	Modified int64          `datastore:"modified"`
	Content  string         `datastore:"content,noindex"`
}

Entity is a datastore entity for data.

type History added in v0.8.7

type History struct {
	Key      *datastore.Key `datastore:"__key__"`
	Service  string         `datastore:"service"`
	Datatype string         `datastore:"type"`
	Realm    string         `datastore:"realm"`
	User     string         `datastore:"user_id"`
	ID       string         `datastore:"id"`
	Rev      int64          `datastore:"rev"`
	Version  string         `datastore:"version,noindex"`
	Modified int64          `datastore:"modified"`
	Content  string         `datastore:"content,noindex"`
}

History is an datastore entity for history.

type Key added in v0.8.7

type Key struct {
	Datatype string `datastore:"type"`
	Realm    string `datastore:"realm"`
	User     string `datastore:"user_id"`
	ID       string `datastore:"id"`
	Rev      int64  `datastore:"rev"`
}

Key is the key for items.

type Lock added in v0.8.6

type Lock struct {
	// contains filtered or unexported fields
}

Lock is the data for a lock.

func NewLock added in v0.8.6

func NewLock(client *datastore.Client, name string) *Lock

NewLock creates a new lock object.

func (*Lock) Acquire added in v0.8.6

func (l *Lock) Acquire(ctx context.Context, end time.Time) error

Acquire attempts to acquire the lock until the specified time. Warning: The times used are local times, be careful with cross process clock skew, stop assuming that you hold the lock slightly before you

func (*Lock) Release added in v0.8.6

func (l *Lock) Release(ctx context.Context) error

Release attempts to release the holding of the named lock.

func (*Lock) Reset added in v0.8.6

func (l *Lock) Reset(ctx context.Context) error

Reset clears the information about the lock from datastore.

type Meta added in v0.8.7

type Meta struct {
	Key   *datastore.Key `datastore:"__key__"`
	Name  string         `datastore:"name"`
	Value string         `datastore:"value,noindex"`
}

Meta is a datastore entity for meta.

type Store added in v0.8.7

type Store struct {
	// contains filtered or unexported fields
}

Store is a datastore based implementation of storage.

func New

func New(client *datastore.Client, project, service, path string) *Store

New creates a new storage.

func NewStore added in v0.8.7

func NewStore(ctx context.Context, project, service, path string) *Store

NewStore creates a new datastore storace and initilizes it. TODO: create the client for datastore in the main and inject it.

func (*Store) Delete added in v0.8.7

func (s *Store) Delete(datatype, realm, user, id string, rev int64) error

Delete deletes a data entity.

func (*Store) DeleteTx added in v0.8.7

func (s *Store) DeleteTx(datatype, realm, user, id string, rev int64, tx storage.Tx) (ferr error)

DeleteTx deletes a data entity inside a transaction.

func (*Store) Exists added in v0.8.7

func (s *Store) Exists(datatype, realm, user, id string, rev int64) (bool, error)

Exists checks if a data entity with the given name exists.

func (*Store) Info added in v0.8.7

func (s *Store) Info() map[string]string

Info returns some information about the store. TODO: delete this and pass the information directly rather than through store.

func (*Store) Init added in v0.8.7

func (s *Store) Init(ctx context.Context) error

Init initilizes the store. It creates some metadata information about the store on datastore. If metada information already exists on datastore, it comapres to see if they are compatible with the metadata information of the current store.

func (*Store) LockTx added in v0.8.7

func (s *Store) LockTx(lockName string, minFrequency time.Duration, tx storage.Tx) storage.Tx

LockTx returns a storage-wide lock by the given name. Only one such lock should be requested at a time. If Tx is provided, it must be an update Tx. TODO: get rid of this function and fix the code using it. Note: This doesn't provide distributed mutual exclusion, don't use this.

func (*Store) MultiDeleteTx added in v0.8.7

func (s *Store) MultiDeleteTx(datatype, realm, user string, tx storage.Tx) error

MultiDeleteTx deletes all records of a certain data type within a realm. If user is "", deletes for all users.

func (*Store) MultiReadTx added in v0.8.7

func (s *Store) MultiReadTx(datatype, realm, user string, filters [][]storage.Filter, offset, pageSize int, content map[string]map[string]proto.Message, typ proto.Message, tx storage.Tx) (_ int, ferr error)

MultiReadTx reads a set of data entities matching the filters. MultiReadTx will not see the writes inside the transaction. If realm is "" reads all realms. if user is "" reads all users. Returns the number of items matching the filter. content is a map of user and id to values.

func (*Store) Read added in v0.8.7

func (s *Store) Read(datatype, realm, user, id string, rev int64, content proto.Message) error

Read reads a data entity.

func (*Store) ReadHistory added in v0.8.7

func (s *Store) ReadHistory(datatype, realm, user, id string, content *[]proto.Message) error

ReadHistory reads the history.

func (*Store) ReadHistoryTx added in v0.8.7

func (s *Store) ReadHistoryTx(datatype, realm, user, id string, content *[]proto.Message, tx storage.Tx) (ferr error)

ReadHistoryTx reads the history inside a transaction.

func (*Store) ReadTx added in v0.8.7

func (s *Store) ReadTx(datatype, realm, user, id string, rev int64, content proto.Message, tx storage.Tx) (ferr error)

ReadTx reads a data entity inside a transaction. ReadTx will not see the writes inside the transaction.

func (*Store) Tx added in v0.8.7

func (s *Store) Tx(update bool) (storage.Tx, error)

Tx creates a new transaction for the store.

func (*Store) Wipe added in v0.8.7

func (s *Store) Wipe(realm string) error

Wipe deletes all data and history within a realm. If realm is "" deletes for all realms.

func (*Store) Write added in v0.8.7

func (s *Store) Write(datatype, realm, user, id string, rev int64, content proto.Message, history proto.Message) error

Write writes a data entity.

func (*Store) WriteTx added in v0.8.7

func (s *Store) WriteTx(datatype, realm, user, id string, rev int64, content proto.Message, history proto.Message, tx storage.Tx) (ferr error)

WriteTx writes a data entity inside a transaction.

type Tx added in v0.8.7

type Tx struct {
	Tx *datastore.Transaction
	// contains filtered or unexported fields
}

Tx is a transaction.

func (*Tx) Finish added in v0.8.7

func (tx *Tx) Finish() error

Finish attempts to commit a transaction.

func (*Tx) IsUpdate added in v0.8.7

func (tx *Tx) IsUpdate() bool

IsUpdate tells if the transaction is an update or read-only.

func (*Tx) Rollback added in v0.8.7

func (tx *Tx) Rollback() error

Rollback attempts to rollback a transaction.

Directories

Path Synopsis
Binary itest runs some code against Datastore.
Binary itest runs some code against Datastore.

Jump to

Keyboard shortcuts

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