config

package
v0.1.258 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const MAX_SLICE_LEN = 10

Variables

This section is empty.

Functions

func BindEnv

func BindEnv(path []string, val reflect.Value)

func IsIndex

func IsIndex(s string) bool

Types

type AppSync

type AppSync struct {
	// Security token for AppSync
	Token string

	// URL of the AppSync endpoint
	Url string

	// Num of workers that send GQL requests
	MaxWorkers int

	// Max num of requests in worker's queue
	MaxQueueSize int

	// Max time a request should be retried. 0 means no limit.
	BackoffMaxElapsedTime time.Duration

	// Max time between failed retries to save data.
	BackoffMaxInterval time.Duration
}

type Arweave

type Arweave struct {
	// URL to arweave.net
	NodeUrl string

	// Time limit for requests. The timeout includes connection time, any
	// redirects, and reading the response body
	RequestTimeout time.Duration

	// Miminum time a peer needs to answer in order to be considered responsive.
	// This should be much smaller than request timeout
	CheckPeerTimeout time.Duration

	// Maximum amount of time a dial will wait for a connect to complete.
	DialerTimeout time.Duration

	// Interval between keep-alive probes for an active network connection.
	DialerKeepAlive time.Duration

	// Maximum amount of time an idle (keep-alive) connection will remain idle before closing itself.
	IdleConnTimeout time.Duration

	// Maximum amount of time waiting to wait for a TLS handshake
	TLSHandshakeTimeout time.Duration

	// https://ar-io.zendesk.com/hc/en-us/articles/7595655106971-arweave-net-Rate-Limits
	// Time in which max num of requests is enforced
	LimiterInterval time.Duration

	// Max num requests to particular peer per interval
	LimiterBurstSize int

	// Limit is a float numbef = max frequency per second. Whenever a HTTP 429 Too Many Requests is received we multiply limit by this factor.
	// This way even if the limit is set too high eventually it'll get small enough.
	LimiterDecreaseFactor float64

	// How often limiters get decreased. This timeout won't allow sudden burst to decrease the limit too much
	LimiterDecreaseInterval time.Duration
}

type Bundler

type Bundler struct {
	// Disable polling mechanism
	PollerDisabled bool

	// How often to poll the database
	PollerInterval time.Duration

	// How long does it wait for the query response
	PollerTimeout time.Duration

	// Maksimum number of requests run in parallel
	PollerMaxParallelQueries int

	// Maksimum number of interactions updated in the database in one db transaction
	PollerMaxBatchSize int

	// Retry sending bundles to bundlr.network
	PollerRetryBundleAfter time.Duration

	// Max queries in the queue
	WorkerPoolQueueSize int

	// Maksimum number of interactions selected from the database in one db transaction
	PollerMaxDownloadedBatchSize int

	// How often notifier monitors the number of pending tx to bundle
	DBPollerInterval time.Duration

	// Switch off listening for async notifications
	NotifierDisabled bool

	// Maksimum number of workers that handle notifications
	NotifierWorkerPoolSize int

	// Maksimum notifications waiting in the queue
	NotifierWorkerQueueSize int

	// How many batches are confirmet in one transaction
	ConfirmerBatchSize int

	// How often are states updated in the database
	ConfirmerInterval time.Duration

	// Max time confirmer will try to insert a batch of data to the database
	// 0 means no limit
	// This should be 0,
	ConfirmerBackoffMaxElapsedTime time.Duration

	// Max time between retries to insert a batch of confirmations to  the database
	ConfirmerBackoffMaxInterval time.Duration

	// Number of workers that send bundles in parallel
	BundlerNumBundlingWorkers int
}

type Bundlr

type Bundlr struct {
	// List of urls that can be used, order matters
	Urls []string

	// Time limit for requests. The timeout includes connection time, any
	// redirects, and reading the response body
	RequestTimeout time.Duration

	// Miminum time a peer needs to answer in order to be considered responsive.
	// This should be much smaller than request timeout
	CheckPeerTimeout time.Duration

	// Maximum amount of time a dial will wait for a connect to complete.
	DialerTimeout time.Duration

	// Interval between keep-alive probes for an active network connection.
	DialerKeepAlive time.Duration

	// Maximum amount of time an idle (keep-alive) connection will remain idle before closing itself.
	IdleConnTimeout time.Duration

	// Maximum amount of time waiting to wait for a TLS handshake
	TLSHandshakeTimeout time.Duration

	// https://ar-io.zendesk.com/hc/en-us/articles/7595655106971-arweave-net-Rate-Limits
	// Time in which max num of requests is enforced
	LimiterInterval time.Duration

	// Max num requests to particular peer per interval
	LimiterBurstSize int

	// Wallet used to signing transactions
	Wallet string
}

type Checker

type Checker struct {
	// Minimal number of blocks to wait before checking the bundle
	MinConfirmationBlocks int64

	// Number of bundles to confirm in one run.
	MaxBundlesPerRun int

	// Number of workers that check bundles in parallel
	WorkerPoolSize int

	// Size of the queue for workers
	WorkerQueueSize int

	// How often for unfinished checks
	PollerInterval time.Duration

	// After this time retry checking the bundle
	PollerRetryCheckAfter time.Duration
}

type Config

type Config struct {
	// REST API address. API used for monitoring etc.
	RESTListenAddress string

	// Maximum time Syncer will be closing before stop is forced.
	StopTimeout time.Duration

	// Logging level
	LogLevel string

	Arweave               Arweave
	PeerMonitor           PeerMonitor
	TransactionDownloader TransactionDownloader
	NetworkMonitor        NetworkMonitor
	Syncer                Syncer
	Bundler               Bundler
	Bundlr                Bundlr
	Checker               Checker
	Database              Database
	Contract              Contract
	Redis                 []Redis
	AppSync               AppSync
	Forwarder             Forwarder
}

