util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: LGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyTypeMnemonic    = "mnemonic"
	KeyTypeAWSMnemonic = "aws_mnemonic"
)
View Source
const (
	IncidentDedupKeyBlockTimeout = "block_timeout"
	IncidentDedupKeyRelayError   = "relay_error"
)

Variables

View Source
var (
	// Logger instance for quick declarative logging levels
	Logger    = logging.MustGetLogger("deputy")
	SdkLogger = &sdkLogger{}
)

Functions

func GetSecret

func GetSecret(secretName, region string) (string, error)

GetSecret retrieves the secret from aws secret manager

func InitAlert

func InitAlert(cfg *AlertConfig)

func InitLogger

func InitLogger(config LogConfig)

InitLogger initialises the logger.

func PrepareDB

func PrepareDB(config *Config) (*gorm.DB, error)

func SendPagerDutyAlert

func SendPagerDutyAlert(detail string, dedupKey string)

func SendTelegramMessage

func SendTelegramMessage(msg string)

SendTelegramMessage sends message to telegram group

Types

type AdminConfig

type AdminConfig struct {
	ListenAddr string `json:"listen_addr"`
}

type AlertConfig

type AlertConfig struct {
	Moniker string `json:"moniker"`

	TelegramBotId  string `json:"telegram_bot_id"`
	TelegramChatId string `json:"telegram_chat_id"`

	PagerDutyAuthToken string `json:"pager_duty_auth_token"`

	BlockUpdateTimeOut         int64 `json:"block_update_time_out"`
	PackageDelayAlertThreshold int64 `json:"package_delay_alert_threshold"`
}

func (*AlertConfig) Validate

func (cfg *AlertConfig) Validate()

type ChainConfig

type ChainConfig struct {
	ASCStartHeight               int64          `json:"asc_start_height"`
	ASCProviders                 []string       `json:"asc_providers"`
	ASCConfirmNum                int64          `json:"asc_confirm_num"`
	ASCChainId                   uint16         `json:"asc_chain_id"`
	ASCCrossChainContractAddress ethcmm.Address `json:"asc_cross_chain_contract_address"`

	AFCRpcAddrs      []string `json:"afc_rpc_addrs"`
	AFCMnemonic      string   `json:"afc_mnemonic"`
	AFCKeyType       string   `json:"afc_key_type"`
	AFCAWSRegion     string   `json:"afc_aws_region"`
	AFCAWSSecretName string   `json:"afc_aws_secret_name"`

	RelayInterval int64 `json:"relay_interval"`
}

func (*ChainConfig) Validate

func (cfg *ChainConfig) Validate()

type Config

type Config struct {
	DBConfig    *DBConfig    `json:"db_config"`
	ChainConfig *ChainConfig `json:"chain_config"`
	LogConfig   *LogConfig   `json:"log_config"`
	AlertConfig *AlertConfig `json:"alert_config"`
	AdminConfig *AdminConfig `json:"admin_config"`
}

func GetTestConfig

func GetTestConfig() *Config

func ParseConfigFromFile

func ParseConfigFromFile(filePath string) *Config

ParseConfigFromFile returns the config from json file

func ParseConfigFromJson

func ParseConfigFromJson(content string) *Config

ParseConfigFromJson returns the config from json string

func (*Config) Validate

func (cfg *Config) Validate()

type DBConfig

type DBConfig struct {
	Dialect string `json:"dialect"`
	DBPath  string `json:"db_path"`
}

func (*DBConfig) Validate

func (cfg *DBConfig) Validate()

type LogConfig

type LogConfig struct {
	Level                        string `json:"level"`
	Filename                     string `json:"filename"`
	MaxFileSizeInMB              int    `json:"max_file_size_in_mb"`
	MaxBackupsOfLogFiles         int    `json:"max_backups_of_log_files"`
	MaxAgeToRetainLogFilesInDays int    `json:"max_age_to_retain_log_files_in_days"`
	UseConsoleLogger             bool   `json:"use_console_logger"`
	UseFileLogger                bool   `json:"use_file_logger"`
	Compress                     bool   `json:"compress"`
}

func (*LogConfig) Validate

func (cfg *LogConfig) Validate()

type TgAlerter

type TgAlerter struct {
	BotId  string
	ChatId string
}

Jump to

Keyboard shortcuts

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