go-platform: github.com/micro/go-platform/kv Index | Files | Directories

package kv

import "github.com/micro/go-platform/kv"

Package kv is an interface for key-value storage.


Package Files

context.go handler.go kv.go options.go os.go util.go


var (
    GossipTopic = "go.micro.kv.announce"
    GossipEvent = time.Second * 1
    ReaperEvent = time.Second * 10
var (
    ErrNotFound = errors.New("not found")

func NewContext Uses

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

type Announcement Uses

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

func (*Announcement) ContentType Uses

func (a *Announcement) ContentType() string

func (*Announcement) Message Uses

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

func (*Announcement) Topic Uses

func (a *Announcement) Topic() string

type Item Uses

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

type KV Uses

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

func FromContext Uses

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

func NewKV Uses

func NewKV(opts ...Option) KV

type Option Uses

type Option func(o *Options)

func Client Uses

func Client(c client.Client) Option

func Internal Uses

func Internal(b bool) Option

Internal specifies whether to use advertise handlers to discovery

func Namespace Uses

func Namespace(ns string) Option

func Server Uses

func Server(s server.Server) Option

func Servers Uses

func Servers(s ...string) Option

func Service Uses

func Service(b bool) Option

Service specifies whether to use the KV service. Defaults to false.

type Options Uses

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

    // Use a service rather than gossip
    Service bool
    // Whether handlers should be internal
    Internal bool

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

    // Alternative options set using Context
    Context context.Context


protoPackage go_micro_os_kv is a generated protocol buffer package.

Package kv imports 14 packages (graph) and is imported by 6 packages. Updated 2020-11-06. Refresh now. Tools for package owners.