broker

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgErrJSONMarshalFail   = "json marshal fail: %w"
	MsgErrCreateProducer    = "can't create producer connection to broker: %w "
	MsgErrCreateAdminClient = "can't create admin client connection to broker: %w"
	MsgErrCreateTopics      = "can't create topics in broker: %w"
	MsgErrProduceTopic      = "can't produce topic: %w"
	MsgErrCreatePartitions  = "can't create partitions in broker: %w"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

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

func New

func New(cfg Config, l zerolog.Logger, opts ...opt) *Broker

func (*Broker) PublishRawBlock

func (b *Broker) PublishRawBlock(_ context.Context, block interface{}) error

func (*Broker) PublishRawBlockResults

func (b *Broker) PublishRawBlockResults(_ context.Context, br interface{}) error

func (*Broker) PublishRawGenesis

func (b *Broker) PublishRawGenesis(_ context.Context, g interface{}) error

func (*Broker) PublishRawTransaction

func (b *Broker) PublishRawTransaction(_ context.Context, tx interface{}) error

func (*Broker) Start

func (b *Broker) Start(ctx context.Context) error

func (*Broker) Stop

func (b *Broker) Stop(ctx context.Context) error

type Config

type Config struct {
	ServerURL       string `env:"BROKER_SERVER"`
	PartitionsCount int    `env:"PARTITIONS_COUNT" envDefault:"1"`
	MaxMessageBytes int    `env:"MAX_MESSAGE_MAX_BYTES" envDefault:"5242880"` // 5MB
	BatchProducer   bool   `env:"BATCH_PRODUCER"`
	Enabled         bool   `env:"BROKER_ENABLED"`
}

type Topic

type Topic *string
var (
	RawBlock        Topic = newTopic("raw_block")
	RawBlockResults Topic = newTopic("raw_block_results")
	RawGenesis      Topic = newTopic("raw_genesis")
	RawTransaction  Topic = newTopic("raw_transaction")
)

type Topics

type Topics []Topic

func (Topics) ToStringSlice

func (ts Topics) ToStringSlice() []string

Jump to

Keyboard shortcuts

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