pubsub

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const TraceIDContextKey string = "trace_id"

TraceIDContextKey defines the trace id key in a context.

Variables

This section is empty.

Functions

This section is empty.

Types

type PubSubClient

type PubSubClient[T any] struct {
	// contains filtered or unexported fields
}

PubSubClient is a client of Google Pubsub topic with schema of type T.

func MustNewPubSubClient

func MustNewPubSubClient[T any](params *PubSubClientParams[T]) *PubSubClient[T]

MustNewPubSubClient creates a new PubSubClient instance. It panics if any error is found.

func NewPubSubClient

func NewPubSubClient[T any](params *PubSubClientParams[T]) (*PubSubClient[T], error)

NewPubSubClient creates a new PubSubClient instance.

func (PubSubClient[T]) Publish

func (c PubSubClient[T]) Publish(ctx context.Context, in ...PublishInput[T]) []error

Publish publishes messages in a pubsub topic with schema of type T.

type PubSubClientParams

type PubSubClientParams[T any] struct {
	Topic Publisher
}

PubSubClientParams encapsulates the necessary params to build a PubSubClient.

type PublishInput

type PublishInput[T any] struct {
	Data       T
	Attributes map[string]string
}

PublishInput is the input for publishing data into a topic with schema of type T.

type Publisher

type Publisher interface {
	Publish(ctx context.Context, msg *pubsub.Message) error
}

Publisher defines boundary interfaces of a pubsub topic.

type TopicWrapper

type TopicWrapper struct {
	Topic *pubsub.Topic
}

TopicWrapper envelopes a pubsub topic type.

func (TopicWrapper) Publish

func (tw TopicWrapper) Publish(ctx context.Context, msg *pubsub.Message) error

Publish envelopes a pubsub topic publish method.

Jump to

Keyboard shortcuts

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