Documentation ¶
Index ¶
- Constants
- type EventHandlerFunc
- type HTTP
- func (t *HTTP) Connect() error
- func (t *HTTP) Disconnect(quiesce uint)
- func (t *HTTP) ReloadTLSConfig(tlsConfig *tls.Config) error
- func (t *HTTP) SetEventHandler(f EventHandlerFunc) error
- func (t *HTTP) SetRxHandler(f RxHandlerFunc) error
- func (t *HTTP) Tx(addr string, metadata map[string]string, data []byte) (responseCode int, responseMetadata map[string]string, responseData []byte, ...)
- type HTTPResponse
- type MQTT
- func (t *MQTT) Connect() error
- func (t *MQTT) Disconnect(quiesce uint)
- func (t *MQTT) ReloadTLSConfig(tlsConfig *tls.Config) error
- func (t *MQTT) SetEventHandler(f EventHandlerFunc) error
- func (t *MQTT) SetRxHandler(f RxHandlerFunc) error
- func (t *MQTT) Tx(addr string, metadata map[string]string, data []byte) (responseCode int, responseMetadata map[string]string, responseData []byte, ...)
- type Noop
- func (t *Noop) Connect() error
- func (t *Noop) Disconnect(quiesce uint)
- func (t *Noop) ReloadTLSConfig(tlsConfig *tls.Config) error
- func (t *Noop) SetEventHandler(f EventHandlerFunc) error
- func (t *Noop) SetRxHandler(f RxHandlerFunc) error
- func (t *Noop) Tx(addr string, metadata map[string]string, data []byte) (responseCode int, responseMetadata map[string]string, responseData []byte, ...)
- type RxHandlerFunc
- type Transporter
- type TransporterEvent
Constants ¶
const ( TxResponseErr int = -1 TxResponseOK int = 0 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventHandlerFunc ¶
type EventHandlerFunc func(e TransporterEvent)
type HTTP ¶
type HTTP struct {
// contains filtered or unexported fields
}
HTTP is a Transporter that sends and receives data and control messages by sending HTTP requests to a URL.
func NewHTTPTransport ¶
func (*HTTP) Disconnect ¶
func (*HTTP) ReloadTLSConfig ¶
ReloadTLSConfig creates a new HTTP client with the provided TLS config.
func (*HTTP) SetEventHandler ¶
func (t *HTTP) SetEventHandler(f EventHandlerFunc) error
func (*HTTP) SetRxHandler ¶
func (t *HTTP) SetRxHandler(f RxHandlerFunc) error
type HTTPResponse ¶
type HTTPResponse struct { StatusCode int Body json.RawMessage Metadata map[string]string }
HTTPResponse is a data structure representing an HTTP response received from an HTTP request sent through the transport.
type MQTT ¶
type MQTT struct {
// contains filtered or unexported fields
}
MQTT is a Transporter that sends and receives data and control messages over MQTT by subscribing and publishing to topics on an MQTT broker.
func NewMQTTTransport ¶
NewMQTTTransport creates a transport suitable for transmitting data over a set of MQTT topics.
func (*MQTT) Connect ¶
Connect connects an MQTT client to the configured broker and waits for the connection to open.
func (*MQTT) Disconnect ¶
Disconnect closes the connection to the MQTT broker, waiting for the specified number of milliseconds for work to complete.
func (*MQTT) ReloadTLSConfig ¶
ReloadTLSConfig creates a new MQTT client with the given TLS config, disconnects the previous client, and connects the new one.
func (*MQTT) SetEventHandler ¶
func (t *MQTT) SetEventHandler(f EventHandlerFunc) error
func (*MQTT) SetRxHandler ¶
func (t *MQTT) SetRxHandler(f RxHandlerFunc) error
SetRxHandler stores a reference to f, which is then called whenever data is received over the inbound data topic.
type Noop ¶
type Noop struct{}
Noop is a Transporter that does nothing. This Transport is used to enable a "local only" dispatch mode.
func NewNoopTransport ¶
func (*Noop) Disconnect ¶
func (*Noop) SetEventHandler ¶
func (t *Noop) SetEventHandler(f EventHandlerFunc) error
func (*Noop) SetRxHandler ¶
func (t *Noop) SetRxHandler(f RxHandlerFunc) error
type RxHandlerFunc ¶
type Transporter ¶
type Transporter interface { // Connect begins listening over specific network connections and receiving // data. Connect() error // Disconnect disconnects the transport, performing any graceful shutdown // necessary. Disconnect(quiesce uint) // Tx sends a message to the given address, using metadata and data // according to the specific nature of the transport.Transporter // implementation. Tx( addr string, metadata map[string]string, data []byte, ) (responseCode int, responseMetadata map[string]string, responseData []byte, err error) // SetRxHandler stores a reference to f, which is then called whenever data // is received over the network. SetRxHandler(f RxHandlerFunc) error // ReloadTLSConfig forces the transport to replace its TLS configuration // with tlsConfig. ReloadTLSConfig(tlsConfig *tls.Config) error // SetEventHandler stores a reference to f, which is then called whenever an // event occurs in the transporter. SetEventHandler(f EventHandlerFunc) error }
Transporter is an interface representing the ability to send and receive data. It abstracts away the concrete implementation, leaving that up to the implementing type.
type TransporterEvent ¶
type TransporterEvent uint
const ( TransporterEventConnected TransporterEvent = 0 TransporterEventDisconnected TransporterEvent = 1 )