forked from TykTechnologies/tyk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrpc_dispatcher.go
35 lines (26 loc) · 1.01 KB
/
grpc_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
30
31
32
33
34
35
// +build coprocess
// +build grpc
package coprocess
import (
"github.com/TykTechnologies/tyk/apidef"
)
const (
_ = iota
JsonMessage
ProtobufMessage
)
// Dispatcher defines a basic interface for the CP dispatcher, check PythonDispatcher for reference.
type Dispatcher interface {
// Dispatch takes and returns a pointer to a CoProcessMessage struct, see coprocess/api.h for details. This is used by CP bindings.
Dispatch(*Object) (*Object, error)
// DispatchEvent takes an event JSON, as bytes. Doesn't return.
DispatchEvent([]byte)
// DispatchObject takes and returns a coprocess.Object pointer, this is used by gRPC.
DispatchObject(*Object) (*Object, error)
// LoadModules is called the first time a CP binding starts. Used by Lua.
LoadModules()
// HandleMiddlewareCache is called when a bundle has been loaded and the dispatcher needs to cache its contents. Used by Lua.
HandleMiddlewareCache(*apidef.BundleManifest, string)
// Reload is called when a hot reload is triggered. Used by all the CPs.
Reload()
}