miface

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Encoder
	Decoder
}

type Decoder

type Decoder interface {
	Decode(subject string, data []byte, vPtr any) error
}

type Encoder

type Encoder interface {
	Encode(subject string, v any) ([]byte, error)
}

type Message

type Message interface {
	ID() string
	Topic() string
	Data() []byte
	VPtr() (vPtr any)
}

type MessageQueue

type MessageQueue interface {
	Subscribe(topic string, handler SubResponseHandler, opts ...SubOption) (Subscription, error)
	Publish(topic string, opts ...PubOption) error
}

type PubOption

type PubOption func(o *PubOptions) error

PubOption is a closure that updates PubOptions.

func WithBytes

func WithBytes(data []byte) PubOption

WithBytes Use WithBytes to set mq's message []byte data payload directly

func WithDelay

func WithDelay(deferAmt time.Duration) PubOption

WithDelay Use WithDelay to set the value to defer the message. Deferring is to be done by the message queue, not mq.

func WithEncoder

func WithEncoder(encoder Encoder, topic string, data any) PubOption

WithEncoder Use WithEncoder to set the PubOptions' Data field with with encoded data

func WithJSON

func WithJSON(data any) PubOption

WithJSON Use WithJSON to set the PubOptions' Data field with a JSON object

type PubOptions

type PubOptions struct {
	Data  []byte
	Delay time.Duration
}

PubOptions contains all the various options that the provided WithXyz functions construct.

func NewPubOptions

func NewPubOptions(opts ...PubOption) (options PubOptions, err error)

NewPubOptions constructs an PubOptions struct from the provided PubOption closures and returns it.

type SubOption

type SubOption func(o *SubOptions) error

SubOption is a closure that updates SubOptions.

func WithAtLeastOnceDelivery

func WithAtLeastOnceDelivery() SubOption

Configures delivery semantics of subscription to be at-least-once delivery. If a semantics preference is not set, mq implementation will use its default mode. Mutually exclusive with WithAtMostOnceDelivery()

func WithAtMostOnceDelivery

func WithAtMostOnceDelivery(groupId common.GroupId) SubOption

Configures delivery semantics of subscription to be at-most-once delivery. If a semantics preference is not set, mq implementation will use its default mode. groupId is also optional. Pass in mq.DefaultId to have the mq implementation set a default groupId. Mutually exclusive with WithAtLeastOnceDelivery()

func WithDecoder

func WithDecoder(decoder Decoder, vPtrFactory ValuePtrFactory) SubOption

Use WithDecoder to decode a message's data payload into a value pointer, which is generated by passed-in ValuePtrFactory. Note: When using the WithDecoder option, Message data is only available via VPtr(). No data will be found in Data().

type SubOptions

type SubOptions struct {
	Decoder           Decoder
	VPtrFactory       ValuePtrFactory
	DeliverySemantics common.DeliverySemantics
	GroupId           string
}

SubOptions contains all the various options that the provided WithXyz functions construct.

func NewSubOptions

func NewSubOptions(opts ...SubOption) (options SubOptions, err error)

NewSubOptions constructs an SubOptions struct from the provided SubOption closures and returns it.

type SubResponseHandler

type SubResponseHandler = func(msg Message, err error) common.ConsumptionCode

type Subscription

type Subscription interface {
	IsValid() bool
	Unsubscribe() error
}

type ValuePtrFactory

type ValuePtrFactory interface {
	NewVPtr() (vPtr any)
}

ValuePtrFactory is used during optional subscription decoding. A ValuePtrFactory produces the value pointer populated by Decode()

Jump to

Keyboard shortcuts

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