confpulsar

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package confpulsar defines component of pulsar +genx:doc

Code generated by genx:code@v0.3.0 DO NOT EDIT.

Code generated by genx:doc@v0.3.0 DO NOT EDIT.

Index

Constants

View Source
const (
	PERSISTENT     = "persistent://"
	NON_PERSISTENT = "non-persistent://"
)
View Source
const (
	// EXTRA_KEY__EXPIRED_AT is property key for message expiration timestamp (epoch seconds).
	EXTRA_KEY__EXPIRED_AT = "EXPIRED_AT"
)

Variables

Functions

func WithPubBatchingMaxMessages

func WithPubBatchingMaxMessages(n uint) mq.OptionApplier

func WithPubEnableBlockIfQueueFull

func WithPubEnableBlockIfQueueFull() mq.OptionApplier

func WithPubEnableCompression

func WithPubEnableCompression() mq.OptionApplier

func WithPubMaxPendingMessages

func WithPubMaxPendingMessages(n int) mq.OptionApplier

func WithPubSendTimeout

func WithPubSendTimeout(d time.Duration) mq.OptionApplier

func WithPubTopic

func WithPubTopic(topic string) mq.OptionApplier

func WithPublisherName

func WithPublisherName(name string) mq.OptionApplier

func WithPulsarConsumerOptions

func WithPulsarConsumerOptions(options pulsar.ConsumerOptions) mq.OptionApplier

func WithPulsarProducerOptions

func WithPulsarProducerOptions(o pulsar.ProducerOptions) mq.OptionApplier

func WithSubCallback

func WithSubCallback(f mq.SubCallback[ConsumerMessage]) mq.OptionApplier

WithSubCallback set subscriber's callback when message is handled.

func WithSubConsumingMode

func WithSubConsumingMode(mode mq.ConsumeHandleMode) mq.OptionApplier

func WithSubDisableAutoAck

func WithSubDisableAutoAck() mq.OptionApplier

WithSubDisableAutoAck enables auto ack. when message received from mq, ack will be performed immediately.

func WithSubEnableRetryNack

func WithSubEnableRetryNack(retryDelay time.Duration, maxRetry uint32) mq.OptionApplier

func WithSubGroupName

func WithSubGroupName(name string) mq.OptionApplier

func WithSubOrderedKeyHasher

func WithSubOrderedKeyHasher(h mq.Hasher) mq.OptionApplier

func WithSubTopic

func WithSubTopic(topics ...string) mq.OptionApplier

func WithSubTopicPattern

func WithSubTopicPattern(pattern string) mq.OptionApplier

func WithSubWorkerBufferSize

func WithSubWorkerBufferSize(n uint16) mq.OptionApplier

func WithSubWorkerSize

func WithSubWorkerSize(n uint16) mq.OptionApplier

func WithSyncPublish

func WithSyncPublish() mq.OptionApplier

Types

type Consumer

type Consumer = mq.Consumer[ConsumerMessage]

type Endpoint

type Endpoint struct {
	types.Endpoint[Option]

	mq.ResourceManager `env:"-"`
	// contains filtered or unexported fields
}

Endpoint pulsar component endpoint

func (*Endpoint) Close

func (e *Endpoint) Close() error

func (*Endpoint) DocOf

func (v *Endpoint) DocOf(names ...string) ([]string, bool)

func (*Endpoint) Init

func (e *Endpoint) Init(ctx context.Context) (err error)

func (*Endpoint) LivenessCheck

func (e *Endpoint) LivenessCheck(ctx context.Context) (v liveness.Result)

LivenessCheck helps to probe liveness of broker. Note: for avoiding backlogs. devs should config message ttl for `liveness` topic eg: pulsarctl topics set-message-ttl persistent://public/default/liveness -t 30

func (*Endpoint) NewConsumer

func (e *Endpoint) NewConsumer(ctx context.Context, options ...mq.OptionApplier) (_ mq.Consumer[ConsumerMessage], err error)

func (*Endpoint) NewProducer

func (e *Endpoint) NewProducer(ctx context.Context, options ...mq.OptionApplier) (_ mq.Producer[ProducerMessage], err error)

func (*Endpoint) SetDefault

func (e *Endpoint) SetDefault()

type Error

type Error int8

Error presents error codes for confpulsar +genx:code

const (
	ERROR_UNDEFINED             Error = iota
	ERROR__CLI_CLOSED                 // client closed
	ERROR__CLI_INIT_ERROR             // client init failed
	ERROR__SUB_CLOSED                 // subscriber closed
	ERROR__SUB_BOOTED                 // subscriber is already booted
	ERROR__SUB_HANDLER_PANICKED       // subscriber handler panicked
	ERROR__SUB_UNSUBSCRIBED           // subscriber unsubscribed
	ERROR__PUB_CLOSED                 // publisher closed
	ERROR__PUB_INVALID_MESSAGE        // publisher got invalid message
)

func (*Error) DocOf

func (v *Error) DocOf(names ...string) ([]string, bool)

func (Error) Message

func (e Error) Message() string

type Observer

type Observer = mq.Observer[ConsumerMessage]

type Option

