producer

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package producer defines functions for producing messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicConcurrentProducer added in v1.2.0

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

func StartBasicConcurrentProducer added in v1.2.0

func StartBasicConcurrentProducer(globalCtx context.Context, blockingProducer Producer, config BasicConcurrentProducerConfig) *BasicConcurrentProducer

func (*BasicConcurrentProducer) Errors added in v1.2.0

func (b *BasicConcurrentProducer) Errors() <-chan Error

func (*BasicConcurrentProducer) Job added in v1.2.0

func (b *BasicConcurrentProducer) Job(globalCtx context.Context, index uint)

func (*BasicConcurrentProducer) Messages added in v1.2.0

func (b *BasicConcurrentProducer) Messages() chan<- proto.Message

type BasicConcurrentProducerConfig added in v1.2.0

type BasicConcurrentProducerConfig struct {
	// JobsNumber should be relatively high, since IPFS communication can sometimes block for extend periods
	JobsNumber     uint          `envconfig:"JOBS_NUMBER" default:"20"`
	ProduceTimeout time.Duration `envconfig:"PRODUCE_TIMEOUT" default:"2m"`
	ErrBuf         uint          `envconfig:"ERR_CHAN_BUFF" default:"50"`
	MessageBuf     uint          `envconfig:"MESSAGE_BUFF" default:"250"`
}

type BlockingProducer added in v1.2.0

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

func NewBlockingProducer added in v1.2.0

func NewBlockingProducer(writer storage.MessageWriter, sentinelClient sentinelpb.SentinelClient) *BlockingProducer

func (*BlockingProducer) Produce added in v1.2.0

func (m *BlockingProducer) Produce(ctx context.Context, message proto.Message) error

type ConcurrentProducer added in v1.2.0

type ConcurrentProducer interface {
	Messages() chan<- proto.Message
	Errors() <-chan Error
}

ConcurrentProducer can run multiple Produce jobs concurrently. error channel should be sunk, otherwise it would block messages production eventually in order to stop it gracefully, close Messages channel and then sink Errors channel till it's closed

type Error added in v1.2.0

type Error struct {
	Err     error
	Message proto.Message
}

func (Error) Error added in v1.2.0

func (e Error) Error() string

func (Error) Unwrap added in v1.2.0

func (e Error) Unwrap() error

type Producer

type Producer interface {
	Produce(ctx context.Context, message proto.Message) error
}

Producer defines an interface for a blocking operation of adding message to the configured pdcl topic

Jump to

Keyboard shortcuts

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