code.vegaprotocol.io/vega@v0.79.0/datanode/candlesv2/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 candlesv2
    17  
    18  import (
    19  	"time"
    20  
    21  	"code.vegaprotocol.io/vega/datanode/config/encoding"
    22  	"code.vegaprotocol.io/vega/logging"
    23  )
    24  
    25  // namedLogger is the identifier for package and should ideally match the package name
    26  // this is simply emitted as a hierarchical label e.g. 'api.grpc'.
    27  const namedLogger = "candlesV2"
    28  
    29  // Config represent the configuration of the candle v2 package.
    30  type Config struct {
    31  	Level         encoding.LogLevel   `long:"log-level"`
    32  	CandleStore   CandleStoreConfig   `group:"CandleStore"   namespace:"candlestore"`
    33  	CandleUpdates CandleUpdatesConfig `group:"CandleUpdates" namespace:"candleupdates"`
    34  }
    35  
    36  type CandleStoreConfig struct {
    37  	DefaultCandleIntervals string `description:"candles with the given intervals will always be created and exist by default" string:"default-candle-intervals"`
    38  }
    39  
    40  type CandleUpdatesConfig struct {
    41  	CandleUpdatesStreamBufferSize                int               `description:"buffer size used by the candle events stream for the per client per candle channel" long:"candle-updates-stream-buffer-size"`
    42  	CandleUpdatesStreamInterval                  encoding.Duration `description:"The time between sending updated candles"                                           long:"candle-updates-stream-interval"`
    43  	CandlesFetchTimeout                          encoding.Duration `description:"Maximum time permissible to fetch candles"                                          long:"candles-fetch-timeout"`
    44  	CandleUpdatesStreamSubscriptionMsgBufferSize int               `description:"size of the buffer used to hold pending subcribe/unsubscribe requests"              long:"candle-updates-stream-subscription-buffer-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  		CandleUpdates: CandleUpdatesConfig{
    53  			CandleUpdatesStreamBufferSize:                100,
    54  			CandleUpdatesStreamInterval:                  encoding.Duration{Duration: time.Second},
    55  			CandlesFetchTimeout:                          encoding.Duration{Duration: 10 * time.Second},
    56  			CandleUpdatesStreamSubscriptionMsgBufferSize: 100,
    57  		},
    58  	}
    59  }