/
types.go
47 lines (37 loc) · 802 Bytes
/
types.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
package slsh
import (
"context"
"encoding/json"
"time"
"github.com/sirupsen/logrus"
)
type Secret []byte
func (s Secret) String() string { return "******" }
type AliyunError struct {
HTTPCode int32 `json:"-"`
Code string `json:"errorCode"`
Message string `json:"errorMessage"`
RequestID string `json:"-"`
}
func (a AliyunError) Error() string {
if data, err := json.Marshal(a); err != nil {
return err.Error()
} else {
return string(data)
}
}
type Message struct {
Time time.Time
Contents map[string]string
}
type Writer interface {
WriteMessage(messages ...Message) error
}
type Service interface {
Push(ctx context.Context, message Message) error
Start()
Stop(ctx context.Context) error
}
type Converter interface {
Message(entry *logrus.Entry) Message
}