Documentation
¶
Overview ¶
Package hexapulsar implements hexa events. Pulsar driver is thread safe.
Index ¶
- Variables
- func NewEmitter(client pulsar.Client, options EmitterOptions) (hevent.Emitter, error)
- func NewReceiver(o ReceiverOptions) (hevent.Receiver, error)
- func NewSubscriptionFromPulsarOptions(o PulsarSubscribeOptions) *hevent.SubscriptionOptions
- type EmitterOptions
- type ProducerGenerator
- type PulsarSubscribeOptions
- type ReceiverOptions
- type SubscribeOptionsBuilder
- func (b *SubscribeOptionsBuilder) Build() *hevent.SubscriptionOptions
- func (b *SubscribeOptionsBuilder) WithFormatter(f string) *SubscribeOptionsBuilder
- func (b *SubscribeOptionsBuilder) WithOptions(o pulsar.ConsumerOptions) *SubscribeOptionsBuilder
- func (b *SubscribeOptionsBuilder) WithSubscriptionName(sub string) *SubscribeOptionsBuilder
- func (b *SubscribeOptionsBuilder) WithType(t pulsar.SubscriptionType) *SubscribeOptionsBuilder
- type TopicFormatter
Constants ¶
This section is empty.
Variables ¶
var SubscriptionNameError = errors.New("both subscriptionName and topic name are empty, we can not setOptionValues ")
SubscriptionNameError is the error to specify both subscription_name and the topic_name is empty.
Functions ¶
func NewEmitter ¶
func NewEmitter(client pulsar.Client, options EmitterOptions) (hevent.Emitter, error)
NewEmitter returns new instance of pulsar emitter
func NewReceiver ¶
func NewReceiver(o ReceiverOptions) (hevent.Receiver, error)
NewReceiver returns new instance of pulsar implementation of the hexa event receiver.
func NewSubscriptionFromPulsarOptions ¶
func NewSubscriptionFromPulsarOptions(o PulsarSubscribeOptions) *hevent.SubscriptionOptions
NewSubscriptionFromPulsarOptions returns new instance of the SubscriptionOptions from the pulsar options.
Types ¶
type EmitterOptions ¶
type EmitterOptions struct { ProducerGenerator ProducerGenerator ContextPropagator hexa.ContextPropagator Encoder hevent.Encoder }
EmitterOptions contains options that can provide on create emitter.
type ProducerGenerator ¶
ProducerGenerator setOptionValues new producer
func CustomProducerGenerator ¶
func CustomProducerGenerator(topicFormat string, options pulsar.ProducerOptions) ProducerGenerator
CustomProducerGenerator gets producer options and just set the topic name on the producer. then returns new producer. topicFormat is the topic name format, e.g "persistent://public/default/%s", and then we set the provided topic name in the topic pattern.
func DefaultProducerGenerator ¶
func DefaultProducerGenerator(topicPattern string) ProducerGenerator
DefaultProducerGenerator returns producer generator function with default options. topicPattern is the topic name pattern, e.g "persistent://public/default/%s", and then we set the provided topic name in the topic pattern.
type PulsarSubscribeOptions ¶
type PulsarSubscribeOptions struct { SubscriptionName string Formatter string Channel string Handler hevent.EventHandler Type pulsar.SubscriptionType }
PulsarSubscribeOptions contains props which we can use to generate new SubscriptionOptions instance..
type ReceiverOptions ¶
type ReceiverOptions struct { Client pulsar.Client ContextPropagator hexa.ContextPropagator }
type SubscribeOptionsBuilder ¶
type SubscribeOptionsBuilder struct {
// contains filtered or unexported fields
}
SubscribeOptionsBuilder is a builder to build subscription options according to the pulsar options.
func NewSubscribeOptionsBuilder ¶
func NewSubscribeOptionsBuilder(ch string, h hevent.EventHandler) *SubscribeOptionsBuilder
NewSubscribeOptionsBuilder returns new instance of the SubscriptionOptionsBuilderW.
func (*SubscribeOptionsBuilder) Build ¶
func (b *SubscribeOptionsBuilder) Build() *hevent.SubscriptionOptions
Build builds the hexa-event subscriptionOptions.
func (*SubscribeOptionsBuilder) WithFormatter ¶
func (b *SubscribeOptionsBuilder) WithFormatter(f string) *SubscribeOptionsBuilder
WithFormatter sets the formatter.
func (*SubscribeOptionsBuilder) WithOptions ¶
func (b *SubscribeOptionsBuilder) WithOptions(o pulsar.ConsumerOptions) *SubscribeOptionsBuilder
WithOptions sets the pulsar consumer options.
func (*SubscribeOptionsBuilder) WithSubscriptionName ¶
func (b *SubscribeOptionsBuilder) WithSubscriptionName(sub string) *SubscribeOptionsBuilder
WithSubscriptionName sets the subscription name.
func (*SubscribeOptionsBuilder) WithType ¶
func (b *SubscribeOptionsBuilder) WithType(t pulsar.SubscriptionType) *SubscribeOptionsBuilder
WithType sets the subscription type.
type TopicFormatter ¶
type TopicFormatter string
TopicFormatter is the formatter which can use to format topic. e.g "persistent://my_tenant/hello/%s" , so if we has a topic named "john" => topicFormatter format it and finally we have "persistent://my_tenant/hello/john" as our topic
func (TopicFormatter) Format ¶
func (f TopicFormatter) Format(topic string) string
Format format the topic
func (TopicFormatter) FormatList ¶
func (f TopicFormatter) FormatList(topics []string) []string
FormatList format list of topics