conn

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2018 License: AGPL-3.0, Apache-2.0 Imports: 17 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 *intern.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 BadgerDB).
	Applied x.WaterMark
	// contains filtered or unexported fields
}

func NewNode added in v0.8.3

func NewNode(rc *intern.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) DeletePeer added in v0.9.2

func (n *Node) DeletePeer(pid uint64)

func (*Node) DoneConfChange added in v0.9.3

func (n *Node) DoneConfChange(id uint64, err error)

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) ProposePeerRemoval added in v0.9.2

func (n *Node) ProposePeerRemoval(ctx context.Context, id uint64) error

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) SaveSnapshot added in v1.0.2

func (n *Node) SaveSnapshot(s raftpb.Snapshot)

func (*Node) SaveToStorage added in v0.8.3

func (n *Node) SaveToStorage(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 *api.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.

func (*Pool) UpdateHealthStatus added in v0.9.3

func (p *Pool) UpdateHealthStatus()

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)

func (*Pools) Remove added in v0.9.2

func (p *Pools) Remove(addr string)

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 *api.Payload) (*api.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 *intern.RaftContext) (*api.Payload, error)

func (*RaftServer) RaftMessage added in v0.8.3

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

Jump to

Keyboard shortcuts

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