mqconnector

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandHandler

type CommandHandler func(context.Context, []byte) error

type KafkaConnector

type KafkaConnector struct {
	URL           string        //the URL of the Kafka message queue
	WriteDeadline time.Duration // the deadline for future Write calls and any currently-blocked Write call
}

func (KafkaConnector) SendMessage

func (c KafkaConnector) SendMessage(ctx context.Context, message []byte, key string, topic string, properties map[string]string) error

SendMessage sends *message* with *key* to the Kafka message queue under the specified *topic*. Currently, you cannot choose to which partition you send the message (it automatically sends to partition 0).

func (KafkaConnector) SubscribeAndConsume

func (c KafkaConnector) SubscribeAndConsume(ctx context.Context, topic string, subscriptionName string, commands map[string]CommandHandler)

type MQConsumer

type MQConsumer interface {
	SubscribeAndConsume(ctx context.Context, topic string, subscriptionName string, commands map[string]CommandHandler, maxRetry int, sleep int)
}

type MQProducer

type MQProducer interface {
	SendMessage(context.Context, []byte, string, string, map[string]string) error // SendMessage(context, message, key, topic, properties)
}

type PulsarConnector

type PulsarConnector struct {
	URL              string //the URL of the Pulsar message queue
	ConsumeAndDelete bool   // when set to true, read messages are instantly removed from the message queue
}

func (PulsarConnector) SendMessage

func (c PulsarConnector) SendMessage(ctx context.Context, message []byte, key string, topic string, properties map[string]string) error

SendMessage sends *message* with *key* to the Pulsar message queue under the *topic* topic

func (PulsarConnector) SubscribeAndConsume

func (c PulsarConnector) SubscribeAndConsume(ctx context.Context, topic string, subscriptionName string, commands map[string]CommandHandler, maxRetry int, sleepTime time.Duration)

SubscribeAndConsume subscribed to *topic* in the the Pulsar message queue as *subscriptionName*. When a message is received, it checks its key and looks in *commands* which function must be executed.

Jump to

Keyboard shortcuts

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