-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinterface.go
66 lines (59 loc) · 1.67 KB
/
interface.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
64
65
66
package fluent
import (
"context"
"net"
"sync"
"time"
)
type marshaler interface {
Marshal(*Message) ([]byte, error)
}
// Client represents a fluentd client. The client receives data as we go,
// and proxies it to a background minion. The background minion attempts to
// write to the server as soon as possible
type Client interface {
Post(string, interface{}, ...Option) error
Ping(string, interface{}, ...Option) error
Close() error
Shutdown(context.Context) error
}
// Buffered is a Client that buffers incoming messages, and sends them
// asynchrnously when it can.
//
//nolint:maligned
type Buffered struct {
closed bool
minionCancel func()
minionDone chan struct{}
minionQueue chan *Message
muClosed sync.RWMutex
pingQueue chan *Message
subsecond bool
}
// Unbuffered is a Client that synchronously sends messages.
type Unbuffered struct {
address string
conn net.Conn
dialTimeout time.Duration
marshaler marshaler
maxConnAttempts uint64
mu sync.RWMutex
network string
subsecond bool
tagPrefix string
writeTimeout time.Duration
}
// Message is a fluentd's payload, which can be encoded in JSON or MessagePack
// format.
type Message struct {
Tag string `msgpack:"tag"`
Time EventTime `msgpack:"time"`
Record interface{} `msgpack:"record"`
Option interface{} `msgpack:"option"`
subsecond bool // true if we should include subsecond resolution time
replyCh chan error // non-nil if caller expects notification for successfully appending to buffer
}
// EventTime is used to represent the time in a msgpack Message
type EventTime struct {
time.Time
}