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
- Variables
- func WithPubAccessMode(m pulsar.ProducerAccessMode) mq.OptionApplier
- func WithPubBatchingMaxMessages(n uint) mq.OptionApplier
- func WithPubEnableBlockIfQueueFull() mq.OptionApplier
- func WithPubEnableCompression() mq.OptionApplier
- func WithPubMaxPendingMessages(n int) mq.OptionApplier
- func WithPubSendTimeout(d time.Duration) mq.OptionApplier
- func WithPubTopic(topic string) mq.OptionApplier
- func WithPublishCallback(f mq.AsyncPubCallback[ProducerMessage]) mq.OptionApplier
- func WithPublisherName(name string) mq.OptionApplier
- func WithPulsarConsumerOptions(options pulsar.ConsumerOptions) mq.OptionApplier
- func WithPulsarProducerOptions(o pulsar.ProducerOptions) mq.OptionApplier
- func WithSubCallback(f mq.SubCallback[ConsumerMessage]) mq.OptionApplier
- func WithSubConsumingMode(mode mq.ConsumeHandleMode) mq.OptionApplier
- func WithSubDisableAutoAck() mq.OptionApplier
- func WithSubEnableRetryNack(retryDelay time.Duration, maxRetry uint32) mq.OptionApplier
- func WithSubGroupName(name string) mq.OptionApplier
- func WithSubOrderedKeyHasher(h mq.Hasher) mq.OptionApplier
- func WithSubTopic(topics ...string) mq.OptionApplier
- func WithSubTopicPattern(pattern string) mq.OptionApplier
- func WithSubType(t pulsar.SubscriptionType) mq.OptionApplier
- func WithSubWorkerBufferSize(n uint16) mq.OptionApplier
- func WithSubWorkerSize(n uint16) mq.OptionApplier
- func WithSyncPublish() mq.OptionApplier
- type Consumer
- type ConsumerMessage
- type Endpoint
- func (e *Endpoint) Close() error
- func (v *Endpoint) DocOf(names ...string) ([]string, bool)
- func (e *Endpoint) Init(ctx context.Context) (err error)
- func (e *Endpoint) LivenessCheck(ctx context.Context) (v liveness.Result)
- func (e *Endpoint) NewConsumer(ctx context.Context, options ...mq.OptionApplier) (_ mq.Consumer[ConsumerMessage], err error)
- func (e *Endpoint) NewProducer(ctx context.Context, options ...mq.OptionApplier) (_ mq.Producer[ProducerMessage], err error)
- func (e *Endpoint) SetDefault()
- type Error
- type Observer
- type Option
- func (o *Option) ClientOption(url string) pulsar.ClientOptions
- func (v *Option) DocOf(names ...string) ([]string, bool)
- func (o *Option) PatchTopic(t *string)
- func (o *Option) PubOption(appliers ...mq.OptionApplier) *PubOption
- func (o *Option) SetDefault()
- func (o *Option) SubOption(appliers ...mq.OptionApplier) *SubOption
- type Producer
- type ProducerMessage
- type PubOption
- type PubSub
- type SubOption
Constants ¶
const ( PERSISTENT = "persistent://" NON_PERSISTENT = "non-persistent://" )
const (
// EXTRA_KEY__EXPIRED_AT is property key for message expiration timestamp (epoch seconds).
EXTRA_KEY__EXPIRED_AT = "EXPIRED_AT"
)
Variables ¶
var ( With = mq.With[ProducerMessage, ConsumerMessage] From = mq.From[ProducerMessage, ConsumerMessage] Must = mq.Must[ProducerMessage, ConsumerMessage] Carry = mq.Carry[ProducerMessage, ConsumerMessage] )
Functions ¶
func WithPubAccessMode ¶
func WithPubAccessMode(m pulsar.ProducerAccessMode) mq.OptionApplier
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 WithPublishCallback ¶
func WithPublishCallback(f mq.AsyncPubCallback[ProducerMessage]) 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 WithSubType ¶
func WithSubType(t pulsar.SubscriptionType) 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 ConsumerMessage ¶
type ConsumerMessage interface {
mq.HasTopic
mq.HasPayload
mq.HasExtra
mq.HasExpiredAt
mq.HasPartitionKey
mq.HasOrderingKey
mq.HasPartitionID
mq.HasProducer
mq.HasPublishedAt
mq.HasConsumedAt
mq.CanRefreshConsumedAt
mq.HasLatency
mq.HasBrokerLatency
mq.HasRetryCount
mq.HasUnderlying[pulsar.Message]
}
func NewConsumerMessage ¶
func NewConsumerMessage(u pulsar.Message) ConsumerMessage
type Endpoint ¶
type Endpoint struct {
types.Endpoint[Option]
mq.ResourceManager `env:"-"`
// contains filtered or unexported fields
}
Endpoint pulsar component endpoint
func (*Endpoint) LivenessCheck ¶
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 )
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
// for producer. failed immediately if there's already a producer connected.
DisablePubShared bool `url:",default=false"`
// 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) PatchTopic ¶
func (*Option) SetDefault ¶
func (o *Option) SetDefault()
type Producer ¶
type Producer = mq.Producer[ProducerMessage]
type ProducerMessage ¶
type ProducerMessage interface {
mq.HasTopic
mq.CanSetTopic
mq.HasPayload
mq.CanSetPayload
mq.HasExtra
mq.CanAppendExtra
mq.HasExpiredAt
mq.CanSetExpiredAt
mq.HasPartitionKey
mq.CanSetPartitionKey
mq.HasOrderingKey
mq.CanSetOrderingKey
mq.HasPublishedAt
mq.CanRefreshPublishedAt
mq.HasDelay
mq.CanSetDelay
mq.HasUnderlying[*pulsar.ProducerMessage]
}
func NewProducerMessage ¶
func NewProducerMessage(topic string, payload []byte) ProducerMessage
type PubOption ¶
type PubOption struct {
// contains filtered or unexported fields
}
func (*PubOption) OptionScheme ¶
func (*PubOption) Options ¶
func (o *PubOption) Options() pulsar.ProducerOptions
type SubOption ¶
type SubOption struct {
// contains filtered or unexported fields
}
func (*SubOption) OptionScheme ¶
func (*SubOption) Options ¶
func (o *SubOption) Options() pulsar.ConsumerOptions