pubsub

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AggregateIDMessageAttributeKey      = "aggID"
	AggregateNameMessageAttributeKey    = "aggName"
	AggregateVersionMessageAttributeKey = "aggVer"
	EventIDMessageAttributeKey          = "id"
	EventNameMessageAttributeKey        = "name"
	EventTimeMessageAttributeKey        = "time"

	EventTimeFormat = time.RFC3339
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Publisher

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

func NewPublisher

func NewPublisher(ctx context.Context, client *pubsub.Client, encoding codec.Encoding, log logger.Logger, config PublisherConfig) *Publisher

NewPublisher creates a new Publisher that publishes events to a PubSub topic The topic must be created before using this gateway Messages are sent in order, so the OrderingKey is set to the Aggregate ID

To authenticate with PubSub, the GOOGLE_APPLICATION_CREDENTIALS environment variable must be set See https://cloud.google.com/docs/authentication/getting-started for more information

func (*Publisher) Publish

func (g *Publisher) Publish(e event.Event, options ...eventbus.Option) error

Publish sends the given events to the configured PubSub topic Each message is sent in order, if an error is produced, it stops sending and returns the error.

The event name can be found in the "type" attribute of the message

type PublisherAdapter

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

PublisherAdapter is an adapter that allows to use a pubsub.Publisher as an eventbus.Publisher

func NewPublisherAdapter

func NewPublisherAdapter(pubSubPublisher *Publisher) *PublisherAdapter

func (*PublisherAdapter) Publish

func (p *PublisherAdapter) Publish(event1 eventbus.Event, options ...eventbus.Option) error

type PublisherConfig

type PublisherConfig struct {
	ProjectID  string
	TopicName  string
	LogMessage bool
}

type PullAdapter

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

PullAdapter pulls events from a PubSub topic and publishes them to a local event bus

func NewPullAdapter

func NewPullAdapter(client *pubsub.Client, publisher eventbus.Publisher, encoder codec.Encoding, log logger.Logger, config PullAdapterConfig) *PullAdapter

NewPullAdapter creates a new PullAdapter that pulls events from a PubSub topic and publishes them to another publisher

The provided enconder should have all the event types registered before processing events.

To authenticate with PubSub, the GOOGLE_APPLICATION_CREDENTIALS environment variable must be set See https://cloud.google.com/docs/authentication/getting-started for more information

type PullAdapterConfig

type PullAdapterConfig struct {
	ProjectID        string
	SubscriptionName string
	Debug            bool
}

Jump to

Keyboard shortcuts

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