eventbus

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 13 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUnprocessableEventError

func IsUnprocessableEventError(err error) bool

Types

type EventDesc

type EventDesc struct {
	Name        string
	HandlerType interface{}
	Handler     eventHandler
}

type EventHandlerRegistrar

type EventHandlerRegistrar interface {
	RegisterEventHandler(desc *ServiceDesc, event string, impl interface{})
}

type Handler

type Handler func(ctx context.Context, event interface{}) error

type Processor

type Processor func(md *event.Metadata, data []byte) error

type PublishFn

type PublishFn func(ctx context.Context, name string, e interface{}, p *PublisherImpl, opts ...PublishOption) error

type PublishOption

type PublishOption func(m *event.Metadata)

func WithEventContentType added in v0.1.4

func WithEventContentType(contentType string) PublishOption

func WithEventDataSchema added in v0.1.6

func WithEventDataSchema(schema *url.URL) PublishOption

func WithEventExtension added in v0.1.6

func WithEventExtension(name string, value interface{}) PublishOption

func WithEventSource added in v0.1.4

func WithEventSource(source string) PublishOption

func WithEventSubject added in v0.1.6

func WithEventSubject(subject string) PublishOption

type Publisher

type Publisher interface {
	Publish(ctx context.Context, name string, event interface{}, opts ...PublishOption) error
}

type PublisherImpl

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

func NewPublisher

func NewPublisher(sender Sender, opts ...PublisherOption) *PublisherImpl

func (*PublisherImpl) Publish

func (p *PublisherImpl) Publish(ctx context.Context, name string, event interface{}, opts ...PublishOption) error

type PublisherInterceptor

type PublisherInterceptor func(ctx context.Context, name string, e interface{}, p *PublisherImpl, pf PublishFn, opts ...PublishOption) error

type PublisherOption

type PublisherOption func(opts *publisherOptions)

func WithChainPublisherInterceptor

func WithChainPublisherInterceptor(interceptors ...PublisherInterceptor) PublisherOption

func WithDefaultPublishOptions added in v0.1.4

func WithDefaultPublishOptions(pos ...PublishOption) PublisherOption

func WithPublisherContentType

func WithPublisherContentType(t string) PublisherOption

func WithPublisherInterceptor

func WithPublisherInterceptor(f PublisherInterceptor) PublisherOption

type Receiver

type Receiver interface {
	Receive(ctx context.Context, p Processor) error
}

type Sender

type Sender interface {
	Send(ctx context.Context, metadata *event.Metadata, data []byte) error
}

type ServiceDesc

type ServiceDesc struct {
	ServiceName string
	Events      []EventDesc
	Metadata    string
}

type ServiceInfo

type ServiceInfo struct {
	ServiceName string
	Events      []string
}

type Setuper added in v0.1.6

type Setuper interface {
	Setup(ctx context.Context, serviceName string, info ...ServiceInfo) error
}

type Subscriber

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

func NewSubscriber

func NewSubscriber(name string, opts ...SubscriberOption) *Subscriber

func (*Subscriber) GetServiceInfo

func (s *Subscriber) GetServiceInfo() []ServiceInfo

func (*Subscriber) RegisterEventHandler

func (s *Subscriber) RegisterEventHandler(sd *ServiceDesc, eventName string, h interface{})

func (*Subscriber) Subscribe

func (s *Subscriber) Subscribe(ctx context.Context, r Receiver) error

type SubscriberInterceptor

type SubscriberInterceptor func(ctx context.Context, md *event.Metadata, event interface{}, handler Handler) error

type SubscriberOption

type SubscriberOption func(opts *subscriberOptions)

func WithChainSubscriberInterceptor

func WithChainSubscriberInterceptor(interceptors ...SubscriberInterceptor) SubscriberOption

func WithSubscriberInterceptor

func WithSubscriberInterceptor(f SubscriberInterceptor) SubscriberOption

type UnprocessableEventError

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

func NewUnprocessableEventError

func NewUnprocessableEventError(err error) *UnprocessableEventError

func (*UnprocessableEventError) Error

func (e *UnprocessableEventError) Error() string

func (*UnprocessableEventError) Unwrap

func (e *UnprocessableEventError) Unwrap() error

Jump to

Keyboard shortcuts

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