-
Notifications
You must be signed in to change notification settings - Fork 19
/
config.go
90 lines (81 loc) · 4.32 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
// Copyright (c) 2022 Gobalsky Labs Limited
//
// Use of this software is governed by the Business Source License included
// in the LICENSE.DATANODE file and at https://www.mariadb.com/bsl11.
//
// Change Date: 18 months from the later of the date of the first publicly
// available Distribution of this version of the repository, and 25 June 2022.
//
// On the date above, in accordance with the Business Source License, use
// of this software will be governed by version 3 or later of the GNU General
// Public License.
package broker
import (
"time"
"code.vegaprotocol.io/vega/datanode/config/encoding"
"code.vegaprotocol.io/vega/logging"
)
const namedLogger = "broker"
// Config represents the configuration of the broker.
type Config struct {
Level encoding.LogLevel `long:"log-level"`
SocketConfig SocketConfig `group:"Socket" namespace:"socket"`
SocketServerInboundBufferSize int `long:"socket-server-inbound-buffer-size"`
SocketServerOutboundBufferSize int `long:"socket-server-outbound-buffer-size"`
FileEventSourceConfig FileEventSourceConfig `group:"FileEventSourceConfig" namespace:"fileeventsource"`
UseEventFile encoding.Bool `long:"use-event-file" description:"set to true to source events from a file"`
PanicOnError encoding.Bool `long:"panic-on-error" description:"if an error occurs on event push the broker will panic, else log the error"`
UseBufferedEventSource encoding.Bool `long:"use-buffered-event-source" description:"if true datanode will buffer events"`
BufferedEventSourceConfig BufferedEventSourceConfig `group:"BufferedEventSource" namespace:"bufferedeventsource"`
EventBusClientBufferSize int `long:"event-bus-client-buffer-size"`
}
// NewDefaultConfig creates an instance of config with default values.
func NewDefaultConfig() Config {
return Config{
Level: encoding.LogLevel{Level: logging.InfoLevel},
SocketConfig: SocketConfig{
IP: "0.0.0.0",
Port: 3005,
MaxReceiveTimeouts: 3,
TransportType: "tcp",
},
SocketServerInboundBufferSize: 10000,
SocketServerOutboundBufferSize: 10000,
FileEventSourceConfig: FileEventSourceConfig{
File: "vega.evt",
TimeBetweenBlocks: encoding.Duration{Duration: 1 * time.Second},
SendChannelBufferSize: 1000,
IsBufferFile: false,
},
UseEventFile: false,
PanicOnError: false,
UseBufferedEventSource: true,
BufferedEventSourceConfig: BufferedEventSourceConfig{
EventsPerFile: 10_000_000,
SendChannelBufferSize: 10_000,
MaxBufferedEvents: 100_000_000,
Archive: true,
ArchiveMaximumSizeBytes: 10_000_000_000,
},
EventBusClientBufferSize: 100000,
}
}
type FileEventSourceConfig struct {
File string `long:"file" description:"the event file"`
TimeBetweenBlocks encoding.Duration `string:"time-between-blocks" description:"the time between sending blocks"`
SendChannelBufferSize int `long:"send-buffer-size" description:"size of channel buffer used to send events to broker "`
IsBufferFile bool `long:"is-buffer-file" description:"if true the source file is a data-node buffer file"`
}
type SocketConfig struct {
IP string `long:"ip" description:" "`
Port int `long:"port" description:" "`
MaxReceiveTimeouts int `long:"max-receive-timeouts"`
TransportType string `long:"transport-type"`
}
type BufferedEventSourceConfig struct {
EventsPerFile int `long:"events-per-file" description:"the number of events to store in a file buffer, set to 0 to disable the buffer"`
SendChannelBufferSize int `long:"send-buffer-size" description:"sink event channel buffer size"`
MaxBufferedEvents int `long:"max-buffered-events" description:"max number of events that can be buffered, after this point events will no longer be buffered"`
Archive bool `long:"archive" description:"archives event buffer files after they have been read, default false"`
ArchiveMaximumSizeBytes int64 `long:"archive-maximum-size" description:"the maximum size of the archive directory"`
}