pubsub

package
v0.0.0-...-e30ce0b Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PubsubMetadataConsumerID = "pubsubConsumerID"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BulkHandler

type BulkHandler func(ctx context.Context, msgs []*NewMessage) error

type BulkMessageEntry

type BulkMessageEntry struct {
	EntryId     string            `json:"entryId"` //nolint:stylecheck
	Event       []byte            `json:"event"`
	ContentType string            `json:"contentType,omitempty"`
	Metadata    map[string]string `json:"metadata"`
}

BulkMessageEntry represents a single message inside a bulk request.

type BulkPublishRequest

type BulkPublishRequest struct {
	Entries    []BulkMessageEntry `json:"entries"`
	PubsubName string             `json:"pubsubname"`
	Topic      string             `json:"topic"`
	Metadata   map[string]string  `json:"metadata"`
}

BulkPublishRequest is the request to publish mutilple messages.

type BulkPublishResponse

type BulkPublishResponse struct {
	FailedEntry []FailedEntry
}

type BulkPublisher

type BulkPublisher interface {
	BulkPublish(ctx context.Context, req *BulkPublishRequest) (*BulkPublishResponse, error)
}

type BulkSubscribeConfig

type BulkSubscribeConfig struct {
	MaxMessagesCount   int `json:"maxMessagesCount,omitempty"`
	MaxAwaitDurationMs int `json:"maxAwaitDurationMs,omitempty"`
}

type BulkSubscriber

type BulkSubscriber interface {
	BulkSubscribe(ctx context.Context, req *SubscribeRequest, handler BulkHandler) error
}

type FailedEntry

type FailedEntry struct {
	EntryId string
	Err     error
}

type Feature

type Feature string

Feature names a feature that can be implemented by PubSub components.

const (
	// FeatureMessageTTL is the feature to handle message TTL.
	FeatureMessageTTL Feature = "MESSAGE_TTL"
	// FeatureSubscribeWildcards is the feature to allow subscribing to topics/queues using a wildcard.
	FeatureSubscribeWildcards Feature = "SUBSCRIBE_WILDCARDS"
	FeatureBulkPublish        Feature = "BULK_PUBSUB"
)

func (Feature) IsPresent

func (f Feature) IsPresent(features []Feature) bool

IsPresent checks if a given feature is present in the list.

type Handler

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

type Metadata

type Metadata struct {
	metadata.Base `json:",inline"`
}

type NewMessage

type NewMessage struct {
	Data        []byte            `json:"data"`
	Topic       string            `json:"topic"`
	Metadata    map[string]string `json:"metadata"`
	ContentType *string           `json:"contentType,omitempty"`
}

NewMessage is an event arriving from a message bus instance.

type PubSub

type PubSub interface {
	io.Closer
	Init(ctx context.Context, metadata Metadata) error
	Publish(ctx context.Context, req *PublishRequest) error
	Subscribe(ctx context.Context, req *SubscribeRequest, handler Handler) error
}

type PublishRequest

type PublishRequest struct {
	Data       []byte            `json:"data"`
	PubsubName string            `json:"pubsubName"`
	Topic      string            `json:"topic"`
	Metadata   map[string]string `json:"metadata"`
}

type SubscribeRequest

type SubscribeRequest struct {
	Topic               string              `json:"topic"`
	Metadata            map[string]string   `json:"metadata"`
	BulkSubscribeConfig BulkSubscribeConfig `json:"bulkSubscribe,omitempty"`
}

SubscribeRequest is the request to subscribe to a topic.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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