broker

package
v0.0.0-...-b981748 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFailedToSaveMessage is returned when the broker fails to save a message
	ErrFailedToSaveMessage = errors.New("error: failed to save message")

	// ErrChannelDoesNotExist is returned when the broker tries to publish a message to a non-existent channel
	ErrChannelDoesNotExist = errors.New("error: channel does not exist")

	// ErrChannelAlreadyExists is returned when the broker tries to create a channel that already exists
	ErrChannelAlreadyExists = errors.New("error: channel already exists")

	// ErrSubscriberDoesNotExist is returned when the broker tries to unsubscribe a subscriber from a channel in which the subscriber does not exist
	ErrSubscriberDoesNotExist = errors.New("error: subscriber is not subscribed to the channel")
)

Functions

func NewGrpcServer

func NewGrpcServer(server *Server) *grpc.Server

NewGrpcServer returns a new gRPC server

Types

type Broker

type Broker interface {
	// contains filtered or unexported methods
}

Broker defines the interface for the message broker

type GrpcServer

type GrpcServer struct {
	broker.UnimplementedBrokerServiceServer
	// contains filtered or unexported fields
}

GrpcServer is the gRPC server

func (*GrpcServer) CreateChannel

CreateChannel gRPC endpoint

func (*GrpcServer) Publish

Publish gRPC endpoint

func (*GrpcServer) Subscribe

Subscribe gRPC endpoint

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the broker service implementation for gRPC

func NewServer

func NewServer(logger *zap.Logger, srv *Service) *Server

NewServer returns a new broker server

func (*Server) CreateChannel

gRPC implementation of the CreateChannel method

func (*Server) Publish

gRPC implementation of the Publish method

func (*Server) Subscribe

gRPC implementation of the Subscribe method

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the implementation of the Broker interface

func NewService

func NewService(logger *zap.Logger, storage storage.Storage) *Service

NewService returns a new broker service

Jump to

Keyboard shortcuts

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