-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexposed.go
33 lines (26 loc) · 950 Bytes
/
exposed.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
package exposed
import (
"errors"
)
var (
errTransport = errors.New("transport error")
errOperation = errors.New("operation error")
errHandlerNotFound = errors.New("handler not found")
errOperationAlreadyRegistered = errors.New("type already registered")
)
//Exposable interface autoregister services Operations
type Exposable interface {
//ExposedOperations return a list of operations
ExposedOperations() []OperationInfo
}
//Message represents an interchangeable payload
type Message = interface{}
type Handler interface {
ServeExposed(ctx *Context, req Message, resp Message) (err error)
}
// The HandlerFunc type is an adapter to allow the use of
// ordinary functions as exposed RPC handlers.
type HandlerFunc func(ctx *Context, req Message, resp Message) (err error)
func (h HandlerFunc) ServeExposed(ctx *Context, req Message, resp Message) (err error) {
return h(ctx, req, resp)
}