-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathnative_dispatcher.go
46 lines (33 loc) · 1.11 KB
/
native_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
36
37
38
39
40
41
42
43
44
45
46
// +build coprocess
// +build !grpc
package coprocess
/*
#include <stdio.h>
#include "sds/sds.h"
#include "api.h"
*/
import "C"
import "unsafe"
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(unsafe.Pointer) unsafe.Pointer
// 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()
}