topic

package
v0.1.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package topic provides all functionality within arrebato regarding topics. This includes both gRPC, raft and data store interactions.

Index

Constants

This section is empty.

Variables

View Source
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

func NewBoltStore(db *bbolt.DB) *BoltStore

NewBoltStore returns a new instance of the BoltStore type that will manage/query topic data in a boltdb database.

func (*BoltStore) Create

func (bs *BoltStore) Create(_ context.Context, t *topic.Topic) error

Create a new topic. Returns ErrTopicExists if a topic with the same name already exists.

func (*BoltStore) Delete

func (bs *BoltStore) Delete(_ context.Context, t string) error

Delete a named topic, returns ERrNoTopic if the topic does not exist.

func (*BoltStore) Get

func (bs *BoltStore) Get(ctx context.Context, name string) (*topic.Topic, error)

Get information about a Topic by name. Returns ErrNoTopic if the topic does not exist.

func (*BoltStore) List

func (bs *BoltStore) List(ctx context.Context) ([]*topic.Topic, error)

List all known topics. Returns ErrNoTopic if the store should contain information for a topic but doesn't.

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) *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.

func (*GRPC) Create

func (svr *GRPC) Create(ctx context.Context, request *topicsvc.CreateRequest) (*topicsvc.CreateResponse, error)

Create a new Topic. 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

List all topics known to the node. Returns a codes.FailedPrecondition code if a topic record is found with incomplete data.

func (*GRPC) Register

func (svr *GRPC) Register(registrar grpc.ServiceRegistrar, health *health.Server)

Register the GRPC service onto the grpc.ServiceRegistrar.

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

func NewHandler(manager Manager, logger hclog.Logger) *Handler

NewHandler returns a new instance of the Handler type that will modify topic data via the provided Manager implementation.

func (*Handler) Create

func (h *Handler) Create(ctx context.Context, cmd *topiccmd.CreateTopic) error

Create the topic described in the command.

func (*Handler) Delete

func (h *Handler) Delete(ctx context.Context, cmd *topiccmd.DeleteTopic) error

Delete the topic described in the command.

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 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.

Jump to

Keyboard shortcuts

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