config

package
v0.0.0-...-7107d2d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvPrefix is a prefix for env variables
	EnvPrefix = "ROBOT"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchLimits

type BatchLimits struct {
	// BatchBlocksCountLimit is a batch blocks count limit
	BatchBlocksCountLimit uint `mapstructure:"batchBlocksCountLimit"`
	// BatchLenLimit is a batch len limit
	BatchLenLimit uint `mapstructure:"batchLenLimit"`
	// BatchSizeLimit is a batch size limit
	BatchSizeLimit uint `mapstructure:"batchSizeLimit"`
	// BatchTimeoutLimit is a batch timeout limit
	BatchTimeoutLimit time.Duration `mapstructure:"batchTimeoutLimit"`
}

BatchLimits is a batch limits config for robot

type Config

type Config struct {
	// LogLevel is a log level (debug, info, warn, error, fatal, panic)
	LogLevel string `mapstructure:"logLevel" validate:"required"`
	// LogType is a log type (json, text)
	LogType string `mapstructure:"logType" validate:"required"`
	// ServerPort is a port for http server
	ServerPort uint `mapstructure:"serverPort"`
	// ProfilePath is a path for profiling
	ProfilePath string `mapstructure:"profilePath" validate:"required"`
	// UserName is a user name
	UserName string `mapstructure:"userName" validate:"required"`
	// UseSmartBFT is a flag for using smart bft
	UseSmartBFT bool `mapstructure:"useSmartBFT"`
	// TxSwapPrefix is a prefix for swap tx
	TxSwapPrefix string `mapstructure:"txSwapPrefix" validate:"required"`
	// TxMultiSwapPrefix is a prefix for multi swap tx
	TxMultiSwapPrefix string `mapstructure:"txMultiSwapPrefix" validate:"required"`
	// TxPreimagePrefix is a prefix for preimage tx
	TxPreimagePrefix string `mapstructure:"txPreimagePrefix" validate:"required"`
	// DelayAfterChRobotError is a delay after channel robot error
	DelayAfterChRobotError time.Duration `mapstructure:"delayAfterChRobotError"`
	// DefaultBatchLimits is a default batch limits
	DefaultBatchLimits *BatchLimits `mapstructure:"defaultBatchLimits"`
	// RedisStorage is a redis storage config
	RedisStorage *RedisStorage `mapstructure:"redisStor" validate:"required"`
	// PromMetrics is a prometheus metrics config
	PromMetrics *PromMetrics `mapstructure:"promMetrics"`

	// CryptoSrc is a crypto manager kind can be local, vault, google
	CryptoSrc CryptoSrc `mapstructure:"cryptoSrc" validate:"required"`
	// VaultCryptoSettings is a vault crypto settings
	VaultCryptoSettings *VaultCryptoSettings `mapstructure:"vaultCryptoSettings"`
	// GoogleCryptoSettings is a google crypto settings
	GoogleCryptoSettings *GoogleCryptoSettings `mapstructure:"googleCryptoSettings"`
	// DefaultRobotExecOpts is a default robot execute options
	DefaultRobotExecOpts ExecuteOptions `mapstructure:"defaultRobotExecOpts" validate:"dive"`
	// Robots is a robots config
	Robots []*Robot `mapstructure:"robots" validate:"dive"`
}

Config is a struct with config

func GetConfig

func GetConfig() (*Config, error)

GetConfig returns config from file

func (Config) WithoutSensitiveData

func (c Config) WithoutSensitiveData() Config

WithoutSensitiveData returns copy of config with empty sensitive data. This config might be used for trace logging.

type CryptoSrc

type CryptoSrc string

CryptoSrc is a crypto manager kind can be local, vault, google

const (
	// LocalCryptoSrc is a local crypto manager
	LocalCryptoSrc CryptoSrc = "local"
	// VaultCryptoSrc is a vault crypto manager
	VaultCryptoSrc CryptoSrc = "vault"
	// GoogleCryptoSrc is a google crypto manager
	GoogleCryptoSrc CryptoSrc = "google"
)

type ExecuteOptions

