-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhub.go
More file actions
30 lines (25 loc) · 835 Bytes
/
hub.go
File metadata and controls
30 lines (25 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright © 2017 thingful
package hub
// Listener encapsulates various transports e.g. MQTT, HTTP
type Listener interface {
NewChannel(string) (Channel, error)
Close() error
}
// Channel exposes errors and Message channels
type Channel interface {
Errors() chan error
Out() chan Message
Close() error
}
// Message contains a Payload, a processed Output and any Metadata collected
type Message struct {
Payload []byte `json:"payload"`
Output interface{} `json:"output"`
Schema map[string]interface{} `json:"schema"`
Metadata map[string]interface{} `json:"metadata"`
Tags map[string]string `json:"tags,omitempty"`
}
// Endpoint takes a processed message and forwards to another service e.g. an HTTP endpoint, Kafka etc
type Endpoint interface {
Write(message Message) error
}