lazarette

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKeyNotFound = errors.New("key not found in cache")
View Source
var ErrNotNew = errors.New("a newer value was found; not setting")

ErrNotNew is returned when a newer value is found and a value is not set

Functions

func RegisterLazaretteServer

func RegisterLazaretteServer(s *grpc.Server, srv LazaretteServer)

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache .

func New

func New(store store.Store, opts ...Option) (*Cache, error)

New returns a new cache from a store

func (*Cache) Clean

func (c *Cache) Clean() error

Clean cleans the cache

func (*Cache) Close

func (c *Cache) Close() error

Close closes the cache

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, key *Key) (*Value, error)

Get .

func (*Cache) NewSubscription

func (c *Cache) NewSubscription(prefix string) (*Subscription, error)

func (*Cache) Replicate

func (c *Cache) Replicate(ctx context.Context, prefix, addr string) error

TODO should this return a struct that you could stop the replication with?

func (*Cache) Set

func (c *Cache) Set(ctx context.Context, kv *KeyValue) (*empty.Empty, error)

func (*Cache) Subscribe

func (c *Cache) Subscribe(prefix *Key, stream Lazarette_SubscribeServer) error

type Key

type Key struct {
	Key                  string   `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Key) Descriptor

func (*Key) Descriptor() ([]byte, []int)

func (*Key) GetKey

func (m *Key) GetKey() string

func (*Key) ProtoMessage

func (*Key) ProtoMessage()

func (*Key) Reset

func (m *Key) Reset()

func (*Key) String

func (m *Key) String() string

func (*Key) XXX_DiscardUnknown

func (m *Key) XXX_DiscardUnknown()

func (*Key) XXX_Marshal

func (m *Key) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Key) XXX_Merge

func (m *Key) XXX_Merge(src proto.Message)

func (*Key) XXX_Size

func (m *Key) XXX_Size() int

func (*Key) XXX_Unmarshal

func (m *Key) XXX_Unmarshal(b []byte) error

type KeyValue

type KeyValue struct {
	Key                  string               `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Timestamp            *timestamp.Timestamp `protobuf:"bytes,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	Data                 []byte               `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
	XXX_NoUnkeyedLiteral struct{}             `json:"-"`
	XXX_unrecognized     []byte               `json:"-"`
	XXX_sizecache        int32                `json:"-"`
}

func (*KeyValue) Descriptor

func (*KeyValue) Descriptor() ([]byte, []int)

func (*KeyValue) GetData

func (m *KeyValue) GetData() []byte

func (*KeyValue) GetKey

func (m *KeyValue) GetKey() string

func (*KeyValue) GetTimestamp

func (m *KeyValue) GetTimestamp() *timestamp.Timestamp

func (*KeyValue) ProtoMessage

func (*KeyValue) ProtoMessage()

func (*KeyValue) Reset

func (m *KeyValue) Reset()

func (*KeyValue) String

func (m *KeyValue) String() string

func (*KeyValue) XXX_DiscardUnknown

func (m *KeyValue) XXX_DiscardUnknown()

func (*KeyValue) XXX_Marshal

func (m *KeyValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*KeyValue) XXX_Merge

func (m *KeyValue) XXX_Merge(src proto.Message)

func (*KeyValue) XXX_Size

func (m *KeyValue) XXX_Size() int

func (*KeyValue) XXX_Unmarshal

func (m *KeyValue) XXX_Unmarshal(b []byte) error

type LazaretteClient

type LazaretteClient interface {
	Get(ctx context.Context, in *Key, opts ...grpc.CallOption) (*Value, error)
	Set(ctx context.Context, in *KeyValue, opts ...grpc.CallOption) (*empty.Empty, error)
	Subscribe(ctx context.Context, in *Key, opts ...grpc.CallOption) (Lazarette_SubscribeClient, error)
}

LazaretteClient is the client API for Lazarette service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewLazaretteClient

func NewLazaretteClient(cc *grpc.ClientConn) LazaretteClient

type LazaretteServer

type LazaretteServer interface {
	Get(context.Context, *Key) (*Value, error)
	Set(context.Context, *KeyValue) (*empty.Empty, error)
	Subscribe(*Key, Lazarette_SubscribeServer) error
}

LazaretteServer is the server API for Lazarette service.

type Lazarette_SubscribeClient

type Lazarette_SubscribeClient interface {
	Recv() (*KeyValue, error)
	grpc.ClientStream
}

type Lazarette_SubscribeServer

type Lazarette_SubscribeServer interface {
	Send(*KeyValue) error
	grpc.ServerStream
}

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is an option to the cache struct

func WithLogger

func WithLogger(l *zap.Logger) Option

WithLogger adds a logger to the cache

func WithPersistent

func WithPersistent(p store.Store, d time.Duration) Option

WithPersistent adds a persistent store to the cache

type Subscription

type Subscription struct {
	// contains filtered or unexported fields
}

func (*Subscription) Changes

func (s *Subscription) Changes() chan *KeyValue

func (*Subscription) Done

func (s *Subscription) Done() chan struct{}

func (*Subscription) Stop

func (s *Subscription) Stop()

type UnimplementedLazaretteServer

type UnimplementedLazaretteServer struct {
}

UnimplementedLazaretteServer can be embedded to have forward compatible implementations.

func (*UnimplementedLazaretteServer) Get

func (*UnimplementedLazaretteServer) Set

func (*UnimplementedLazaretteServer) Subscribe

type Value

type Value struct {
	Timestamp            *timestamp.Timestamp `protobuf:"bytes,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	Data                 []byte               `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	XXX_NoUnkeyedLiteral struct{}             `json:"-"`
	XXX_unrecognized     []byte               `json:"-"`
	XXX_sizecache        int32                `json:"-"`
}

func (*Value) Descriptor

func (*Value) Descriptor() ([]byte, []int)

func (*Value) GetData

func (m *Value) GetData() []byte

func (*Value) GetTimestamp

func (m *Value) GetTimestamp() *timestamp.Timestamp

func (*Value) ProtoMessage

func (*Value) ProtoMessage()

func (*Value) Reset

func (m *Value) Reset()

func (*Value) String

func (m *Value) String() string

func (*Value) XXX_DiscardUnknown

func (m *Value) XXX_DiscardUnknown()

func (*Value) XXX_Marshal

func (m *Value) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Value) XXX_Merge

func (m *Value) XXX_Merge(src proto.Message)

func (*Value) XXX_Size

func (m *Value) XXX_Size() int

func (*Value) XXX_Unmarshal

func (m *Value) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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