types

package
v0.0.0-...-23cc077 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const AppContextKey = "be-indexer-context"

AppContextKey is the key in the context.Context which holds the application context.

Variables

View Source
var ErrUpstreamRpcReturnedError = errors.New("upstream RPC returned error")

ErrUpstreamRpcReturnedError is the error when the upstream RPC returned error

Functions

func IsErrUpstreamRpcReturnedError

func IsErrUpstreamRpcReturnedError(err error) bool

IsErrUpstreamRpcReturnedError returns true if the error is built from upstream RPC response error, when error code is not zero.

func ParseJsonRpcResponse

func ParseJsonRpcResponse[T any](bz []byte) (any, error)

Types

type ChainConfig

type ChainConfig struct {
	ChainId       string   `mapstructure:"chain_id"`
	BeJsonRpcUrls []string `mapstructure:"be_json_rpc_urls"`
	Disable       bool     `mapstructure:"disable"`
}

ChainConfig represent per-chain configuration

func (ChainConfig) Validate

func (cc ChainConfig) Validate() error

Validate performs validation per chain configuration

type ChainList

type ChainList map[string]ChainConfig

ChainList is the structure representation of configuration from `chains.yaml` file

func (ChainList) LoadConfig

func (cl ChainList) LoadConfig(homeDir string) error

LoadConfig load the configuration from `chains.yaml` file within the specified application's home directory

func (ChainList) PrintOptions

func (cl ChainList) PrintOptions()

func (ChainList) Validate

func (cl ChainList) Validate() error

Validate performs validation on the configuration specified in the `chains.yaml` within application's home directory

type Config

type Config struct {
	IndexingConfig Indexing               `mapstructure:"indexing"`
	Logging        logtypes.LoggingConfig `mapstructure:"logging"`
	SecretConfig   Secret                 `mapstructure:"secrets"`
	Endpoints      Endpoints              `mapstructure:"endpoints"`
	TelegramConfig Telegram               `mapstructure:"telegram"`
}

Config is the structure representation of configuration from `config.yaml` file

func (*Config) LoadConfig

func (c *Config) LoadConfig(homeDir string) error

LoadConfig load the configuration from `config.yaml` file within the specified application's home directory

func (Config) PrintOptions

func (c Config) PrintOptions()

PrintOptions prints the configuration in the `config.yaml` in a nice way, human-readable

func (Config) Validate

func (c Config) Validate() error

Validate performs validation on the configuration specified in the `config.yaml` within application's home directory

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context hold the working context of the application entirely. It contains application configuration, logger, as well as connection pool,...

func NewContext

func NewContext() Context

NewContext returns an empty `Context`

func UnwrapIndexerContext

func UnwrapIndexerContext(ctx context.Context) Context

func (Context) Deadline

func (c Context) Deadline() (deadline time.Time, ok bool)

func (Context) Done

func (c Context) Done() <-chan struct{}

func (Context) Err

func (c Context) Err() error

func (Context) GetConfig

func (c Context) GetConfig() Config

func (Context) GetDatabase

func (c Context) GetDatabase() database.Database

func (Context) GetLogger

func (c Context) GetLogger() logging.Logger

func (Context) GetTelegramBot

func (c Context) GetTelegramBot() TelegramBot

func (Context) Sealed

func (c Context) Sealed() Context

func (Context) Value

func (c Context) Value(key any) any

func (Context) WithConfig

func (c Context) WithConfig(cfg Config) Context

func (Context) WithDatabase

func (c Context) WithDatabase(db database.Database) Context

func (Context) WithLogger

func (c Context) WithLogger(logger logging.Logger) Context

func (Context) WithTelegramBot

func (c Context) WithTelegramBot(bot TelegramBot) Context

type ContextKey

type ContextKey string

ContextKey defines a type alias for a stdlib Context key.

type Endpoints

type Endpoints struct {
	Database libdbtypes.PostgresDatabaseConfig `mapstructure:"db"`
}

Endpoints holds nested configurations relates to remote endpoints

type Indexing

type Indexing struct {
	HotReloadInterval             time.Duration `mapstructure:"hot-reload"`
	UrlCheckInterval              time.Duration `mapstructure:"url-check"`
	IndexBlockInterval            time.Duration `mapstructure:"index-block"`
	DisableRetryIndexFailedBlocks bool          `mapstructure:"disable-retry-failed-blocks"`
	Whitelist                     []string      `mapstructure:"whitelist"`
	IgnoreList                    []string      `mapstructure:"ignore-list"`
}

Indexing is the structure representation of configuration from `config.yaml` file, at `indexing` section. Configuration for indexing on-chain data can be putted here

type JsonRpcQueryBuilder

type JsonRpcQueryBuilder interface {
	Method() string
	String() string
}

func NewJsonRpcQueryBuilder

func NewJsonRpcQueryBuilder(
	method string,
	params ...JsonRpcQueryParam,
) JsonRpcQueryBuilder

type JsonRpcQueryParam

type JsonRpcQueryParam interface {
	// IsArray returns true if the param is array formed
	IsArray() bool

	// String returns string of the param
	String() string
}

func NewJsonRpcInt64QueryParam

func NewJsonRpcInt64QueryParam(num int64) JsonRpcQueryParam

func NewJsonRpcIntQueryParam

func NewJsonRpcIntQueryParam(num int) JsonRpcQueryParam

func NewJsonRpcStringArrayQueryParam

func NewJsonRpcStringArrayQueryParam(strArr ...string) (JsonRpcQueryParam, error)

func NewJsonRpcStringQueryParam

func NewJsonRpcStringQueryParam(str string) (JsonRpcQueryParam, error)

type Secret

type Secret struct {
	TelegramToken string `mapstructure:"telegram-token"`
}

Secret is the structure representation of configuration from `config.yaml` file, at `secret` section. Secret keys, tokens,... can be putted here

type Telegram

type Telegram struct {
	LogChannelID int64 `mapstructure:"log-channel-id"`
	ErrChannelID int64 `mapstructure:"error-channel-id"`
}

Telegram is the structure representation of configuration from `config.yaml` file, at `telegram` section. It holds configuration of Telegram bot

type TelegramBot

type TelegramBot interface {
	SendTelegramLogMessage(msg string) (*tgbotapi.Message, error)
	SendTelegramErrorMessage(msg string) (*tgbotapi.Message, error)
	SendTelegramError(err error) (*tgbotapi.Message, error)
	SendTelegramMessage(c tgbotapi.Chattable) (*tgbotapi.Message, error)
	StopReceivingUpdates()

	WithLogger(logger logging.Logger) TelegramBot
	EnableDebug(debug bool) TelegramBot
}

func NewTelegramBot

func NewTelegramBot(token string, logChannelID, errChannelID int64) (TelegramBot, error)

Jump to

Keyboard shortcuts

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