kv

package
v0.0.0-...-284234c Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

README

KV - key value interface

Provides a high level abstraction for key-value stores.

Interface

type KV interface {
	Get(key string) (*Item, error)
	Del(key string) error
	Put(item *Item) error
}

type Item struct {
	Key        string
	Value      []byte
	Expiration time.Duration
}

Supported KV Stores

  • Platform
  • Memcached
  • Redis

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GossipTopic = "go.micro.kv.announce"
	GossipEvent = time.Second * 5
	ReaperEvent = time.Second * 30
)
View Source
var (
	ErrNotFound = errors.New("not found")
)

Functions

func NewContext

func NewContext(ctx context.Context, c KV) context.Context

Types

type Announcement

type Announcement struct {
	// Which namespace does it belong to
	Namespace string
	Address   string
	Timestamp int64
}

func (*Announcement) ContentType

func (a *Announcement) ContentType() string

func (*Announcement) Message

func (a *Announcement) Message() interface{}

func (*Announcement) Topic

func (a *Announcement) Topic() string

type Item

type Item struct {
	Key        string
	Value      []byte
	Expiration time.Duration
}

type KV

type KV interface {
	Get(key string) (*Item, error)
	Del(key string) error
	Put(item *Item) error

	// Runtime. Could be used for internal reaping
	// of expired keys or publishing info, gossip,
	// etc
	Start() error
	Stop() error
	// Name
	String() string
}

func FromContext

func FromContext(ctx context.Context) (KV, bool)

func NewKV

func NewKV(opts ...Option) KV

type Option

type Option func(o *Options)

func Servers

func Servers(s []string) Option

type Options

type Options struct {
	// Servers that store values for access
	Servers []string
	// Limit the scope of queries to a namespace
	// In the case of platform it essentially
	// means the topic we pub to for "gossip"
	// For memcache and redis it could be key/prefix
	Namespace string
	// Number of replicas
	// Default is 1 ofcourse
	Replicas int

	// Replace with go-micro.Service?
	Client client.Client
	Server server.Server

	// Alternative options set using Context
	Context context.Context
}

Directories

Path Synopsis
Package go_micro_platform_kv is a generated protocol buffer package.
Package go_micro_platform_kv is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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