storage

package
v0.0.0-...-32a2d26 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Add = iota
	Remove
)
View Source
const EventChanSize = 16

Variables

View Source
var ErrAlreadyExist = errors.New("already exist")

Functions

func RunExchanger

func RunExchanger(storage *Storage, listenAddr string, addrs []string, periodMs int)

Types

type Event

type Event struct {
	Type int
	Key  ObjectKey
	Data string
}

type ObjectKey

type ObjectKey struct {
	Area, Node, Key string
	// contains filtered or unexported fields
}

func ReadKey

func ReadKey(fullKey string) (k ObjectKey, err error)

func (ObjectKey) FullKey

func (k ObjectKey) FullKey() string

type Request

type Request struct {
	INeedFullKey string `json:"n"`
}

func (Request) Decode

func (Request) Decode(buf []byte) (r Request, err error)

func (Request) Encode

func (r Request) Encode() []byte

type Responce

type Responce struct {
	IHaveFullKeys []string `json:"h"`
	YourKeyVal    string   `json:"v"`
}

func (Responce) Decode

func (Responce) Decode(buf []byte) (r Responce, err error)

func (Responce) Encode

func (r Responce) Encode() []byte

type Storage

type Storage struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(nodeName string, diskOpts diskv.Options, refreshFilesPeriod int) *Storage

func (*Storage) Add

func (s *Storage) Add(area, key string, val string) error

func (*Storage) NextID

func (s *Storage) NextID() int

func (*Storage) Remove

func (s *Storage) Remove(objectKey ObjectKey) error

func (*Storage) SubscribeAndData

func (s *Storage) SubscribeAndData(area string) (data map[ObjectKey]string, subscribe chan Event)

func (*Storage) Unsubscribe

func (s *Storage) Unsubscribe(subscribe chan Event)

Jump to

Keyboard shortcuts

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