topics

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithDelay

func WithDelay(duration time.Duration) func(*v1.TopicPublishRequest)

WithDelay - Delay event publishing by the given duration

Types

type Ctx

type Ctx struct {
	Request  Request
	Response *Response
	Extras   map[string]interface{}
	// contains filtered or unexported fields
}

func NewCtx

func NewCtx(msg *topicspb.ServerMessage) *Ctx

func (*Ctx) ToClientMessage

func (c *Ctx) ToClientMessage() *topicspb.ClientMessage

func (*Ctx) WithError

func (c *Ctx) WithError(err error)

type PublishOption

type PublishOption func(*v1.TopicPublishRequest)

type Request

type Request interface {
	TopicName() string
	Message() map[string]interface{}
}

type Response

type Response struct {
	Success bool
}

type SubscribableTopic

type SubscribableTopic interface {
	// Allow requests the given permissions to the topic.
	Allow(permission TopicPermission, permissions ...TopicPermission) *TopicClient

	// Subscribe will register and start a subscription handler that will be called for all events from this topic.
	// Valid function signatures for handler are:
	//
	//	func()
	//	func() error
	//	func(*topics.Ctx)
	//	func(*topics.Ctx) error
	//	Handler[topics.Ctx]
	Subscribe(handler interface{})
}

func NewTopic

func NewTopic(name string) SubscribableTopic

NewTopic creates a new Topic with the give name.

type TopicClient

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

func NewTopicClient

func NewTopicClient(name string) (*TopicClient, error)

func (*TopicClient) Name

func (s *TopicClient) Name() string

func (*TopicClient) Publish

func (s *TopicClient) Publish(ctx context.Context, message map[string]interface{}, opts ...PublishOption) error

type TopicClientIface

type TopicClientIface interface {
	// Name returns the Topic name.
	Name() string

	// Publish will publish the provided events on the topic.
	Publish(ctx context.Context, message map[string]interface{}, options ...PublishOption) error
}

TopicClientIface for pub/sub async messaging.

type TopicPermission

type TopicPermission string

TopicPermission defines the available permissions on a topic

const (
	// TopicPublish is required to call Publish on a topic.
	TopicPublish TopicPermission = "publish"
)

Jump to

Keyboard shortcuts

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