Introduce Sender interface to abstract client sending in router handlers

This commit is contained in:
Mickael Remond
2019-06-14 09:37:38 +02:00
committed by Mickaël Rémond
parent b05e68c844
commit 9db33d5792
4 changed files with 80 additions and 30 deletions

View File

@@ -19,12 +19,20 @@ import (
// permanent errors to avoid useless reconnection loops.
// - Metrics processing
// StreamClient is an interface used by StreamManager to control Client lifecycle,
// set callback and trigger reconnection.
type StreamClient interface {
Connect() error
Disconnect()
SetHandler(handler EventHandler)
}
// Sender is an interface provided by Stream clients to allow sending XMPP data.
type Sender interface {
Send(packet Packet) error
SendRaw(packet string) error
}
// StreamManager supervises an XMPP client connection. Its role is to handle connection events and
// apply reconnection strategy.
type StreamManager struct {