publisher

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConnection added in v2.5.0

func NewConnection(pCfg *config.PublisherCfg) (*rabbitmq.Conn, error)

NewConnection creates a new RabbitMQ connection manager.

func NewProducer

func NewProducer(pCfg *config.PublisherCfg) (sarama.SyncProducer, error)

NewProducer return new Kafka producer instance.

func NewPublisher added in v2.5.0

func NewPublisher(topic string, conn *rabbitmq.Conn) (*rabbitmq.Publisher, error)

NewPublisher represent constructor for RabbitMQ publisher.

Types

type Event

type Event struct {
	ID        uuid.UUID      `json:"id"`
	Schema    string         `json:"schema"`
	Table     string         `json:"table"`
	Action    string         `json:"action"`
	Data      map[string]any `json:"data"`
	DataOld   map[string]any `json:"dataOld"`
	EventTime time.Time      `json:"commitTime"`
}

Event structure for publishing to the NATS server.

func (*Event) SubjectName

func (e *Event) SubjectName(cfg *config.Config) string

SubjectName creates subject name from the prefix, schema and table name. Also using topic map from cfg.

type GooglePubSubPublisher added in v2.5.1

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

GooglePubSubPublisher represent Pub/Sub publisher.

func NewGooglePubSubPublisher added in v2.5.1

func NewGooglePubSubPublisher(pubSubConnection *PubSubConnection) *GooglePubSubPublisher

NewGooglePubSubPublisher create new instance of GooglePubSubPublisher.

func (*GooglePubSubPublisher) Close added in v2.5.1

func (p *GooglePubSubPublisher) Close() error

func (*GooglePubSubPublisher) Publish added in v2.5.1

func (p *GooglePubSubPublisher) Publish(ctx context.Context, topic string, event *Event) error

Publish send events, implements eventPublisher.

type KafkaPublisher

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

KafkaPublisher represent event publisher with Kafka broker.

func NewKafkaPublisher

func NewKafkaPublisher(producer sarama.SyncProducer) *KafkaPublisher

NewKafkaPublisher return new KafkaPublisher instance.

func (*KafkaPublisher) Close added in v2.4.2

func (p *KafkaPublisher) Close() error

Close connection close.

func (*KafkaPublisher) Publish

func (p *KafkaPublisher) Publish(_ context.Context, topic string, event *Event) error

type NatsPublisher

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

NatsPublisher represent event publisher.

func NewNatsPublisher

func NewNatsPublisher(conn *nats.Conn, logger *slog.Logger) (*NatsPublisher, error)

NewNatsPublisher return new NatsPublisher instance.

func (NatsPublisher) Close added in v2.4.2

func (n NatsPublisher) Close() error

Close connection.

func (NatsPublisher) CreateStream added in v2.4.2

func (n NatsPublisher) CreateStream(streamName string) error

CreateStream creates a stream by using JetStreamContext. We can do it manually.

func (NatsPublisher) Publish

func (n NatsPublisher) Publish(_ context.Context, subject string, event *Event) error

Publish serializes the event and publishes it on the bus.

type PubSubConnection added in v2.5.1

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

PubSubConnection represent Pub/Sub connection.

func NewPubSubConnection added in v2.5.1

func NewPubSubConnection(ctx context.Context, logger *slog.Logger, pubSubProjectID string) (*PubSubConnection, error)

NewPubSubConnection create new connection with specified project id.

func (*PubSubConnection) Close added in v2.5.1

func (c *PubSubConnection) Close() error

func (*PubSubConnection) Publish added in v2.5.1

func (c *PubSubConnection) Publish(ctx context.Context, topic string, data []byte) error

type RabbitPublisher added in v2.5.0

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

RabbitPublisher represent event publisher for RabbitMQ.

func NewRabbitPublisher added in v2.5.0

func NewRabbitPublisher(pubTopic string, conn *rabbitmq.Conn, publisher *rabbitmq.Publisher) (*RabbitPublisher, error)

NewRabbitPublisher create new RabbitPublisher instance.

func (*RabbitPublisher) Close added in v2.5.0

func (p *RabbitPublisher) Close() error

Close represent finalization for RabbitMQ publisher.

func (*RabbitPublisher) Publish added in v2.5.0

func (p *RabbitPublisher) Publish(ctx context.Context, topic string, event *Event) error

Publish send events, implements eventPublisher.

Jump to

Keyboard shortcuts

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