Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyMessagePayload = errors.New("empty message payload")
ErrEmptyMessagePayload is the error returned when the message payload is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorLogger ¶ added in v0.4.0
type ErrorLogger interface {
Error(err error)
}
ErrorLogger is the interface that wraps the basic message publishing.
type GenericMessage ¶
type GenericMessage struct {
// contains filtered or unexported fields
}
GenericMessage represents a message to be sent to message message queue. It implements the Message interface.
func NewMessage ¶
func NewMessage(payload []byte) (*GenericMessage, error)
NewMessage returns a new Message given a payload.
func (*GenericMessage) AddMetadata ¶
func (m *GenericMessage) AddMetadata(key, value string)
AddMetadata adds the given key-value pair to the message metadata.
func (*GenericMessage) Metadata ¶
func (m *GenericMessage) Metadata() map[string]string
Metadata returns the message metadata.
func (*GenericMessage) Payload ¶
func (m *GenericMessage) Payload() any
Payload returns the message payload.
type Option ¶ added in v0.4.0
type Option func(*Worker)
Option defines the optional parameters for worker.
func WithCleanUp ¶ added in v0.4.0
func WithErrorLogger ¶ added in v0.4.0
func WithErrorLogger(l ErrorLogger) Option
func WithPublishBatchSize ¶ added in v0.4.0
func WithPublishPeriod ¶ added in v0.4.0
type Queue ¶ added in v0.4.0
type Queue interface { // Sends the message to queue Publish(ctx context.Context, msg *store.Message) error }
Queue is the interface that wraps the basic message publishing.
type Store ¶ added in v0.4.0
type Store interface { // List unpublished messages with a batch size Messages(ctx context.Context, batch int) ([]*store.Message, error) // Mark as published the given messages, if one of the messages fails will not update any of the messages Published(ctx context.Context, msg ...*store.Message) error // Deletes messages marked as published and older than expiration period from datastore. DeletePublishedByExpiration(ctx context.Context, exp time.Duration) error }
Source is the interface that wraps the message retrieval and update methods.
type Worker ¶ added in v0.4.0
type Worker struct {
// contains filtered or unexported fields
}
Worker is responsible of publishing messages from datastore to queue, and cleaning already published messages.
func NewWorker ¶ added in v0.4.0
NewWorker returns a `Worker` instance with defaults.
- Publish batch size: 100
- Publish period: 1s
- Golang standard error logger.
func (*Worker) Clean ¶ added in v0.4.0
Clean runs once the message cleaning process given a message expiration time.
func (*Worker) StartClean ¶ added in v0.4.0
StartClean runs the cleaning process preriodically defined by the clean period. If there is an error it stops and returns the error.
func (*Worker) StartPublisher ¶ added in v0.4.0
StartPublisher runs the publishing process. In case there is a publish error, it will call to error handler without stopping the process. If a fatal error happens, ex, cant connect to datastore it will stop the process.
Directories ¶
Path | Synopsis |
---|---|
Package publish manages message publishing from a source to a queue.
|
Package publish manages message publishing from a source to a queue. |
Package store the message for internal use that should not be exported
|
Package store the message for internal use that should not be exported |
postgres/pgx
Package pgx implements storage functionality for saving and retrieving messages
|
Package pgx implements storage functionality for saving and retrieving messages |