go_sheep

package module
v0.0.0-...-30cbb4e Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2017 License: MIT Imports: 8 Imported by: 0

README

go-sheep

WIP SWIM implementation in Go

Documentation

Overview

Package go_sheep is a generated protocol buffer package.

It is generated from these files:

state.proto

It has these top-level messages:

DelegateCheckRequest
States
Target
Node
State

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LaunchStateHandler

func LaunchStateHandler(n *Node, failureDetector SWIM, logger zap.Logger) (chan<- Request, chan<- struct{})

func NewCheckError

func NewCheckError(s, t *Node, err error) error

func RegisterSWIMServer

func RegisterSWIMServer(s *grpc.Server, srv SWIMServer)

Types

type CheckError

type CheckError struct {
	Source *Node
	Target *Node
	Err    error
}

func (*CheckError) Error

func (c *CheckError) Error() string

type DelegateCheckRequest

type DelegateCheckRequest struct {
	State  *State `protobuf:"bytes,1,opt,name=state" json:"state,omitempty"`
	Target *Node  `protobuf:"bytes,2,opt,name=target" json:"target,omitempty"`
}

func (*DelegateCheckRequest) Descriptor

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

func (*DelegateCheckRequest) GetState

func (m *DelegateCheckRequest) GetState() *State

func (*DelegateCheckRequest) GetTarget

func (m *DelegateCheckRequest) GetTarget() *Node

func (*DelegateCheckRequest) ProtoMessage

func (*DelegateCheckRequest) ProtoMessage()

func (*DelegateCheckRequest) Reset

func (m *DelegateCheckRequest) Reset()

func (*DelegateCheckRequest) String

func (m *DelegateCheckRequest) String() string

type Errors

type Errors []error

func NewErrors

func NewErrors(n int) *Errors

func (Errors) Error

func (e Errors) Error() (err string)

type NetworkError

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

type Node

type Node struct {
	Uuid     string                     `protobuf:"bytes,1,opt,name=uuid" json:"uuid,omitempty"`
	Address  string                     `protobuf:"bytes,2,opt,name=address" json:"address,omitempty"`
	LastSeen *google_protobuf.Timestamp `protobuf:"bytes,3,opt,name=lastSeen" json:"lastSeen,omitempty"`
}

Node contains membership information of a particular host

func (*Node) Descriptor

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

func (*Node) GetAddress

func (m *Node) GetAddress() string

func (*Node) GetLastSeen

func (m *Node) GetLastSeen() *google_protobuf.Timestamp

func (*Node) GetUuid

func (m *Node) GetUuid() string

func (*Node) ProtoMessage

func (*Node) ProtoMessage()

func (*Node) Reset

func (m *Node) Reset()

func (*Node) String

func (m *Node) String() string

type Request

type Request struct {
	Action     StateAction
	ResponseCh chan *Response
	Payload    interface{}
}

type Response

type Response struct {
	State *State
	Err   error
}

type SWIM

type SWIM interface {

	// RandomizedTarget returns a Node to ping that is not equal to 'currentNodeInfo'
	// or error if no valid address is found.
	GetRandomizedTarget(s *State, currentNodeInfo *Node) (*Node, error)

	// Checkers returns 'n' addresses:ports to check the existence of 't', which is also an address:port.
	GetCheckers(s *State, t, cur *Node, n int) ([]*Node, error)

	// Merge state takes a state A and merges it with a state B returning the merged result
	MergeState(a, b *State) (*State, error)
}

type SWIMClient

type SWIMClient interface {
	// Ping sends State to a previously randomized address to retrieve its state already merge with ours.
	Ping(ctx context.Context, in *State, opts ...grpc.CallOption) (*State, error)
	// DelegateCheck sends State to a delegated node so it can check agains Target node. Returns:
	// - The state of the target AND the delegated node (the node we are connecting to)
	// - The state of the delegated node and an error if it couldn't get state from Target
	// - An error only if something happened
	DelegateCheck(ctx context.Context, in *DelegateCheckRequest, opts ...grpc.CallOption) (*State, error)
	Join(ctx context.Context, in *Node, opts ...grpc.CallOption) (*State, error)
}

func NewSWIMClient

func NewSWIMClient(cc *grpc.ClientConn) SWIMClient

type SWIMServer

type SWIMServer interface {
	// Ping sends State to a previously randomized address to retrieve its state already merge with ours.
	Ping(context.Context, *State) (*State, error)
	// DelegateCheck sends State to a delegated node so it can check agains Target node. Returns:
	// - The state of the target AND the delegated node (the node we are connecting to)
	// - The state of the delegated node and an error if it couldn't get state from Target
	// - An error only if something happened
	DelegateCheck(context.Context, *DelegateCheckRequest) (*State, error)
	Join(context.Context, *Node) (*State, error)
}

type SafeState

type SafeState struct {
	*State
	sync.RWMutex
}
var CurrentState *SafeState

type State

type State struct {
	Nodes []*Node `protobuf:"bytes,4,rep,name=Nodes,json=nodes" json:"Nodes,omitempty"`
}

State represents an array of Node with their current membership info. Each host must have an stored state.

func (*State) Descriptor

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

func (*State) GetNodes

func (m *State) GetNodes() []*Node

func (*State) ProtoMessage

func (*State) ProtoMessage()

func (*State) Reset

func (m *State) Reset()

func (*State) String

func (m *State) String() string

type StateAction

type StateAction byte
const (
	MERGE StateAction = iota
)

type States

type States struct {
	States []*State `protobuf:"bytes,1,rep,name=States,json=states" json:"States,omitempty"`
}

States is an array of State objects

func (*States) Descriptor

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

func (*States) GetStates

func (m *States) GetStates() []*State

func (*States) ProtoMessage

func (*States) ProtoMessage()

func (*States) Reset

func (m *States) Reset()

func (*States) String

func (m *States) String() string

type Target

type Target struct {
	Address string `protobuf:"bytes,1,opt,name=address" json:"address,omitempty"`
}

Target is a Node that will be pinged by delegated Nodes

func (*Target) Descriptor

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

func (*Target) GetAddress

func (m *Target) GetAddress() string

func (*Target) ProtoMessage

func (*Target) ProtoMessage()

func (*Target) Reset

func (m *Target) Reset()

func (*Target) String

func (m *Target) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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