config

package
v0.0.0-...-c72677e Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName           = "nodecore"
	DefaultConfigPath = "./nodecore.yml"
	ConfigPathVar     = "NODECORE_CONFIG_PATH"
)
View Source
const (
	DefaultLatencyPolicyFuncName          = "defaultLatencyPolicyFunc"
	DefaultLatencyErrorRatePolicyFuncName = "defaultLatencyErrorRatePolicyFunc"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiConnectorConfig

type ApiConnectorConfig struct {
	Type    ApiConnectorType  `yaml:"type"`
	Url     string            `yaml:"url"`
	Headers map[string]string `yaml:"headers,omitempty"`
	Ca      string            `yaml:"ca"`
}

type ApiConnectorType

type ApiConnectorType string
const (
	JsonRpc ApiConnectorType = "json-rpc"
	Rest    ApiConnectorType = "rest"
	Grpc    ApiConnectorType = "grpc"
	Ws      ApiConnectorType = "websocket"
)

type AppConfig

type AppConfig struct {
	ServerConfig      *ServerConfig            `yaml:"server"`
	UpstreamConfig    *UpstreamConfig          `yaml:"upstream-config"`
	CacheConfig       *CacheConfig             `yaml:"cache"`
	AuthConfig        *AuthConfig              `yaml:"auth"`
	RateLimit         []RateLimitBudgetsConfig `yaml:"rate-limit"`
	AppStorages       []AppStorageConfig       `yaml:"app-storages"`
	IntegrationConfig *IntegrationConfig       `yaml:"integration"`
}

func NewAppConfig

func NewAppConfig() (*AppConfig, error)

type AppStorageConfig

type AppStorageConfig struct {
	Name     string                 `yaml:"name"`
	Redis    *RedisStorageConfig    `yaml:"redis"`
	Postgres *PostgresStorageConfig `yaml:"postgres"`
}

type AuthConfig

type AuthConfig struct {
	Enabled               bool                   `yaml:"enabled"`
	RequestStrategyConfig *RequestStrategyConfig `yaml:"request-strategy"`
	KeyConfigs            []*KeyConfig           `yaml:"key-management"`
}

type AuthContracts

type AuthContracts struct {
	Allowed []string `yaml:"allowed"`
}

type AuthMethods

type AuthMethods struct {
	Allowed   []string `yaml:"allowed"`
	Forbidden []string `yaml:"forbidden"`
}

type CacheConfig

type CacheConfig struct {
	ReceiveTimeout  time.Duration           `yaml:"receive-timeout"`
	CacheConnectors []*CacheConnectorConfig `yaml:"connectors"`
	CachePolicies   []*CachePolicyConfig    `yaml:"policies"`
}

type CacheConnectorConfig

type CacheConnectorConfig struct {
	Id       string                        `yaml:"id"`
	Driver   CacheConnectorDriver          `yaml:"driver"`
	Redis    *RedisCacheConnectorConfig    `yaml:"redis"`
	Memory   *MemoryCacheConnectorConfig   `yaml:"memory"`
	Postgres *PostgresCacheConnectorConfig `yaml:"postgres"`
}

type CacheConnectorDriver

type CacheConnectorDriver string
const (
	Memory   CacheConnectorDriver = "memory"
	Redis    CacheConnectorDriver = "redis"
	Postgres CacheConnectorDriver = "postgres"
)

type CachePolicyConfig

type CachePolicyConfig struct {
	Id               string           `yaml:"id"`
	Chain            string           `yaml:"chain"`
	Method           string           `yaml:"method"`
	FinalizationType FinalizationType `yaml:"finalization-type"`
	CacheEmpty       bool             `yaml:"cache-empty"`
	Connector        string           `yaml:"connector-id"`
	ObjectMaxSize    string           `yaml:"object-max-size"`
	TTL              string           `yaml:"ttl"`
}

type ChainDefaults

type ChainDefaults struct {
	PollInterval time.Duration    `yaml:"poll-interval"`
	Options      *UpstreamOptions `yaml:"options"`
}

type DrpcIntegrationConfig

type DrpcIntegrationConfig struct {
	Url            string        `yaml:"url"`
	RequestTimeout time.Duration `yaml:"request-timeout"`
}

type DrpcKeyConfig

type DrpcKeyConfig struct {
	Owner *DrpcOwnerConfig `yaml:"owner"`
}

type DrpcOwnerConfig

type DrpcOwnerConfig struct {
	Id       string `yaml:"id"`
	ApiToken string `yaml:"api-token"`
}

type ExternalKeyConfig

type ExternalKeyConfig struct {
}

type FailsafeConfig

type FailsafeConfig struct {
	HedgeConfig   *HedgeConfig   `yaml:"hedge"`
	TimeoutConfig *TimeoutConfig `yaml:"timeout"`
	RetryConfig   *RetryConfig   `yaml:"retry"`
}

type FinalizationType

type FinalizationType string
const (
	Finalized FinalizationType = "finalized"
	None      FinalizationType = "none"
)

type HedgeConfig

type HedgeConfig struct {
	Delay time.Duration `yaml:"delay"`
	Count int           `yaml:"max"`
}

type IntegrationConfig

type IntegrationConfig struct {
	Drpc *DrpcIntegrationConfig `yaml:"drpc"`
}

type IntegrationKeyConfig

type IntegrationKeyConfig interface {
	// contains filtered or unexported methods
}

type IntegrityConfig

type IntegrityConfig struct {
	Enabled bool `yaml:"enabled"`
}

type JwtRequestStrategyConfig

type JwtRequestStrategyConfig struct {
	PublicKey          string `yaml:"public-key"`
	AllowedIssuer      string `yaml:"allowed-issuer"`
	ExpirationRequired bool   `yaml:"expiration-required"`
}

type KeyConfig

type KeyConfig struct {
	Id             string          `yaml:"id"`
	Type           KeyType         `yaml:"type"`
	LocalKeyConfig *LocalKeyConfig `yaml:"local"`
	DrpcKeyConfig  *DrpcKeyConfig  `yaml:"drpc"`
}

type KeySettingsConfig

type KeySettingsConfig struct {
	AllowedIps    []string       `yaml:"allowed-ips"`
	Methods       *AuthMethods   `yaml:"methods"`
	AuthContracts *AuthContracts `yaml:"contracts"`
	CorsOrigins   []string       `yaml:"cors-origins"`
}

type KeyType

type KeyType string
const (
	LocalKey KeyType = "local"
	DrpcKey  KeyType = "drpc"
)

type LocalKeyConfig

type LocalKeyConfig struct {
	Key               string             `yaml:"key"`
	KeySettingsConfig *KeySettingsConfig `yaml:"settings"`
}

type MemoryCacheConnectorConfig

type MemoryCacheConnectorConfig struct {
	MaxItems              int           `yaml:"max-items"`
	ExpiredRemoveInterval time.Duration `yaml:"expired-remove-interval"`
}

type MethodsConfig

type MethodsConfig struct {
	BanDuration    time.Duration `yaml:"ban-duration"`
	EnableMethods  []string      `yaml:"enable"`
	DisableMethods []string      `yaml:"disable"`
}

type PostgresCacheConnectorConfig

type PostgresCacheConnectorConfig struct {
	StorageName           string         `yaml:"storage-name"`
	QueryTimeout          *time.Duration `yaml:"query-timeout"`
	CacheTable            string         `yaml:"cache-table"`
	ExpiredRemoveInterval time.Duration  `yaml:"expired-remove-interval"`
}

type PostgresStorageConfig

type PostgresStorageConfig struct {
	Url string `yaml:"url"`
}

type PyroscopeConfig

type PyroscopeConfig struct {
	Enabled  bool   `yaml:"enabled"`
	Url      string `yaml:"url"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

func (*PyroscopeConfig) GetServerAddress

func (p *PyroscopeConfig) GetServerAddress() string

func (*PyroscopeConfig) GetServerPassword

func (p *PyroscopeConfig) GetServerPassword() string

func (*PyroscopeConfig) GetServerUsername

func (p *PyroscopeConfig) GetServerUsername() string

type RateLimitAutoTuneConfig

type RateLimitAutoTuneConfig struct {
	Enabled             bool          `yaml:"enabled"`
	Period              time.Duration `yaml:"period"`
	ErrorRateThreshold  float64       `yaml:"error-threshold"`
	InitRateLimit       int           `yaml:"init-rate-limit"`
	InitRateLimitPeriod time.Duration `yaml:"init-rate-limit-period"`
}

type RateLimitBudget

type RateLimitBudget struct {
	Name    string             `yaml:"name"`
	Storage string             `yaml:"storage"`
	Config  *RateLimiterConfig `yaml:"config"`
}

type RateLimitBudgetsConfig

type RateLimitBudgetsConfig struct {
	DefaultStorage string            `yaml:"default-engine"`
	Budgets        []RateLimitBudget `yaml:"budgets"`
}

type RateLimitEngine

type RateLimitEngine struct {
	Name  string                      `yaml:"name"`
	Type  string                      `yaml:"type"`
	Redis *RedisRateLimitEngineConfig `yaml:"redis"`
}

type RateLimitRule

type RateLimitRule struct {
	Method   string        `yaml:"method"`
	Pattern  string        `yaml:"pattern"`
	Requests int           `yaml:"requests"`
	Period   time.Duration `yaml:"period"`
}

type RateLimiterConfig

type RateLimiterConfig struct {
	Rules []RateLimitRule `yaml:"rules"`
}

type RedisCacheConnectorConfig

type RedisCacheConnectorConfig struct {
	StorageName string `yaml:"storage-name"`
}

type RedisRateLimitEngineConfig

type RedisRateLimitEngineConfig struct {
	StorageName string `yaml:"storage-name"`
}

type RedisStorageConfig

type RedisStorageConfig struct {
	FullUrl  string                      `yaml:"full-url"`
	Address  string                      `yaml:"address"`
	Username string                      `yaml:"username"`
	Password string                      `yaml:"password"`
	DB       *int                        `yaml:"db"`
	Timeouts *RedisStorageTimeoutsConfig `yaml:"timeouts"`
	Pool     *RedisStoragePoolConfig     `yaml:"pool"`
}

type RedisStoragePoolConfig

type RedisStoragePoolConfig struct {
	Size            int            `yaml:"size"`
	PoolTimeout     *time.Duration `yaml:"pool-timeout"`
	MinIdleConns    int            `yaml:"min-idle-conns"`
	MaxIdleConns    int            `yaml:"max-idle-conns"`
	MaxActiveConns  int            `yaml:"max-active-conns"`
	ConnMaxIdleTime *time.Duration `yaml:"conn-max-idle-time"`
	ConnMaxLifeTime *time.Duration `yaml:"conn-max-life-time"`
}

type RedisStorageTimeoutsConfig

type RedisStorageTimeoutsConfig struct {
	ConnectTimeout *time.Duration `yaml:"connect-timeout"`
	ReadTimeout    *time.Duration `yaml:"read-timeout"`
	WriteTimeout   *time.Duration `yaml:"write-timeout"`
}

type RequestStrategyConfig

type RequestStrategyConfig struct {
	Type                       RequestStrategyType         `yaml:"type"`
	TokenRequestStrategyConfig *TokenRequestStrategyConfig `yaml:"token"`
	JwtRequestStrategyConfig   *JwtRequestStrategyConfig   `yaml:"jwt"`
}

type RequestStrategyType

type RequestStrategyType string
const (
	Token RequestStrategyType = "token"
	Jwt   RequestStrategyType = "jwt"
)

type RetryConfig

type RetryConfig struct {
	Attempts int            `yaml:"attempts"`
	Delay    time.Duration  `yaml:"delay"`
	MaxDelay *time.Duration `yaml:"max-delay"`
	Jitter   *time.Duration `yaml:"jitter"`
}

type ScorePolicyConfig

type ScorePolicyConfig struct {
	CalculationInterval         time.Duration `yaml:"calculation-interval"`
	CalculationFunctionName     string        `yaml:"calculation-function-name"`      // a func name from a 'defaultRatingFunctions' map
	CalculationFunctionFilePath string        `yaml:"calculation-function-file-path"` // a path to the file with a function
	// contains filtered or unexported fields
}

func (*ScorePolicyConfig) GetScoreFunc

func (s *ScorePolicyConfig) GetScoreFunc() (goja.Callable, error)

type ServerConfig

type ServerConfig struct {
	Port            int              `yaml:"port"`
	MetricsPort     int              `yaml:"metrics-port"`
	PprofPort       int              `yaml:"pprof-port"`
	TlsConfig       *TlsConfig       `yaml:"tls"`
	PyroscopeConfig *PyroscopeConfig `yaml:"pyroscope-config"`
	TorUrl          string           `yaml:"tor-url"`
}

type TimeoutConfig

type TimeoutConfig struct {
	Timeout time.Duration `yaml:"duration"`
}

type TlsConfig

type TlsConfig struct {
	Enabled     bool   `yaml:"enabled"`
	Certificate string `yaml:"certificate"`
	Key         string `yaml:"key"`
	Ca          string `yaml:"ca"`
}

type TokenRequestStrategyConfig

type TokenRequestStrategyConfig struct {
	Value string `yaml:"value"`
}

type Upstream

type Upstream struct {
	Id                string                   `yaml:"id"`
	ChainName         string                   `yaml:"chain"`
	Connectors        []*ApiConnectorConfig    `yaml:"connectors"`
	HeadConnector     ApiConnectorType         `yaml:"head-connector"`
	PollInterval      time.Duration            `yaml:"poll-interval"`
	Methods           *MethodsConfig           `yaml:"methods"`
	FailsafeConfig    *FailsafeConfig          `yaml:"failsafe-config"`
	Options           *UpstreamOptions         `yaml:"options"`
	RateLimitBudget   string                   `yaml:"rate-limit-budget"`
	RateLimit         *RateLimiterConfig       `yaml:"rate-limit"`
	RateLimitAutoTune *RateLimitAutoTuneConfig `yaml:"rate-limit-auto-tune"`
}

type UpstreamConfig

type UpstreamConfig struct {
	Upstreams         []*Upstream               `yaml:"upstreams"`
	ChainDefaults     map[string]*ChainDefaults `yaml:"chain-defaults"`
	FailsafeConfig    *FailsafeConfig           `yaml:"failsafe-config"`
	ScorePolicyConfig *ScorePolicyConfig        `yaml:"score-policy-config"`
	IntegrityConfig   *IntegrityConfig          `yaml:"integrity"`
}

type UpstreamOptions

type UpstreamOptions struct {
	InternalTimeout           time.Duration `yaml:"internal-timeout"`
	ValidationInterval        time.Duration `yaml:"validation-interval"`
	DisableValidation         *bool         `yaml:"disable-validation"`
	DisableSettingsValidation *bool         `yaml:"disable-settings-validation"`
	DisableChainValidation    *bool         `yaml:"disable-chain-validation"`
}

Jump to

Keyboard shortcuts

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