cluster

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2017 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Datastore

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

Datastore holds a struct synced in a KV store

func NewDataStore

func NewDataStore(ctx context.Context, kvSource staert.KvSource, object Object, listener Listener) (*Datastore, error)

NewDataStore creates a Datastore

func (*Datastore) Begin

func (d *Datastore) Begin() (Transaction, Object, error)

Begin creates a transaction with the KV store.

func (*Datastore) Get

func (d *Datastore) Get() Object

Get atomically a struct from the KV store

func (*Datastore) Load

func (d *Datastore) Load() (Object, error)

Load load atomically a struct from the KV store

type LeaderListener

type LeaderListener func(elected bool) error

LeaderListener is called when leadership has changed

type Leadership

type Leadership struct {
	*safe.Pool
	*types.Cluster
	// contains filtered or unexported fields
}

Leadership allows leadership election using a KV store

func NewLeadership

func NewLeadership(ctx context.Context, cluster *types.Cluster) *Leadership

NewLeadership creates a leadership

func (*Leadership) AddListener

func (l *Leadership) AddListener(listener LeaderListener)

AddListener adds a leadership listerner

func (*Leadership) IsLeader

func (l *Leadership) IsLeader() bool

IsLeader returns true if current node is leader

func (*Leadership) Participate

func (l *Leadership) Participate(pool *safe.Pool)

Participate tries to be a leader

func (*Leadership) Resign

func (l *Leadership) Resign()

Resign resigns from being a leader

type Listener

type Listener func(Object) error

Listener is called when Object has been changed in KV store

type Metadata

type Metadata struct {
	Object []byte
	Lock   string
	// contains filtered or unexported fields
}

Metadata stores Object plus metadata

func NewMetadata

func NewMetadata(object Object) *Metadata

NewMetadata returns new Metadata

func (*Metadata) Marshall

func (m *Metadata) Marshall() error

Marshall marshalls object

type Object

type Object interface{}

Object is the struct to store

type Store

type Store interface {
	Load() (Object, error)
	Get() Object
	Begin() (Transaction, Object, error)
}

Store is a generic interface to represents a storage

type Transaction

type Transaction interface {
	Commit(object Object) error
}

Transaction allows to set a struct in the KV store

Jump to

Keyboard shortcuts

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