pubsub

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 7 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

func MustNewSubscriberPipeline added in v1.1.0

func MustNewSubscriberPipeline(params SubscriberPipelineParams) subscriberPipeline

MustNewSubscriberPipeline initializes subscriberPipeline by calling NewSubscriberPipeline It panics if any error is found.

func NewSubscriberPipeline added in v1.1.0

func NewSubscriberPipeline(params SubscriberPipelineParams) (subscriberPipeline, error)

NewSubscriberPipeline creates a new instance of subscriberPipeline. The pipeline initiates with only one step: subscriberReceiver (which receives raw messages from Pubsub).

Types

type Doer added in v1.1.0

type Doer interface {
	// Do executes a pipe entry.
	Do(context.Context, chan any, chan error) chan any
}

Doer indicates how pipeline steps should execute each interaction with the pipe.

type Getter

type Getter interface {
	Get(ctx context.Context) (serverID string, err error)
}

Getter defines boundary interfaces of a pubsub result object.

type PubSubClient

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

PubSubClient is responsible for managing a pubsub topic.

func MustNewPubSubClient

func MustNewPubSubClient[T ToByteser](topic Publisher) PubSubClient[T]

MustNewPubSubClient initializes Publisher by calling NewPubSubClient It panics if any error is found.

func NewPubSubClient

func NewPubSubClient[T ToByteser](topic Publisher) (PubSubClient[T], error)

NewPubSubClient returns a new instance of PubSubClient.

func (PubSubClient[T]) Publish

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

Publish publishes messages in a pubsub topic.

type PublishInput

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

PublishInput is the input for publishing data in a topic.

type Publisher

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

Publisher defines boundary interfaces of a pubsub topic.

type SubscriberPipeline added in v1.1.0

type SubscriberPipeline interface {
	// Run executes the pipeline, connecting each registered step in a ordered way.
	Run(ctx context.Context) chan any

	// Map registers a new Mapper step into pipeline, which is modifies the data that passes
	// through the pipeline. It panics if any required dependency is not properly given.
	Map(mapFn func(any) (any, error)) SubscriberPipeline

	// Reduce registers a new Reducer step into pipeline.
	// It panics if any required dependency is not properly given.
	Reduce(reduceFn func(state interface{}, item interface{}, idx int) (newState interface{}, err error), initialState func() interface{}) SubscriberPipeline

	// Batch registers a new Batcher step into pipeline.
	// It panics if any required dependency is not properly given.
	Batch(itemType reflect.Type, batchSize int, timeout time.Duration) SubscriberPipeline

	// Errors exposes all errors that happens during pipeline processing.
	Errors() chan error
}

SubscriberPipeline is a structure that defines a pubsub pipeline data handler.

type SubscriberPipelineParams added in v1.1.0

type SubscriberPipelineParams struct {
	PubsubSubscription steps.Receiver
	// contains filtered or unexported fields
}

SubscriberPipelineParams encapsulates dependencies for a SubscriberPipelineParams instance.

type ToByteser added in v1.0.1

type ToByteser interface {
	ToBytes() ([]byte, error)
}

ToByteser defines the interface of pubsub client types.

type TopicWrapper

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

TopicWrapper envelopes a pubsub topic type.

func NewTopicWrapper

func NewTopicWrapper(topic *pubsub.Topic) TopicWrapper

NewTopicWrapper returns a new instance of TopicWrapper.

func (TopicWrapper) Publish

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

Publish envelopes a pubsub topic publish method. It returns a Geter.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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