pubsub

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultURLMux = &URLMux{}

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Marshal(src any) ([]byte, error)
	Unmarshal(data []byte, dest any) error
}

type Handler

type Handler[A any] func(ctx context.Context, url *url.URL, h HandlerFunc[A], concurrency int) (Subscription, error)

type HandlerFunc

type HandlerFunc[A any] func(ctx context.Context, msg A) error

type JSONCodec

type JSONCodec struct{}

func (JSONCodec) Marshal

func (c JSONCodec) Marshal(src any) ([]byte, error)

func (JSONCodec) Unmarshal

func (c JSONCodec) Unmarshal(data []byte, dest any) error

type Message added in v0.0.2

type Message struct {
	Metadata map[string]string
	Body     []byte
}

type Subscription added in v0.0.2

type Subscription interface {
	Shutdown(ctx context.Context) error
}

func Handle

func Handle[A any](ctx context.Context, url string, h HandlerFunc[A]) (Subscription, error)

func HandleConcurrent

func HandleConcurrent[A any](ctx context.Context, u string, h HandlerFunc[A], concurrency int) (Subscription, error)

type Topic

type Topic[A any] interface {
	Send(ctx context.Context, req A) error
	Shutdown(ctx context.Context) error
}

func OpenTopic

func OpenTopic[A any](ctx context.Context, u string) (Topic[A], error)

type TopicOpener

type TopicOpener[A any] func(ctx context.Context, url *url.URL) (Topic[A], error)

type URLMux

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

func (*URLMux) GetCodec

func (m *URLMux) GetCodec(scheme string) (Codec, error)

func (*URLMux) GetHandler

func (m *URLMux) GetHandler(scheme string) (Handler[Message], error)

func (*URLMux) GetTopicOpener

func (m *URLMux) GetTopicOpener(scheme string) (TopicOpener[Message], error)

func (*URLMux) RegisterCodec

func (m *URLMux) RegisterCodec(scheme string, c Codec)

func (*URLMux) RegisterHandler

func (m *URLMux) RegisterHandler(scheme string, h Handler[Message])

func (*URLMux) RegisterTopicOpener

func (m *URLMux) RegisterTopicOpener(scheme string, driver TopicOpener[Message])

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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