Documentation
¶
Overview ¶
Package topic provides all functionality within arrebato regarding topics. This includes both gRPC, raft and data store interactions.
Index ¶
- Variables
- type BoltStore
- type Executor
- type GRPC
- func (svr *GRPC) Create(ctx context.Context, request *topicsvc.CreateRequest) (*topicsvc.CreateResponse, error)
- func (svr *GRPC) Delete(ctx context.Context, request *topicsvc.DeleteRequest) (*topicsvc.DeleteResponse, error)
- func (svr *GRPC) Get(ctx context.Context, request *topicsvc.GetRequest) (*topicsvc.GetResponse, error)
- func (svr *GRPC) List(ctx context.Context, _ *topicsvc.ListRequest) (*topicsvc.ListResponse, error)
- func (svr *GRPC) Register(registrar grpc.ServiceRegistrar, health *health.Server)
- type Handler
- type Manager
- type NodeLister
- type Querier
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTopicExists is the error given when attempting to create a new topic with the same name as an existing // topic. ErrTopicExists = errors.New("topic exists") // ErrNoTopic is the error given when attempting to delete/query a topic that does not exist. ErrNoTopic = errors.New("no topic") // ErrNoTopicInfo is the error given when querying a topic that has incomplete/invalid data within the state. ErrNoTopicInfo = errors.New("no topic info") )
Functions ¶
This section is empty.
Types ¶
type BoltStore ¶
type BoltStore struct {
// contains filtered or unexported fields
}
The BoltStore type is responsible for querying/mutating topic data within a boltdb database.
func NewBoltStore ¶
NewBoltStore returns a new instance of the BoltStore type that will manage/query topic data in a boltdb database.
func (*BoltStore) Create ¶
Create a new topic. Returns ErrTopicExists if a topic with the same name already exists.
type Executor ¶
type Executor interface { // Execute should perform actions corresponding to the provided command. The returned error should correspond // to the issue relevant to the command. For example, a command that creates a new Topic should return // ErrTopicExists if the topic already exists. Execute(ctx context.Context, cmd command.Command) error }
The Executor interface describes types that execute commands related to Topic data.
type GRPC ¶
type GRPC struct {
// contains filtered or unexported fields
}
The GRPC type is a topicsvc.TopicServiceServer implementation that handles inbound gRPC requests to manage and query Topics.
func NewGRPC ¶
func NewGRPC(executor Executor, querier Querier, nodes NodeLister) *GRPC
NewGRPC returns a new instance of the GRPC type that will modify Topic data via commands sent to the Executor and query Topic data via the Querier implementation. Node data for topic assignment will be obtained via the NodeLister implementation.
func (*GRPC) Create ¶
func (svr *GRPC) Create(ctx context.Context, request *topicsvc.CreateRequest) (*topicsvc.CreateResponse, error)
Create a new Topic, assigning it to the node with the least number of assigned topics. Returns a codes.AlreadyExists code if the topic already exists.
func (*GRPC) Delete ¶
func (svr *GRPC) Delete(ctx context.Context, request *topicsvc.DeleteRequest) (*topicsvc.DeleteResponse, error)
Delete an existing Topic. Returns a codes.NotFound code if the topic does not exist.
func (*GRPC) Get ¶
func (svr *GRPC) Get(ctx context.Context, request *topicsvc.GetRequest) (*topicsvc.GetResponse, error)
Get a topic by name. Returns a codes.NotFound code if the topic does not exist, or a codes.InvalidArgument code if a topic record is found with incomplete data.
func (*GRPC) List ¶
func (svr *GRPC) List(ctx context.Context, _ *topicsvc.ListRequest) (*topicsvc.ListResponse, error)
List all topics known to the node. Returns a codes.FailedPrecondition code if a topic record is found with incomplete data.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
The Handler type is responsible for handling Topic related commands passed to an Executor implementation and modifying the state of topic data appropriately.
func NewHandler ¶
NewHandler returns a new instance of the Handler type that will modify topic data via the provided Manager implementation.
type Manager ¶
type Manager interface { Create(ctx context.Context, t *topic.Topic) error Delete(ctx context.Context, t string) error }
The Manager interface describes types responsible for managing the state of Topics within a data store.
type NodeLister ¶
type NodeLister interface { // List should return all node records in the state. List(ctx context.Context) ([]*nodepb.Node, error) }
The NodeLister interface describes types that can list nodes within the cluster.
type Querier ¶
type Querier interface { // Get should return the Topic corresponding to the given name. It should return ErrNoTopic if the // named topic does not exist. It should return ErrNoTopicInfo if incomplete topic data is found. Get(ctx context.Context, name string) (*topic.Topic, error) // List should return a slice of all Topics the node has knowledge of. It should return ErrNoTopicInfo if // incomplete topic data is found. List(ctx context.Context) ([]*topic.Topic, error) }
The Querier interface describes types that can query Topic data from a data store.