config

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2025 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

View Source
const (
	EnvPrefix = "NODE"

	Environment = "environment"

	EnvironmentDevelopment = "development"
	EnvironmentProduction  = "production"

	EnvironmentPyroscopeEndpoint = EnvPrefix + "_PYROSCOPE_ENDPOINT"
)

Variables

This section is empty.

Functions

func CalculateWorkerCount

func CalculateWorkerCount(config *File) int

CalculateWorkerCount returns the number of workers deployed

func EvmAddressHookFunc

func EvmAddressHookFunc() mapstructure.DecodeHookFuncType

func HasOneWorker

func HasOneWorker(config *File) error

HasOneWorker Check if there is at least one worker deployed

func IsRSSOrAIComponentOnly

func IsRSSOrAIComponentOnly(config *File) bool

IsRSSOrAIComponentOnly Check if the configuration contains an RSS or AI component only

Types

type Component

type Component struct {
	RSS           *Module   `mapstructure:"rss"`
	Federated     []*Module `mapstructure:"federated" validate:"dive"`
	Decentralized []*Module `mapstructure:"decentralized" validate:"dive"`
	AI            *Module   `mapstructure:"ai"`
}

type Database

type Database struct {
	CoveragePeriod int    `mapstructure:"coverage_period" validate:"min=3,max=12" default:"3"`
	URI            string `mapstructure:"uri" validate:"required" default:"postgres://postgres@localhost:5432/postgres"`
}

type Discovery

type Discovery struct {
	Operator *Operator `mapstructure:"operator"`
	Server   *Server   `mapstructure:"server"`
}

type Endpoint

type Endpoint struct {
	URL           string            `mapstructure:"url"`
	HTTPHeaders   map[string]string `mapstructure:"http_headers"`
	HTTP2Disabled bool              `mapstructure:"http2_disabled"`
}

func (Endpoint) BuildEthereumOptions

func (e Endpoint) BuildEthereumOptions() []ethereum.Option

BuildEthereumOptions builds the custom options to be supplied to an ethereum client.

type File

type File struct {
	Environment   string              `mapstructure:"environment" validate:"required" default:"development"`
	Endpoints     map[string]Endpoint `mapstructure:"endpoints"`
	Discovery     *Discovery          `mapstructure:"discovery" validate:"required"`
	Component     *Component          `mapstructure:"component" validate:"required"`
	Database      *Database           `mapstructure:"database" validate:"required"`
	Stream        *Stream             `mapstructure:"stream"`
	Redis         *Redis              `mapstructure:"redis"`
	Observability *Telemetry          `mapstructure:"observability"`
}

func Setup

func Setup(configName string) (*File, error)

func (*File) LoadModulesEndpoint

func (f *File) LoadModulesEndpoint() error

LoadModulesEndpoint loads the endpoint url and headers for each module. If the endpoint id is not found in the endpoints list, it will use the endpoint id as the url.

type Module

type Module struct {
	ID           string          `mapstructure:"id"`
	Network      network.Network `mapstructure:"network"`
	EndpointID   string          `mapstructure:"endpoint"`
	IPFSGateways []string        `mapstructure:"ipfs_gateways"`
	Worker       worker.Worker   `mapstructure:"worker"`
	Parameters   *Parameters     `mapstructure:"parameters"`
	Endpoint     Endpoint        `mapstructure:"-"`
}

type OpenTelemetryConfig

type OpenTelemetryConfig struct {
	Metrics *OpenTelemetryMetricsConfig `mapstructure:"metrics" validate:"required"`
	Traces  *OpenTelemetryTracesConfig  `mapstructure:"traces" validate:"required"`
}

type OpenTelemetryMetricsConfig

type OpenTelemetryMetricsConfig struct {
	Enable   bool   `mapstructure:"enable" default:"false"`
	Endpoint string `mapstructure:"endpoint" default:"0.0.0.0:9090"`
}

type OpenTelemetryTracesConfig

type OpenTelemetryTracesConfig struct {
	Enable   bool   `mapstructure:"enable" default:"false"`
	Insecure bool   `mapstructure:"insecure" default:"false"`
	Endpoint string `mapstructure:"endpoint" validate:"required" default:"0.0.0.0:4318"`
}

type Operator

type Operator struct {
	EvmAddress common.Address `mapstructure:"evm_address"`
	Signature  string         `mapstructure:"signature"`
}

type Parameters

type Parameters map[string]any

func (*Parameters) Decode

func (p *Parameters) Decode(v interface{}) error

func (*Parameters) String

func (p *Parameters) String() string

type Redis

type Redis struct {
	Endpoint string   `mapstructure:"endpoint" default:"localhost:6379" validate:"required"`
	Username string   `mapstructure:"username"`
	Password string   `mapstructure:"password"`
	TLS      RedisTLS `mapstructure:"tls"`
}

type RedisTLS

type RedisTLS struct {
	Enabled            bool   `mapstructure:"enabled" default:"false"`
	CAFile             string `mapstructure:"ca_file"`
	CertFile           string `mapstructure:"cert_file"`
	KeyFile            string `mapstructure:"key_file"`
	InsecureSkipVerify bool   `mapstructure:"insecure_skip_verify" default:"false"`
}

type Server

type Server struct {
	Endpoint              string `mapstructure:"endpoint"`
	GlobalIndexerEndpoint string `mapstructure:"global_indexer_endpoint"`
	AccessToken           string `mapstructure:"access_token"`
}

type Stream

type Stream struct {
	Enable *bool  `mapstructure:"enable" validate:"required" default:"false"`
	URI    string `mapstructure:"uri" validate:"required" default:"localhost:9092"`
}

type Telemetry

type Telemetry struct {
	OpenTelemetry *OpenTelemetryConfig `mapstructure:"opentelemetry" validate:"required"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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