-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.go
48 lines (39 loc) · 874 Bytes
/
api.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
47
48
package mqlib
import (
"context"
"time"
)
type RpcCallback = func(msg *Message)
type SubCallback = func(msg *Message) error
type SubDispatcher interface {
ProcessMsg(msg *Message) error
}
type baseClient interface {
Shutdown()
}
type PubClient interface {
baseClient
GetPub() *Producer
SetRpcTimeout(ttl time.Duration)
SendMessage(msg *Message) error
Request(msg *Message, ctx ...context.Context) (resp *Message, err error)
RequestAsync(msg *Message, out chan *Message, ctx ...context.Context) error
RequestAsyncWithFunc(msg *Message, callback RpcCallback, ctx ...context.Context) error
}
type SubClient interface {
baseClient
GetSub() *Consumer
SetDeDup(bool)
}
type RpcSrvClient interface {
baseClient
Respond(msg *Message) error
}
type PubSubClient interface {
PubClient
SubClient
}
type GenericClient interface {
RpcSrvClient
PubSubClient
}