Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( NotSubscribedErr = errors.New("subscription is not yet active") AlreadyHandlingErr = errors.New("this subscriber is already handling messages") )
Functions ¶
This section is empty.
Types ¶
type KafkaSubscriber ¶
type KafkaSubscriber struct {
// contains filtered or unexported fields
}
func NewKafkaSubscriber ¶
func NewKafkaSubscriber(configuration *configuration.KafkaConfiguration) (*KafkaSubscriber, error)
func (*KafkaSubscriber) BeginHandle ¶
func (subscriber *KafkaSubscriber) BeginHandle() error
func (*KafkaSubscriber) Close ¶
func (subscriber *KafkaSubscriber) Close() error
func (*KafkaSubscriber) StopHandle ¶
func (subscriber *KafkaSubscriber) StopHandle()
func (*KafkaSubscriber) Subscribe ¶
func (subscriber *KafkaSubscriber) Subscribe(handler MessageHandler) error
func (*KafkaSubscriber) Unsubscribe ¶
func (subscriber *KafkaSubscriber) Unsubscribe() error
type MessageHandler ¶
type MessageHandler interface { // HandleMessage parses the message received from the broker and takes any necessary action to process it. // True is returned if the message has been correctly handled, false otherwise. HandleMessage(message []byte) bool // GetTopic returns a topic, messages from which can be handled by this handler GetTopic() string }
MessageHandler is responsible for processing messages read from the message broker.
type Subscriber ¶
type Subscriber interface { // Subscribe subscribed to a topic defined in handler. Subscribe(handler MessageHandler) error // Unsubscribe removes current subscription. Unsubscribe() error // BeginHandle starts handling messages received from the broker. // This call starts a goroutine in the background and will not block. BeginHandle() error // StopHandle stops message handling and blocks until current message processing finishes. StopHandle() // Close disables handling, unsubscribed, and disconnects from the broker. Close() error }
Subscriber is a consumer for a message broker. It will listen for new messages from the broker and pass them for handling.
Click to show internal directories.
Click to hide internal directories.