Documentation
¶
Overview ¶
Package pubsub contains implementations for eventing providers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrDeadLetter can be returned by a subscriber to immediately send the event to the dead-letter queue. ErrDeadLetter = errors.New("dead-lettered event") // ErrDiscard can be returned by a subscriber to immediately discard the event without retries/dead-lettering. ErrDiscard = errors.New("discarded event") )
Functions ¶
func NewID ¶
NewID returns a unique identifier for the given type.
The string is a [TypeID](https://github.com/jetify-com/typeid), with the TopicName as the prefix.
Types ¶
type DeadLetter ¶
type DeadLetter[T any] struct { // Error that resulted in the event being dead-lettered. Error string `json:"error"` Event T `json:"event"` }
DeadLetter represents a dead-lettered event.
It is itself an event.
func (DeadLetter[T]) EventID ¶
func (d DeadLetter[T]) EventID() string
type Event ¶
type Event[T any] struct { // contains filtered or unexported fields }
Event represents a typed CloudEvent.
Marshals to/from a JSON CloudEvent (https://cloudevents.io/)
eg.
{
"specversion": "1.0",
"type": "github.com/alecthomas/zero.User",
"source": "github.com/alecthomas/zero.PublishUserEvent",
"id": "Bob",
"data": {"name": "Bob", "age": 30}
}
func (Event[T]) MarshalJSON ¶
func (*Event[T]) UnmarshalJSON ¶
type EventPayload ¶
type EventPayload interface {
// EventID returns the unique identifier for the event.
//
// This is required for idempotence and deduplication in the face of multiple retries.
EventID() string
}
EventPayload _may_ be implemented by an event to specify an ID.
If not present, a unique TypeID will be generated using NewID.
type InMemoryTopic ¶
type InMemoryTopic[T any] struct { // contains filtered or unexported fields }
func (*InMemoryTopic[T]) Close ¶
func (i *InMemoryTopic[T]) Close() error
type Topic ¶
type Topic[T any] interface { // Publish publishes a message to the topic. Publish(ctx context.Context, msg Event[T]) error // Subscribe subscribes to a topic. Subscribe(ctx context.Context, handler func(ctx context.Context, event Event[T]) error) error // Close the topic. Close() error }
Topic represents a PubSub topic.
Directories
¶
| Path | Synopsis |
|---|---|
|
postgres
|
|
|
dashboard
Package dashboard provides dashboard components for the PostgreSQL PubSub provider.
|
Package dashboard provides dashboard components for the PostgreSQL PubSub provider. |
|
Package pubsubtest contains helper functions for testing pubsub.
|
Package pubsubtest contains helper functions for testing pubsub. |
Click to show internal directories.
Click to hide internal directories.