hermes

package
v0.0.0-...-43dea2a Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterPeerPicker

func RegisterPeerPicker(fn func() PeerPicker)

Types

type Cache

type Cache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewCache

func NewCache(config *config.Config) *Cache

func (*Cache) Clear

func (c *Cache) Clear()

Clears the cache's and filter's (if available) items

func (*Cache) Contains

func (c *Cache) Contains(key string) bool

Checks the filter for the key's presence. Only appends the filter's stats.

func (*Cache) Delete

func (c *Cache) Delete(ctx Context, key string) error

Deletes a data given a key

func (*Cache) FilterCount

func (c *Cache) FilterCount() uint64

Counts items in the filter

func (*Cache) Get

func (c *Cache) Get(ctx Context, key string) ([]byte, error)

Returns the data from a given key

func (*Cache) GetFilterStats

func (c *Cache) GetFilterStats() *FilterStats

Returns cache stats

func (*Cache) GetStats

func (c *Cache) GetStats() *Stats

Returns cache stats

func (*Cache) Len

func (c *Cache) Len() int

Returns the number of items

func (*Cache) MaxSize

func (c *Cache) MaxSize() (maxSize int64)

Returns the maximum given size in MB

func (*Cache) Peers

func (c *Cache) Peers(peers PeerPicker) *Cache

Sets function to be used as data loader

func (*Cache) ResetFilter

func (c *Cache) ResetFilter()

Resets filter

func (*Cache) Set

func (c *Cache) Set(ctx Context, key string, data []byte) error

Sets the data with a given key

func (*Cache) Size

func (c *Cache) Size() (size int64)

Returns the size in MB

type Context

type Context interface{}

type CuckooFilter

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

func NewCuckoo

func NewCuckoo(capacity uint) *CuckooFilter

type Entry

type Entry interface {
	GetKey() uint64
	GetValue() []byte
}

General interface for k-v struct used in any policies you wish to implement

type FilterStats

type FilterStats struct {
	Hits   int64 `json:"hits"`
	Misses int64 `json:"misses"`
}

func NewFilterStats

func NewFilterStats() *FilterStats

type Getter

type Getter interface {
	Get(ctx Context, key string) ([]byte, error)
}

type GetterFunc

type GetterFunc func(ctx Context, key string) ([]byte, error)

Function to be used as data loader

func (GetterFunc) Get

func (f GetterFunc) Get(ctx Context, key string) ([]byte, error)

type HTTPPool

type HTTPPool struct {
	Context   func(*http.Request) Context
	Transport func(Context) http.RoundTripper
	// contains filtered or unexported fields
}

func NewHTTPPool

func NewHTTPPool(self string) *HTTPPool

func NewHTTPPoolOpts

func NewHTTPPoolOpts(self string, o *HTTPPoolOptions) *HTTPPool

func (*HTTPPool) DecrementLoad

func (p *HTTPPool) DecrementLoad()

func (*HTTPPool) GetLoad

func (p *HTTPPool) GetLoad() uint64

func (*HTTPPool) IncrementLoad

func (p *HTTPPool) IncrementLoad()

func (*HTTPPool) PickPeer

func (p *HTTPPool) PickPeer(key string) (ProtoGetter, bool)

func (*HTTPPool) ServeHTTP

func (p *HTTPPool) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*HTTPPool) Set

func (p *HTTPPool) Set(peerList ...string)

type HTTPPoolOptions

type HTTPPoolOptions struct {
	BasePath string
	Replicas int
}

type LRFU

type LRFU struct {
	OnEvicted func(key uint64, value []byte)
	// contains filtered or unexported fields
}

This is not thread-safe, which means it will depend on the parent implementation to do the locking mechanism.

func NewLRFU

func NewLRFU(maxEntries int, lambda float64) *LRFU

func (*LRFU) Clear

func (lru *LRFU) Clear()

func (*LRFU) Get

func (lru *LRFU) Get(key uint64) (value []byte, ok bool)

func (*LRFU) Len

func (lru *LRFU) Len() int

func (*LRFU) Remove

func (lru *LRFU) Remove(key uint64) (ok bool)

func (*LRFU) RemoveElement

func (lru *LRFU) RemoveElement()

func (*LRFU) Set

func (lru *LRFU) Set(key uint64, value []byte)

func (*LRFU) SetEvictedFunc

func (lru *LRFU) SetEvictedFunc(f func(key uint64, value []byte))

type NoPeers

type NoPeers struct{}

func (NoPeers) DecrementLoad

func (NoPeers) DecrementLoad()

func (NoPeers) GetLoad

func (NoPeers) GetLoad() (value uint64)

func (NoPeers) IncrementLoad

func (NoPeers) IncrementLoad()

func (NoPeers) PickPeer

func (NoPeers) PickPeer(key string) (peer ProtoGetter, ok bool)

type PeerPicker

type PeerPicker interface {
	PickPeer(key string) (peer ProtoGetter, ok bool)
	IncrementLoad()
	DecrementLoad()
	GetLoad() uint64
}

type Policy

type Policy interface {
	Set(uint64, []byte)
	Get(uint64) ([]byte, bool)
	Len() int
	Remove(uint64) bool
	Clear()
	RemoveElement()
	SetEvictedFunc(func(key uint64, value []byte))
}

All policies implemented (or wish to be implemented) for hermes follows this interface.

type ProtoGetter

type ProtoGetter interface {
	Get(context Context, in *pb.GetRequest, out *pb.GetResponse) error
	Set(context Context, in *pb.SetRequest, out *pb.SetResponse) error
	Delete(context Context, in *pb.DeleteRequest, out *pb.DeleteResponse) error
}

type Response

type Response struct {
	Value string
}

type Shard

type Shard struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type Stats

type Stats struct {
	Hits       int64 `json:"hits"`
	Misses     int64 `json:"misses"`
	DelHits    int64 `json:"delete_hits"`
	DelMisses  int64 `json:"delete_misses"`
	Collisions int64 `json:"collisions"`
}

Pretty basic

func NewStats

func NewStats() *Stats

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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