Config stores global configuration

func Default

func Default() (config *Config)

func Load

func Load(filename string) (config *Config, err error)

Load configuration from file and env

type Contract

type Contract struct {
	// Worker pool for fetching contact source and init state
	LoaderWorkerPoolSize int

	// Maksimum payloads in loader's queue
	LoaderWorkerQueueSize int

	// Possible contract source content types
	LoaderSupportedContentTypes []string

	// Max time confirmer will try to insert a batch of data to the database. 0 means no limit
	LoaderBackoffMaxElapsedTime time.Duration

	// Max time between retries to insert a batch of confirmations to  the database
	LoaderBackoffMaxInterval time.Duration

	// Acceptable duration for loading a single contract. After this time arweave client will be reset/
	LoaderBackoffAcceptableDuration time.Duration

	// Max time for a transaction to be downloaded. 0 means no limit
	TransactionMaxElapsedTime time.Duration

	// Max time between transaction download retries
	TransactionMaxInterval time.Duration

	// How many contracts are saved in one transaction
	StoreBatchSize int

	// How often is an insert triggered
	StoreInterval time.Duration

	// Max time store will try to insert a batch of data to the database
	// 0 means no limit
	// This should be 0,
	StoreBackoffMaxElapsedTime time.Duration

	// Max time between retries to insert a batch of confirmations to  the database
	StoreBackoffMaxInterval time.Duration

	// Max size of a message that can be published to Redis, in bytes. 10MB by default
	PublisherMaxMessageSize int

	// Saved contracts are published on this Redis channel
	PublisherRedisChannelName string

	// Saved contracts are published on this AppSync channel
	PublisherAppSyncChannelName string
}

type Database

type Database struct {
	Port              uint16
	Host              string
	User              string
	Password          string
	Name              string
	SslMode           string
	PingTimeout       time.Duration
	ClientKey         string
	ClientKeyPath     string
	ClientCert        string
	ClientCertPath    string
	CaCert            string
	CaCertPath        string
	MigrationUser     string
	MigrationPassword string

	// Connection configuration
	MaxOpenConns    int
	MaxIdleConns    int
	ConnMaxIdleTime time.Duration
	ConnMaxLifetime time.Duration
}

type Forwarder

type Forwarder struct {
	// How many L1 interactions are fetched from the DB at once
	FetcherBatchSize int

	// Interactions are saved to this Redis channel
	PublisherRedisChannelName string

	// How long to wait before after receiving a new block height before sending L1 interactions
	// This delay ensures sequencer finishes handling requests in time
	HeightDelay time.Duration
}

type NetworkMonitor

type NetworkMonitor struct {

	// Time between requests to the Warp's Gateway for network info
	Period time.Duration

	// Minimum amount of confirmations (blocks on top of the given block) that are required to consider
	// a given block as confirmed (i.e. not being a fork)
	RequiredConfirmationBlocks int64

	// URL of the node we're using to get the current block height.
	// It's the Warp's Gateway URL to avoid race conditions
	Url string
}

type PeerMonitor

type PeerMonitor struct {
	// Maximum time a peer is blacklisted.
	// Even after this duration is over it may take some time for the peer to be re-checked
	MaxTimeBlacklisted time.Duration

	// Maximum number of peers that can be removed from the blacklist
	// Peers that are blacklisted longer than `PeerMonitorMaxTimeBlacklisted` will get eventually re-used
	// To avoid spikes we can only remove at most this many peers from the blacklist in one try
	MaxPeersRemovedFromBlacklist int

	// Time between sending monitoring requests to peers
	// Peers are downloaded from the arweave API and checked in parallel by couple of workers
	Period time.Duration

	// Max number of peers that can be used for retrying requests
	MaxPeers int

	// Number of workers that check peers in parallel
	NumWorkers int

	// Number of peers pending verification in worker queue
	WorkerQueueSize int
}

type Redis

type Redis struct {
	Port     uint16
	Host     string
	User     string
	Password string
	DB       int

	// TLS configuration
	ClientKey  string
	ClientCert string
	CaCert     string
	EnableTLS  bool

	// Connection configuration
	MinIdleConns    int
	MaxIdleConns    int
	ConnMaxIdleTime time.Duration
	MaxOpenConns    int
	ConnMaxLifetime time.Duration

	// Publish backoff configuration, 0 is no limit
	MaxElapsedTime time.Duration
	MaxInterval    time.Duration

	// Num of workers that publish messages
	MaxWorkers int

	// Max num of requests in worker's queue
	MaxQueueSize int
}

type Syncer

type Syncer struct {
	// Max time for a transaction to be downloaded. 0 means no limit
	BlockMaxElapsedTime time.Duration

	// Max time between transaction download retries
	BlockMaxInterval time.Duration

	// Max time for a transaction to be downloaded. 0 means no limit
	TransactionMaxElapsedTime time.Duration

	// Max time between transaction download retries
	TransactionMaxInterval time.Duration

	// Num of Interactions that are stored in the Store
	// before being inserted into the database in one db transaction and batch.
	StoreBatchSize int

	// After this time all Interactions in Store will be inserted to the database.
	// This is to avoid keeping them in the service for too long when waiting to fill the batch.
	StoreMaxTimeInQueue time.Duration

	// Max time between failed retries to save data.
	StoreMaxBackoffInterval time.Duration
}

type TransactionDownloader

type TransactionDownloader struct {
	// Number of workers that download the transactions
	NumWorkers int

	// Max number of transactions that wait in the worker queue
	WorkerQueueSize int
}

Jump to

Keyboard shortcuts

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