-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathdispatcher.go
29 lines (23 loc) · 923 Bytes
/
dispatcher.go
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
// SPDX-FileCopyrightText: 2017 Comcast Cable Communications Management, LLC
// SPDX-License-Identifier: Apache-2.0
package main
import (
"errors"
"net/http"
"github.com/xmidt-org/webpa-common/v2/device"
)
var ErrOutboundQueueFull = errors.New("outbound message queue full")
// Dispatcher handles the creation and routing of HTTP requests in response to device events.
// A Dispatcher represents the send side for enqueuing HTTP requests.
type Dispatcher interface {
// OnDeviceEvent is the device.Listener function that processes outbound events. Inject
// this function as a device listener for a manager.
OnDeviceEvent(*device.Event)
}
// outboundEnvelope is a tuple of information related to handling an asynchronous HTTP request.
type outboundEnvelope struct {
request *http.Request
cancel func()
}
// schemeContextKey is the internal key type for storing the event type
type schemeContextKey struct{}