-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
93 lines (72 loc) · 2.65 KB
/
config.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package config
import (
"fmt"
"time"
)
// Config holds configuration variables
type Config struct {
// File is the path of a file from which configuration is read.
File string `json:"config-file"`
// Verbose prints debugging information.
Verbose bool `json:"verbose"`
// Host is the socket listener host:port.
Host string `json:"host"`
// HttpHost is the http listener host:port
HttpHost string `json:"http-host"`
// Timeout determines how long to wait during requests before closing the
// connection if the request hasn't completed.
Timeout time.Duration `json:"timeout"`
// IdleTimeout determines how long a connection can live without any
// requests issued.
IdleTimeout time.Duration `json:"idle-timeout"`
// ShutdownTimeout determines how long active connections should be waited
// on during the shutdown sequence.
ShutdownTimeout time.Duration `json:"shutdown-timeout"`
// WorkDir defines the working directory.
WorkDir string `json:"work-dir"`
// LogFileMode defines the file permissions for log files.
LogFileMode int `json:"log-file-mode"`
// MaxBatchSize defines the maximum allowed size for a batch.
MaxBatchSize int `json:"max-batch-size"`
// PartitionSize defines the maximum partition size.
PartitionSize int `json:"partition-size"`
// MaxPartitions defines the maximum number of partitions. Once this has
// been reached, the oldest partition will be rotated out and deleted.
MaxPartitions int `json:"max-partitions"`
// FlushBatches defines the number of batches to write before syncing to
// disk.
FlushBatches int `json:"flush-batches"`
// FlushInterval defines the amount of time elapsed before syncing to disk.
FlushInterval time.Duration `json:"flush-interval"`
// MaxTopics can be defined to limit the number of allowed topics.
MaxTopics int `json:"topics"`
// TopicWhitelist can be defined to limit topics to a predefined list.
TopicWhitelist []string `json:"topic-whitelist"`
// MaxMessages is the maximum number of messages allowed to be returned by
// read and tail requests.
MaxMessages int `json:"max-messages"`
}
// New returns a new configuration object
func New() *Config {
return &Config{}
}
func (c *Config) String() string {
return fmt.Sprintf("%+v", *c)
}
// Default is the default application config
var Default = &Config{
Host: ":1774",
HttpHost: ":1775",
Timeout: 15 * time.Second,
IdleTimeout: 30 * time.Second,
ShutdownTimeout: 15 * time.Second,
WorkDir: "logs/",
LogFileMode: 0600,
MaxBatchSize: 1024 * 64,
PartitionSize: 1024 * 1024 * 2000,
MaxPartitions: 8,
FlushBatches: 0,
FlushInterval: -1,
MaxTopics: 8,
MaxMessages: 50000,
}