pubsub

package
v0.0.0-...-2cbf6af Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package pubsub contains interfaces for publishing data to queues and subscribing and consuming data from those queues.

Index

Constants

View Source
const (
	PublisherClosed  = Error("publisher is closed")
	SubscriberCLosed = Error("subscriber is closed")
)

Pubsub errors.

Variables

This section is empty.

Functions

func GetTopic

func GetTopic(ctx context.Context) string

GetTopic get the topic from the context. If the context doesnt have a topicCtxKey set, then the value returned will be an empty string.

func WithTopic

func WithTopic(ctx context.Context, topic string) context.Context

WithTopic inject to the given context the pubsub topic.

Types

type Error

type Error string

Error represents a cache error.

func (Error) Error

func (e Error) Error() string

Error returns the error message.

type Handler

type Handler func(ctx context.Context, msg Message) error

Handler is the handler used to invoke the app handler.

type HandlerWithAck

type HandlerWithAck func(ctx context.Context, msg Message, ack func(), nack func()) error

HandlerWithAck is the handler used to invoke the app handler.

type Message

type Message []byte

Message is the message that is going to transit to the event pubsub.

func (Message) String

func (m Message) String() string

type Publisher

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

Publisher publishes a message to the given topic.

type Subscriber

type Subscriber interface {
	Subscribe(ctx context.Context, subscription string, handler Handler) error
	SubscribeWithAck(ctx context.Context, subscription string, handler HandlerWithAck) error
}

Subscriber subscribe to a topic subscription and handle the incoming event published to the topic.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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