Documentation ¶
Overview ¶
Package node provides all functionality within arrebato regarding nodes. This includes the gRPC service implementation.
Index ¶
- Variables
- type BoltStore
- func (bs *BoltStore) AssignTopic(ctx context.Context, nodeName string, topicName string) error
- func (bs *BoltStore) Create(ctx context.Context, n *node.Node) error
- func (bs *BoltStore) Delete(ctx context.Context, name string) error
- func (bs *BoltStore) GetTopicOwner(ctx context.Context, topicName string) (*node.Node, error)
- func (bs *BoltStore) List(ctx context.Context) ([]*node.Node, error)
- type GRPC
- func (svr *GRPC) Backup(_ *nodesvc.BackupRequest, stream nodesvc.NodeService_BackupServer) error
- func (svr *GRPC) Describe(ctx context.Context, _ *nodesvc.DescribeRequest) (*nodesvc.DescribeResponse, error)
- func (svr *GRPC) Register(registrar grpc.ServiceRegistrar, health *health.Server)
- func (svr *GRPC) Watch(_ *nodesvc.WatchRequest, server nodesvc.NodeService_WatchServer) error
- type Handler
- type Info
- type Lister
- type Raft
- type Store
Constants ¶
This section is empty.
Variables ¶
var ErrNoNode = errors.New("no node")
ErrNoNode is the error given when querying a node that does not exist, or when querying a topic's owner and none is found.
var ErrNodeExists = errors.New("node exists")
ErrNodeExists is the error given when attempting to create a node that already exists in the store.
Functions ¶
This section is empty.
Types ¶
type BoltStore ¶
type BoltStore struct {
// contains filtered or unexported fields
}
The BoltStore type is responsible for managing node state within a boltdb database.
func NewBoltStore ¶
NewBoltStore returns a new instance of the BoltStore type that will store node state within the bbolt.DB instance.
func (*BoltStore) AssignTopic ¶
AssignTopic adds the provided topic name to a node's list of topics. It also checks other node records and removes the topic from their list if present.
func (*BoltStore) Create ¶
Create a record for the node. Returns ErrNodeExists if a record already exists for the given node.
func (*BoltStore) Delete ¶
Delete the record of a named node. If the node does not exist, nothing happens and a nil error is returned.
func (*BoltStore) GetTopicOwner ¶
GetTopicOwner returns the node that is assigned to the provided topic. Returns ErrNoNode if a node cannot be found that owns the topic.
type GRPC ¶
type GRPC struct {
// contains filtered or unexported fields
}
The GRPC type is a nodesvc.NodeServiceServer implementation that handles inbound gRPC requests to get information on the node.
func NewGRPC ¶
NewGRPC returns a new instance of the GRPC type that returns node information based on the Raft state.
func (*GRPC) Backup ¶
func (svr *GRPC) Backup(_ *nodesvc.BackupRequest, stream nodesvc.NodeService_BackupServer) error
Backup the server state, writing it to the outbound stream.
func (*GRPC) Describe ¶
func (svr *GRPC) Describe(ctx context.Context, _ *nodesvc.DescribeRequest) (*nodesvc.DescribeResponse, error)
Describe the node.
func (*GRPC) Register ¶
func (svr *GRPC) Register(registrar grpc.ServiceRegistrar, health *health.Server)
Register the GRPC service onto the grpc.ServiceRegistrar.
func (*GRPC) Watch ¶
func (svr *GRPC) Watch(_ *nodesvc.WatchRequest, server nodesvc.NodeService_WatchServer) error
Watch the node state, writing data to the server stream when the leadership or known peers changes.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
The Handler type is responsible for handling raft commands regarding nodes and maintaining the node state.
func NewHandler ¶
NewHandler returns a new instance of the Handler type that will maintain node state via the Store implementation.
func (*Handler) AssignTopic ¶
AssignTopic assigns a topic to a desired node.
type Lister ¶
type Lister interface { // List should return all nodes within the cluster, including the current one. List(ctx context.Context) ([]*node.Node, error) }
The Lister interface describes types that can list nodes within the state.