store

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2015 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package store provides platform-independent interfaces to persist and retrieve data.

Its primary job is to wrap existing implementations of such primitives, such as those in package redis, into shared public interfaces that abstract functionality, plus some other related primitives.

Because these interfaces and primitives wrap lower-level operations with various implementations, unless otherwise informed clients should not assume they are safe for parallel execution.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyKey = errors.New("store: key is empty")

ErrEmptyKey means that the key for the object provided is empty

View Source
var ErrKeyNotFound = errors.New("store: key not found")

ErrKeyNotFound means that the object associated with the key is not found in the datastore

Functions

This section is empty.

Types

type Deleter

type Deleter interface {
	Delete(i Item) error
}

Deleter is the interface that wraps the basic Delete method.

Delete deletes i from the underlying datastore. It returns any error encountered that prevented the deletion from occurring.

type Item

type Item interface {
	Key() string
	SetKey(string)
}

Item is the interface that wraps Key and SetKey methods.

Key returns a unique idenfier for the item from the implementation. It is called by the implementing store when retrieving objects from its underlying store.

SetKey sets the item key. It is called by the store when Unmarshalling objects from its underlying store.

The below example illustrates usage:

type Hacker struct {
	Id        string
	Name      string
	Birthyear int
}

func (h *Hacker) Key() string {
	return h.Id
}

func (h *Hacker) SetKey(k string) {
	h.Id = k
}

type Lister

type Lister interface {
	List(interface{}) error
}

Lister is the interface that wraps the basic List method.

type MultiDeleter

type MultiDeleter interface {
	DeleteMultiple(items []Item) (int, error)
}

MultiDeleter is the interface that wraps DeleteMultiple method.

type MultiReadWriter

type MultiReadWriter interface {
	MultiReader
	MultiWriter
	MultiDeleter
}

MultiReadWriter is the interface that groups MultiReader and MultiWriter interfaces.

type MultiReader

type MultiReader interface {
	ReadMultiple(interface{}) error
}

MultiReader is the interface that wraps ReadMultiple method.

type MultiWriter

type MultiWriter interface {
	WriteMultiple(items []Item) error
}

MultiWriter is the interface that wraps WriteMultiple method.

type ReadWriter

type ReadWriter interface {
	Reader
	Writer
	Deleter
}

ReadWriter is the interface that groups Reader, Writer and Deleter interfaces.

type Reader

type Reader interface {
	Read(i Item) error
}

Reader is the interface that wraps the basic Read method.

Read reads i from the underlying data store and copies to i. It returns any error encountered that caused the write to stop early.

type Store

type Store interface {
	ReadWriter
	Lister
	MultiReadWriter
}

Store is the interface to store implemented in package redis. It groups ReadWriter, Lister and MultiReader interfaces.

type Writer

type Writer interface {
	Write(i Item) error
}

Writer is the interface that wraps the basic Write method.

Write writes i to the underlying data store. It expects i.Key method to return a unique identifier for the item, it will otherwise generate a unique identifier and calls i.SetKey method. It returns any error encountered that caused the write to stop early.

Jump to

Keyboard shortcuts

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