type ExecuteOptions struct {
	// ExecuteTimeout is a execute timeout
	ExecuteTimeout *time.Duration `mapstructure:"executeTimeout"`
	// WaitCommitAttempts is a wait commit attempts
	WaitCommitAttempts *uint `mapstructure:"waitCommitAttempts"`
	// WaitCommitAttemptTimeout is a wait commit attempt timeout
	WaitCommitAttemptTimeout *time.Duration `mapstructure:"waitCommitAttemptTimeout"`
}

ExecuteOptions is a execute options for robot

func (ExecuteOptions) EffExecuteTimeout

func (eo ExecuteOptions) EffExecuteTimeout(defOpts ExecuteOptions) (time.Duration, error)

EffExecuteTimeout returns effective execute timeout

func (ExecuteOptions) EffWaitCommitAttemptTimeout

func (eo ExecuteOptions) EffWaitCommitAttemptTimeout(defOpts ExecuteOptions) (time.Duration, error)

EffWaitCommitAttemptTimeout returns effective wait commit attempt timeout

func (ExecuteOptions) EffWaitCommitAttempts

func (eo ExecuteOptions) EffWaitCommitAttempts(defOpts ExecuteOptions) (uint, error)

EffWaitCommitAttempts returns effective wait commit attempts

type GoogleCryptoSettings

type GoogleCryptoSettings struct {
	// GcloudProject is a gcloud project
	GcloudProject string `mapstructure:"gcloudProject"`
	// GcloudCreds is a gcloud creds
	GcloudCreds string `mapstructure:"gcloudCreds"`
	// UserCert is a user cert
	UserCert string `mapstructure:"userCert"`
}

GoogleCryptoSettings is a google crypto settings

type PromMetrics

type PromMetrics struct {
	PrefixForMetrics string `mapstructure:"prefix"`
}

PromMetrics is a prometheus metrics config

type RedisStorage

type RedisStorage struct {
	// DBPrefix is a db prefix
	DBPrefix string `mapstructure:"dbPrefix"`
	// Addr is a list of redis addresses
	Addr []string `mapstructure:"addr"`
	// Password is a password for redis
	Password string `mapstructure:"password"`
	// WithTLS is a flag for using tls
	WithTLS bool `mapstructure:"withTLS"`
	// RootCAs is a list of root ca files
	RootCAs []string `mapstructure:"rootCAs"`
}

RedisStorage is a redis storage config

type Robot

type Robot struct {
	// ChName is a channel name for robot
	ChName string `mapstructure:"chName" validate:"required"`
	// InitMinExecBlockNum is a init min exec block num
	InitMinExecBlockNum uint64 `mapstructure:"initExecBlockNum"`
	// SrcChannels is a list of source channels
	SrcChannels []*SrcChannel `mapstructure:"src" validate:"dive"`
	// BatchLimits is a batch limits
	BatchLimits *BatchLimits `mapstructure:"batchLimits"`
	// CollectorsBufSize is a collectors buffer size
	CollectorsBufSize uint `mapstructure:"collectorsBufSize"`
	// ExecOpts is a execute options for robot
	ExecOpts ExecuteOptions `mapstructure:"execOpts" validate:"dive"`
}

Robot is a robot config

type SrcChannel

type SrcChannel struct {
	// ChName is a channel name
	ChName string `mapstructure:"chName" validate:"required"`
	// InitBlockNum is a init block num
	InitBlockNum *uint64 `mapstructure:"initBlockNum" validate:"required"`
}

SrcChannel is a source channel config

type VaultCryptoSettings

type VaultCryptoSettings struct {
	// VaultToken is a vault token
	VaultToken string `mapstructure:"vaultToken"`
	// UseRenewableVaultTokens is a flag for using renewable vault tokens
	UseRenewableVaultTokens bool `mapstructure:"useRenewableVaultTokens"`
	// VaultAddress is a vault address
	VaultAddress string `mapstructure:"vaultAddress"`
	// VaultAuthPath is a vault auth path
	VaultAuthPath string `mapstructure:"vaultAuthPath"`
	// VaultRole is a vault role
	VaultRole string `mapstructure:"vaultRole"`
	// VaultServiceTokenPath is a vault service token path
	VaultServiceTokenPath string `mapstructure:"vaultServiceTokenPath"`
	// VaultNamespace is a vault namespace
	VaultNamespace string `mapstructure:"vaultNamespace"`
	// UserCert is a user cert
	UserCert string `mapstructure:"userCert"`
}

VaultCryptoSettings is a vault crypto settings

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL