This repository has been archived by the owner on Nov 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
message.go
63 lines (54 loc) · 1.56 KB
/
message.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package kv
const ProtoVersion = "v7"
// Commands
const (
CmdProtoVersion = "version"
CmdReadKey = "kget"
CmdReadBulk = "kget-bulk"
CmdReadPrefix = "kget-all"
CmdWriteKey = "kset"
CmdWriteBulk = "kset-bulk"
CmdSubscribeKey = "ksub"
CmdSubscribePrefix = "ksub-prefix"
CmdUnsubscribeKey = "kunsub"
CmdUnsubscribePrefix = "kunsub-prefix"
CmdListKeys = "klist"
CmdAuthRequest = "klogin"
CmdAuthChallenge = "kauth"
)
type ErrCode string
const (
ErrServerError = "server error"
ErrInvalidFmt = "invalid message format"
ErrMissingParam = "required parameter missing"
ErrUnknownCmd = "unknown command"
ErrAuthNotInit = "authentication not initialized"
ErrAuthFailed = "authentication failed"
ErrAuthRequired = "authentication required"
)
type Request struct {
CmdName string `json:"command"`
RequestID string `json:"request_id,omitempty"`
Data map[string]interface{} `json:"data"`
}
type Error struct {
Ok bool `json:"ok"`
Error ErrCode `json:"error"`
Details string `json:"details"`
RequestID string `json:"request_id,omitempty"`
}
type Response struct {
CmdType string `json:"type"`
Ok bool `json:"ok"`
RequestID string `json:"request_id,omitempty"`
Data interface{} `json:"data,omitempty"`
}
type Push struct {
CmdType string `json:"type"`
Key string `json:"key"`
NewValue string `json:"new_value"`
}
type Hello struct {
CmdType string `json:"type"`
Version string `json:"version"`
}