Documentation ¶
Index ¶
- Variables
- func IsErrNoSuchEntity(err error) bool
- func Register(driver Driver)
- func SafeUnmarshal(data []byte, v interface{}) error
- type Connection
- type Context
- type DataStore
- type Driver
- type Entity
- type EntityStore
- type ErrNoSuchEntity
- type JSONMessage
- type Key
- type Query
- type Results
- type ValidEntity
- type VersionedEntity
Constants ¶
This section is empty.
Variables ¶
var ( //ErrNilEntity returned when Entity parameter is nil ErrNilEntity = errors.New("nil Entity") //ErrNilContext returned when Context parameter is nil ErrNilContext = errors.New("nil Context") //ErrNilKind returned when Kind parameter is nil ErrNilKey = errors.New("nil Key") //ErrEmptyKindID returned when a key has an empty ID ErrEmptyKindID = errors.New("empty Kind id") //ErrEmptyKind returned when a key has an empty kind ErrEmptyKind = errors.New("empty Kind") )
var ErrNoSuchElement = errors.New("no such element")
ErrNoSuchElement if requested element not available
Functions ¶
func IsErrNoSuchEntity ¶
IsErrNoSuchEntity check see if error param is of type ErrNoSuchEntity
func SafeUnmarshal ¶
SafeUnmarshal sets the json decoder to use number types
Types ¶
type Connection ¶
type Connection interface { // Put adds or updates an entity in the datastore using the Key. Put(key Key, data JSONMessage) error // Get returns an entity from the datastore. Can return ErrNoSuchEntity if the entity does not exists Get(key Key) (JSONMessage, error) // Delete deletes an entity associated with the key Delete(key Key) error // Query evaluates the query and returns a list of entities form the datastore Query(query esapi.SearchRequest) ([]JSONMessage, error) }
Connection is the interface for interacting with a datastore
type Context ¶
type Context interface { // Get a connection to the datastore Connection() (Connection, error) // Get the Metrics object from the context Metrics() *metrics.Metrics // Get and set the user for audit logging SetUser(user string) User() string }
Context is the context of the application or request being made
func GetNew ¶
func GetNew() Context
GetNew() returns a new global context. This function is not intended for production use, but is for the purpose of getting fresh contexts for performance testing with metrics for troubleshooting.
func GetNewInstance ¶
func GetNewInstance() Context
GetNewInstance returns a new instance of the context object, but with the metrics and connections from the global context object.
type DataStore ¶
type DataStore struct{}
DataStore EntityStore type
type Driver ¶
type Driver interface { // GetConnection returns a connection to the datastore. GetConnection() (Connection, error) }
Driver is the interface for a driver to a datastore
type Entity ¶
Entity is the interface for encapsulating an object's name and type for use with modules such as a logger.
type EntityStore ¶
type EntityStore interface { // Put adds or updates an entity Put(ctx Context, key Key, entity ValidEntity) error // Get an entity. Return ErrNoSuchEntity if nothing found for the key. Get(ctx Context, key Key, entity ValidEntity) error // Delete removes the entity Delete(ctx Context, key Key) error }
EntityStore interface for storing and retrieving data types from a datastore.
type ErrNoSuchEntity ¶
type ErrNoSuchEntity struct {
Key Key
}
ErrNoSuchEntity is returned when no entity was found for a given key.
func (ErrNoSuchEntity) Error ¶
func (e ErrNoSuchEntity) Error() string
type JSONMessage ¶
type JSONMessage interface { // Bytes return the JSON bytes of an entity Bytes() json.RawMessage Version() map[string]int }
JSONMessage Represents a enity as JSON
func NewJSONMessage ¶
func NewJSONMessage(data []byte, version map[string]int) JSONMessage
NewJSONMessage creates a JSONMessage using the provided bytes. The bytes should represent valid JSON
type Key ¶
type Key interface { // Kind is the type of the entity Kind() string // ID is the id of the entity ID() string }
Key is a unique identifier for an entity. A key is composed of a kind or type of entity and the id of the entity.
type Query ¶
type Query interface { // Execute performs the query and returns an Results to the results. For now this query is specific to the // underlying Connection and Driver implementation. Execute(query esapi.SearchRequest) (Results, error) }
Query is a query used to search for and return entities from a datastore
type Results ¶
type Results interface { // Next retrieves the next available result into entity and advances the Results to the next available entity. // ErrNoSuchElement is returned if no more results. Next(entity ValidEntity) error // HasNext returns true if a call to next would yield a value or false if no more entities are available HasNext() bool //Len return the length of the results Len() int //Len return the length of the results Get(idx int, entity ValidEntity) error }
Results iterates or indexes into the results returned from a query
type ValidEntity ¶
type ValidEntity interface { ValidEntity() error GetType() string SetType(string) GetSeqNo() int SetSeqNo(int) GetPrimaryTerm() int SetPrimaryTerm(int) }
ValidEntity interface for entities that can be stored in the EntityStore
type VersionedEntity ¶
type VersionedEntity struct { IfSeqNo int `json:"-"` IfPrimaryTerm int `json:"-"` Type string `json:"type,omitempty"` }
func (*VersionedEntity) GetPrimaryTerm ¶
func (e *VersionedEntity) GetPrimaryTerm() int
func (*VersionedEntity) GetSeqNo ¶
func (e *VersionedEntity) GetSeqNo() int
func (*VersionedEntity) GetType ¶
func (e *VersionedEntity) GetType() string
func (*VersionedEntity) SetPrimaryTerm ¶
func (e *VersionedEntity) SetPrimaryTerm(i int)
func (*VersionedEntity) SetSeqNo ¶
func (e *VersionedEntity) SetSeqNo(i int)
func (*VersionedEntity) SetType ¶
func (e *VersionedEntity) SetType(t string)