types

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: Apache-2.0 Imports: 3 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultPublisherOption = &PublisherOption{
		PublishDelayMessage: false,
	}

	DefaultSubscriberOption = &SubscriberOption{
		SubscribeDelayMessage: false,
	}
)

Functions

This section is empty.

Types

type Capability

type Capability struct {
	Category ProviderCategory
	Name     string
	Module   fx.Option
}

Capability 能力提供者

type Message

type Message struct {
	// Payload is the message's payload.
	Payload Payload
	// contains filtered or unexported fields
}

Message is the basic transfer unit. Messages are emitted by Publishers and received by Subscribers.

func NewMessage

func NewMessage(payload Payload) *Message

NewMessage creates a new Message with payload.

func (*Message) Ack

func (m *Message) Ack() bool

Ack sends message's acknowledgement.

Ack is not blocking. Ack is idempotent. False is returned, if Nack is already sent.

func (*Message) Acked

func (m *Message) Acked() <-chan struct{}

Acked returns channel which is closed when acknowledgement is sent.

Usage:

select {
case <-message.Acked():
	// ack received
case <-message.Nacked():
	// nack received
}

func (*Message) Context

func (m *Message) Context() context.Context

Context returns the message's context. To change the context, use SetContext.

The returned context is always non-nil; it defaults to the background context.

func (*Message) Nack

func (m *Message) Nack() bool

Nack sends message's negative acknowledgement.

Nack is not blocking. Nack is idempotent. False is returned, if Ack is already sent.

func (*Message) Nacked

func (m *Message) Nacked() <-chan struct{}

Nacked returns channel which is closed when negative acknowledgement is sent.

Usage:

select {
case <-message.Acked():
	// ack received
case <-message.Nacked():
	// nack received
}

func (*Message) SetContext

func (m *Message) SetContext(ctx context.Context)

SetContext sets provided context to the message.

type Payload

type Payload []byte

Payload is the Message's payload.

type ProviderCategory

type ProviderCategory int
const (
	ProviderCategoryUnknown ProviderCategory = iota
	ProviderCategoryConfig
	ProviderCategoryLogger
	ProviderCategoryDb
	ProviderCategoryRedis
	ProviderCategoryMq
	ProviderCategoryOss
)

type PublisherOption

type PublisherOption struct {
	PublishDelayMessage bool
}

type SdkConfig

type SdkConfig struct {
	App            string
	Debug          bool // debug mode
	ConfigFilePath string
	ConfigRootDirs []string
}

type SubscriberOption

type SubscriberOption struct {
	SubscribeDelayMessage bool
}

Jump to

Keyboard shortcuts

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