type Option struct {
	// DisablePersistence [TOPIC] denotes topic scheme. default is "persistent"
	// eg:
	// persistent://<tenant>/[<cluster>/]<namespace>/topic
	// non-persistent://<tenant>/[<cluster>/]<namespace>/topic
	DisablePersistence bool `url:",default=false"`
	// Tenant [TOPIC] represents the top-level Pulsar tenant.
	Tenant string `url:",default=public"`
	// Cluster [TOPIC] denotes target cluster name of client connection
	Cluster string `url:",default="`
	// Namespace [TOPIC] represents the logical domain under a tenant.
	Namespace string `url:",default=default"`

	// ConnectionTimeout [Client] establishment timeout
	ConnectionTimeout types.Duration `url:",default=1s"`
	// ConnectionMaxIdleTime [Client] release the connection if it is not
	// used for more than ConnectionMaxIdleTime. default is 30 minutes
	ConnectionMaxIdleTime types.Duration `url:",default=30m"`
	// OperationTimeout [Client] producer-create, subscribe and unsubscribe
	// operations will be retried until this interval
	OperationTimeout types.Duration `url:",default=3s"`
	// KeepAliveInterval [Client] the ping send and check interval
	KeepAliveInterval types.Duration `url:",default=1m"`
	// MaxConnectionsPerBroker [Client] max connections to a single broker
	MaxConnectionsPerBroker int `url:",default=10"`

	// SendTimeout [PUB] specifies the timeout for a message from sent to
	// acknowledged by the server
	SendTimeout types.Duration `url:",default=2s"`
	// DisableBlockIfQueueFull [PUB] controls whether Send and SendAsync block
	// when producer's message queue is full.
	DisableBlockIfQueueFull bool `url:",default=false"`
	// MaxPendingMessages [PUB] specifies the max size of the queue holding
	MaxPendingMessages int `url:",default=500"`
	// DisableCompress [PUB] specifies if disable message compression, if it is
	// enabled use LZ4 compress type
	DisableCompress bool `url:",default=false"`
	// BatchingMaxMessages [PUB] specifies the max messages permitted in a batch
	BatchingMaxMessages uint
	// DisablePubShared [PUB] if disabled, publisher is required exclusive access
	// for producer. failed immediately if there's already a producer connected.
	DisablePubShared bool `url:",default=false"`

	// EnableSubShared [SUB] if disabled, there can be only 1 consumer on the same
	// topic with the same subscription name
	EnableSubShared bool `url:",default=true"`
	// EnableRetryNack [SUB] if enabled, NACKed message will be redelivered after
	// NackRetryInterval max MaxNackRetry times. if reached MaxNackRetry times,
	// the message filled to global DLQ
	EnableRetryNack bool `url:",default=true"`
	// NackRetryInterval [SUB] retry nack message interval
	NackRetryInterval types.Duration `url:",default=1m"`
	// MaxNackRetry [SUB] max retry times for nack message
	MaxNackRetry uint32 `url:",default=3"`
	// WorkerSize defines the concurrency level for message consumption.
	// Behavior based on ConsumeMode:
	// eg:
	//	- mq.GlobalOrdered: Forced to 1 to ensure strict sequential processing.
	//	- mq.PartitionOrdered: Messages are dispatched to specific workers based on
	//	  a hash of the partition key, ensuring order within the same key.
	//	- mq.Concurrent: messages are distributed across all workers (e.g., round-robin)
	//	  to maximize throughput.
	WorkerSize uint16 `url:",default=16"`
	// WorkerBufferSize [SUB] will prefetch message from broker for improves
	// consumption throughput and reducing wait
	WorkerBufferSize uint16 `url:",default=64"`
	// contains filtered or unexported fields
}

Option presents pulsar client options and default pub/sub options. it can be overridden by option applier when call Endpoint.Publish and Endpoint.Subscribe

func (*Option) ClientOption

func (o *Option) ClientOption(url string) pulsar.ClientOptions

func (*Option) DocOf

func (v *Option) DocOf(names ...string) ([]string, bool)

func (*Option) PatchTopic

func (o *Option) PatchTopic(t *string)

func (*Option) PubOption

func (o *Option) PubOption(appliers ...mq.OptionApplier) *PubOption

func (*Option) SetDefault

func (o *Option) SetDefault()

func (*Option) SubOption

func (o *Option) SubOption(appliers ...mq.OptionApplier) *SubOption

type Producer

type Producer = mq.Producer[ProducerMessage]

type PubOption

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

func (*PubOption) DocOf

func (v *PubOption) DocOf(names ...string) ([]string, bool)

func (*PubOption) OptionScheme

func (*PubOption) OptionScheme() string

func (*PubOption) Options

func (o *PubOption) Options() pulsar.ProducerOptions

type PubSub

type PubSub = mq.PubSub[Producer, Consumer]

type SubOption

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

func (*SubOption) DocOf

func (v *SubOption) DocOf(names ...string) ([]string, bool)

func (*SubOption) OptionScheme

func (*SubOption) OptionScheme() string

func (*SubOption) Options

func (o *SubOption) Options() pulsar.ConsumerOptions

Jump to

Keyboard shortcuts

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