code.vegaprotocol.io/vega@v0.79.0/datanode/api/config.go (about) 1 // Copyright (C) 2023 Gobalsky Labs Limited 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU Affero General Public License as 5 // published by the Free Software Foundation, either version 3 of the 6 // License, or (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU Affero General Public License for more details. 12 // 13 // You should have received a copy of the GNU Affero General Public License 14 // along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 package api 17 18 import ( 19 "time" 20 21 "code.vegaprotocol.io/vega/datanode/config/encoding" 22 "code.vegaprotocol.io/vega/datanode/ratelimit" 23 "code.vegaprotocol.io/vega/logging" 24 ) 25 26 // namedLogger is the identifier for package and should ideally match the package name 27 // this is simply emitted as a hierarchical label e.g. 'api.grpc'. 28 const namedLogger = "api.grpc" 29 30 // Config represents the configuration of the api package. 31 type Config struct { 32 Level encoding.LogLevel `long:"log-level"` 33 Timeout encoding.Duration `long:"timeout"` 34 Port int `long:"port"` 35 WebUIPort int `long:"web-ui-port"` 36 WebUIEnabled encoding.Bool `long:"web-ui-enabled"` 37 Reflection encoding.Bool `long:"reflection"` 38 IP string `long:"ip"` 39 StreamRetries int `long:"stream-retries"` 40 CoreNodeIP string `long:"core-node-ip"` 41 CoreNodeGRPCPort int `long:"core-node-grpc-port"` 42 RateLimit ratelimit.Config `group:"rate-limits"` 43 MaxSubscriptionPerClient uint32 `long:"max-subscription-per-client"` 44 MaxMsgSize int `long:"max-msg-size"` 45 } 46 47 // NewDefaultConfig creates an instance of the package specific configuration, given a 48 // pointer to a logger instance to be used for logging within the package. 49 func NewDefaultConfig() Config { 50 return Config{ 51 Level: encoding.LogLevel{Level: logging.InfoLevel}, 52 Timeout: encoding.Duration{Duration: 5000 * time.Millisecond}, 53 54 IP: "0.0.0.0", 55 Port: 3007, 56 WebUIPort: 3006, 57 WebUIEnabled: false, 58 Reflection: false, 59 StreamRetries: 3, 60 CoreNodeIP: "127.0.0.1", 61 CoreNodeGRPCPort: 3002, 62 RateLimit: ratelimit.NewDefaultConfig(), 63 MaxSubscriptionPerClient: 250, 64 MaxMsgSize: 20 * 1024 * 1024, 65 } 66 }