publisher

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConnection

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

NewConnection creates a new RabbitMQ connection manager.

func NewProducer

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

NewProducer return new Kafka producer instance.

func NewPublisher

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

NewPublisher represent constructor for RabbitMQ publisher.

Types

type GooglePubSubPublisher

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

GooglePubSubPublisher represent Pub/Sub publisher.

func NewGooglePubSubPublisher

func NewGooglePubSubPublisher(pubSubConnection *PubSubConnection) *GooglePubSubPublisher

NewGooglePubSubPublisher create new instance of GooglePubSubPublisher.

func (*GooglePubSubPublisher) Close

func (p *GooglePubSubPublisher) Close() error

func (*GooglePubSubPublisher) Publish

func (p *GooglePubSubPublisher) Publish(ctx context.Context, topic string, event *apis.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

func (p *KafkaPublisher) Close() error

Close connection close.

func (*KafkaPublisher) Publish

func (p *KafkaPublisher) Publish(_ context.Context, topic string, event *apis.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

func (n NatsPublisher) Close() error

Close connection.

func (NatsPublisher) Publish

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

Publish serializes the event and publishes it on the bus.

func (NatsPublisher) WaitForStreamToBeCreated added in v0.0.2

func (n NatsPublisher) WaitForStreamToBeCreated(ctx context.Context, streamName string) error

WaitForStreamToBeCreated polls every 2 seconds until the stream with the given name is found. It returns an error if the context is canceled or times out.

type PubSubConnection

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

PubSubConnection represent Pub/Sub connection.

func NewPubSubConnection

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

NewPubSubConnection create new connection with specified project id.

func (*PubSubConnection) Close

func (c *PubSubConnection) Close() error

func (*PubSubConnection) Publish

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

type RabbitPublisher

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

RabbitPublisher represent event publisher for RabbitMQ.

func NewRabbitPublisher

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

NewRabbitPublisher create new RabbitPublisher instance.

func (*RabbitPublisher) Close

func (p *RabbitPublisher) Close() error

Close represent finalization for RabbitMQ publisher.

func (*RabbitPublisher) Publish

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

Publish send events, implements eventPublisher.