Documentation ¶
Index ¶
- Constants
- Variables
- func IsErrUpstreamRpcReturnedError(err error) bool
- func ParseJsonRpcResponse[T any](bz []byte) (any, error)
- type ChainConfig
- type ChainList
- type Config
- type Context
- func (c Context) Deadline() (deadline time.Time, ok bool)
- func (c Context) Done() <-chan struct{}
- func (c Context) Err() error
- func (c Context) GetConfig() Config
- func (c Context) GetDatabase() database.Database
- func (c Context) GetLogger() logging.Logger
- func (c Context) GetTelegramBot() TelegramBot
- func (c Context) Sealed() Context
- func (c Context) Value(key any) any
- func (c Context) WithConfig(cfg Config) Context
- func (c Context) WithDatabase(db database.Database) Context
- func (c Context) WithLogger(logger logging.Logger) Context
- func (c Context) WithTelegramBot(bot TelegramBot) Context
- type ContextKey
- type Endpoints
- type Indexing
- type JsonRpcQueryBuilder
- type JsonRpcQueryParam
- type Secret
- type Telegram
- type TelegramBot
Constants ¶
const AppContextKey = "be-indexer-context"
AppContextKey is the key in the context.Context which holds the application context.
Variables ¶
var ErrUpstreamRpcReturnedError = errors.New("upstream RPC returned error")
ErrUpstreamRpcReturnedError is the error when the upstream RPC returned error
Functions ¶
func IsErrUpstreamRpcReturnedError ¶
IsErrUpstreamRpcReturnedError returns true if the error is built from upstream RPC response error, when error code is not zero.
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 ¶
LoadConfig load the configuration from `chains.yaml` file within the specified application's home directory
func (ChainList) PrintOptions ¶
func (cl ChainList) PrintOptions()
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 ¶
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
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 UnwrapIndexerContext ¶
func (Context) GetDatabase ¶
func (Context) GetTelegramBot ¶
func (c Context) GetTelegramBot() TelegramBot
func (Context) WithConfig ¶
func (Context) WithTelegramBot ¶
func (c Context) WithTelegramBot(bot TelegramBot) Context
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 ¶
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)