hexapulsar

package
v0.0.0-...-81c1d68 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package hexapulsar implements hexa events. Pulsar driver is thread safe.

Index

Constants

This section is empty.

Variables

View Source
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

type ProducerGenerator func(c pulsar.Client, topic string) (pulsar.Producer, error)

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

Build builds the hexa-event subscriptionOptions.

func (*SubscribeOptionsBuilder) WithFormatter

WithFormatter sets the formatter.

func (*SubscribeOptionsBuilder) WithOptions

WithOptions sets the pulsar consumer options.

func (*SubscribeOptionsBuilder) WithSubscriptionName

func (b *SubscribeOptionsBuilder) WithSubscriptionName(sub string) *SubscribeOptionsBuilder

WithSubscriptionName sets the subscription name.

func (*SubscribeOptionsBuilder) WithType

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

Jump to

Keyboard shortcuts

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