kingsmoot

package
v0.0.0-...-50302ad Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Trace   *log.Logger
	Info    *log.Logger
	Warning *log.Logger
	Fatal   *log.Logger
)

Functions

func Init

func Init(traceHandle io.Writer, infoHandle io.Writer, warningHandle io.Writer, errorHandle io.Writer)

func NewEtcdV2Client

func NewEtcdV2Client(conf *Config) (client.Client, client.KeysAPI, error)

func NewV2Config

func NewV2Config(conf *Config) (c *client.Config, err error)

func Register

func Register(name string, factory DataStoreFactory)

Types

type Candidate

type Candidate interface {
	fmt.Stringer
	UpdateMembership(memberShip MemberShip) error
}

type Change

type Change struct {
	ChangeType ChangeType
	NewValue   string
	PrevValue  string
}

func (*Change) String

func (c *Change) String() string

type ChangeType

type ChangeType int
const (
	Created ChangeType = 1 + iota
	Updated
	Deleted
)

func (ChangeType) String

func (ct ChangeType) String() string

type Config

type Config struct {
	Name            string
	DataStoreType   string
	Addresses       []string
	DsOpTimeout     time.Duration
	MasterDownAfter time.Duration
	CustomConf      map[string]string
}

type DataStore

type DataStore interface {
	PutIfAbsent(key string, value string, ttl time.Duration) (prevValue string, err error)
	RefreshTTL(key string, value string, ttl time.Duration) (err error)
	Get(key string) (value string, err error)
	Del(key string) error
	CompareAndDel(key string, prevValue string) error
	Watch(key string, watch Listener) error
	Close() error
}

func CreateDatastore

func CreateDatastore(conf *Config) (DataStore, error)

func NewEtcdV2DataStore

func NewEtcdV2DataStore(conf *Config) (DataStore, error)

type DataStoreFactory

type DataStoreFactory func(conf *Config) (DataStore, error)

type Error

type Error interface {
	error
	Code() ErrorCode
	Message() string
	Cause() error
}

type ErrorCode

type ErrorCode int
const (
	InvalidArgument ErrorCode = 1 + iota
	KeyNotFound
	KeyExists
	CompareFailed
	DataStoreError
	Timeout
)

func (ErrorCode) String

func (e ErrorCode) String() string

type EtcdV2DataStore

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

func (*EtcdV2DataStore) Close

func (ev2DS *EtcdV2DataStore) Close() error

func (*EtcdV2DataStore) CompareAndDel

func (ev2DS *EtcdV2DataStore) CompareAndDel(key string, value string) error

func (*EtcdV2DataStore) Del

func (ev2DS *EtcdV2DataStore) Del(key string) error

func (*EtcdV2DataStore) Get

func (ev2DS *EtcdV2DataStore) Get(key string) (string, error)

func (*EtcdV2DataStore) PutIfAbsent

func (ev2DS *EtcdV2DataStore) PutIfAbsent(key string, value string, ttl time.Duration) (prevValue string, err error)

func (*EtcdV2DataStore) RefreshTTL

func (ev2DS *EtcdV2DataStore) RefreshTTL(key string, value string, ttl time.Duration) error

func (*EtcdV2DataStore) Watch

func (ev2DS *EtcdV2DataStore) Watch(k string, l Listener) error

type InvalidArgumentError

type InvalidArgumentError struct {
	Name     string
	Value    string
	Expected string
	// contains filtered or unexported fields
}

func (*InvalidArgumentError) Cause

func (iae *InvalidArgumentError) Cause() error

func (*InvalidArgumentError) Code

func (iae *InvalidArgumentError) Code() ErrorCode

func (*InvalidArgumentError) Error

func (iae *InvalidArgumentError) Error() string

func (*InvalidArgumentError) Message

func (iae *InvalidArgumentError) Message() string

type KeyChangeListener

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

func (*KeyChangeListener) Bye

func (l *KeyChangeListener) Bye(err error)

func (*KeyChangeListener) Notify

func (l *KeyChangeListener) Notify(change *Change)

type Kingsmoot

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

func New

func New(name string, addresses []string) (*Kingsmoot, error)

func NewFromConf

func NewFromConf(conf *Config) (*Kingsmoot, error)

func (*Kingsmoot) Exit

func (km *Kingsmoot) Exit()

func (*Kingsmoot) Join

func (km *Kingsmoot) Join(endpoint string, c Candidate) error

func (*Kingsmoot) Leader

func (km *Kingsmoot) Leader() (string, error)

type Listener

type Listener interface {
	Notify(change *Change)
	Bye(err error)
}

type MemberShip

type MemberShip struct {
	Role   Role
	Leader string
}

type OpError

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

func (*OpError) Cause

func (ce *OpError) Cause() error

func (*OpError) Code

func (ce *OpError) Code() ErrorCode

func (*OpError) Error

func (ce *OpError) Error() string

func (*OpError) Message

func (ce *OpError) Message() string

type Role

type Role int8
const (
	NotAMember Role = iota
	Follower
	Leader
	Dead
)

func (Role) String

func (s Role) String() string

Jump to

Keyboard shortcuts

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