conn

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2017 License: AGPL-3.0, Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoConnection        = fmt.Errorf("No connection exists")
	ErrUnhealthyConnection = fmt.Errorf("Unhealthy connection")
)
View Source
var (
	ErrDuplicateRaftId = x.Errorf("Node is already part of group")
)

Functions

This section is empty.

Types

type Node added in v0.8.3

type Node struct {
	x.SafeMutex

	// Fields which are never changed after init.
	Cfg    *raft.Config
	MyAddr string
	Id     uint64

	RaftContext *protos.RaftContext
	Store       *raft.MemoryStorage
	Wal         *raftwal.Wal

	// applied is used to keep track of the applied RAFT proposals.
	// The stages are proposed -> committed (accepted by cluster) ->
	// applied (to PL) -> synced (to RocksDB).
	Applied x.WaterMark
	// contains filtered or unexported fields
}

func NewNode added in v0.8.3

func NewNode(rc *protos.RaftContext) *Node

func (*Node) AddToCluster added in v0.8.3

func (n *Node) AddToCluster(ctx context.Context, pid uint64) error

func (*Node) BatchAndSendMessages added in v0.8.3

func (n *Node) BatchAndSendMessages()

func (*Node) ConfState added in v0.8.3

func (n *Node) ConfState() *raftpb.ConfState

ConfState would return the latest ConfState stored in node.

func (*Node) Connect added in v0.8.3

func (n *Node) Connect(pid uint64, addr string)

Connects the node and makes its peerPool refer to the constructed pool and address (possibly updating ourselves from the old address.) (Unless pid is ourselves, in which case this does nothing.)

func (*Node) InitFromWal added in v0.8.3

func (n *Node) InitFromWal(wal *raftwal.Wal) (idx uint64, restart bool, rerr error)

func (*Node) Peer added in v0.8.3

func (n *Node) Peer(pid uint64) (string, bool)

func (*Node) Raft added in v0.8.3

func (n *Node) Raft() raft.Node

Raft would return back the raft.Node stored in the node.

func (*Node) SaveToStorage added in v0.8.3

func (n *Node) SaveToStorage(s raftpb.Snapshot, h raftpb.HardState,
	es []raftpb.Entry)

func (*Node) Send added in v0.8.3

func (n *Node) Send(m raftpb.Message)

func (*Node) SetConfState added in v0.8.3

func (n *Node) SetConfState(cs *raftpb.ConfState)

SetConfState would store the latest ConfState generated by ApplyConfChange.

func (*Node) SetPeer added in v0.8.3

func (n *Node) SetPeer(pid uint64, addr string)

addr must not be empty.

func (*Node) SetRaft added in v0.8.3

func (n *Node) SetRaft(r raft.Node)

SetRaft would set the provided raft.Node to this node. It would check fail if the node is already set.

func (*Node) WaitForMinProposal added in v0.9.0

func (n *Node) WaitForMinProposal(ctx context.Context, read *protos.LinRead) error

type Pool

type Pool struct {
	sync.RWMutex

	Addr string
	// contains filtered or unexported fields
}

"Pool" is used to manage the grpc client connection(s) for communicating with other worker instances. Right now it just holds one of them.

func NewPool

func NewPool(addr string) (*Pool, error)

NewPool creates a new "pool" with one gRPC connection, refcount 0.

func (*Pool) Get

func (p *Pool) Get() *grpc.ClientConn

Get returns the connection to use from the pool of connections.

func (*Pool) IsHealthy added in v0.8.3

func (p *Pool) IsHealthy() bool

func (*Pool) MonitorHealth added in v0.8.3

func (p *Pool) MonitorHealth()

MonitorHealth monitors the health of the connection via Echo. This function blocks forever.

type Pools

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

func Get

func Get() *Pools

func (*Pools) Connect

func (p *Pools) Connect(addr string) *Pool

func (*Pools) Get

func (p *Pools) Get(addr string) (*Pool, error)

type RaftServer added in v0.8.3

type RaftServer struct {
	Node *Node
	// contains filtered or unexported fields
}

func (*RaftServer) Echo added in v0.8.3

func (w *RaftServer) Echo(ctx context.Context, in *protos.Payload) (*protos.Payload, error)

Hello rpc call is used to check connection with other workers after worker tcp server for this instance starts.

func (*RaftServer) GetNode added in v0.8.3

func (w *RaftServer) GetNode() *Node

func (*RaftServer) JoinCluster added in v0.8.3

func (w *RaftServer) JoinCluster(ctx context.Context,
	rc *protos.RaftContext) (*protos.Payload, error)

func (*RaftServer) RaftMessage added in v0.8.3

func (w *RaftServer) RaftMessage(ctx context.Context,
	query *protos.Payload) (*protos.Payload, error)

Jump to

Keyboard shortcuts

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