entity

package
v0.8.1-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package entity is a connector to execute CRUD commands for a single entity and many entities on a DB instance.

A note on querying limitations:

This package uses the Kubernetes Labels Selector syntax (KLS) for its
query language. There are some querying limitations with using KLS which
is explained below:

  Querying many entities: there are some limitations.

    Because of limitations in KLS, a caller can only query by field names
    that are alphanumeric characters, '-', '_' or '.', and that start and
    end with an alphanumeric character. The limitations also extend to
    operators and values. Less than and greater than operators will
    interpret their values as an integer.  All other operators will
    interpret their values as a string. For example, caller cannot query
    for all documents that have field name "x" with value 2.

  Creating entities: there are no limitations.

    CreateEntities will allow you to create any entity that's a map of a
    string to interface{}. However, given the query limitations explained
    above, if you expect to be able to query for a field/value, ensure you
    only create an entity that would then satisfy a query.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("entity not found")
)

Functions

This section is empty.

Types

type ErrCreate

type ErrCreate struct {
	DbError error
	N       int // number of entities successfully created
}

ErrCreate is a higher level error for caller to check against when calling CreateEntities. It holds the lower level error message from DB and the number of entities successfully inserted on create.

func (ErrCreate) Error

func (e ErrCreate) Error() string

type ErrDelete

type ErrDelete struct {
	DbError error
}

ErrDelete is a higher level error for caller to check against when calling DeleteEntities. It holds the lower level error message from DB.

func (ErrDelete) Error

func (e ErrDelete) Error() string

type ErrDeleteLabel

type ErrDeleteLabel struct {
	DbError error
}

ErrDeleteLabel is a higher level error for caller to check against when calling DeleteLabel. It holds the lower level error message from DB.

func (ErrDeleteLabel) Error

func (e ErrDeleteLabel) Error() string

type ErrRead

type ErrRead struct {
	DbError error
}

ErrRead is a higher level error for caller to check against when calling ReadEntities. It holds the lower level error message from DB.

func (ErrRead) Error

func (e ErrRead) Error() string

type ErrUpdate

type ErrUpdate struct {
	DbError error
}

ErrUpdate is a higher level error for caller to check against when calling UpdateEntities. It holds the lower level error message from DB.

func (ErrUpdate) Error

func (e ErrUpdate) Error() string

type Store

type Store interface {
	// Managing labels for a single entity
	DeleteLabel(WriteOp, string) (etre.Entity, error)

	// Managing multiple entities
	ReadEntities(string, query.Query, etre.QueryFilter) ([]etre.Entity, error)
	CreateEntities(WriteOp, []etre.Entity) ([]string, error)
	UpdateEntities(WriteOp, query.Query, etre.Entity) ([]etre.Entity, error)
	DeleteEntities(WriteOp, query.Query) ([]etre.Entity, error)
}

Store interface has methods needed to do CRUD operations on entities.

func NewStore

func NewStore(conn db.Connector, database string, entityTypes []string, cdcs cdc.Store, dm cdc.Delayer) (Store, error)

NewStore creates a Store.

type WriteOp

type WriteOp struct {
	User       string // required
	EntityType string // required
	EntityId   string // optional

	// Delete ops do not support set ops like insert and update because no
	// entities are sent by the client on delete. However, the caller can do
	// DELETE /entity/node?setOp=foo&setId=bar&setSize=2 and the controller
	// will pass along the set op values. This could (but not currently) also
	// be used to impose/inject a set op on a write op that doesn't specify
	// a set op.
	SetOp   string // optional
	SetId   string // optional
	SetSize int    // optional
}

WriteOp represents common metadata for insert, update, and delete Store methods.

Jump to

Keyboard shortcuts

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