config

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	Key          string    `mapstructure:"key"`
	RateLimit    RateLimit `mapstructure:"rate_limit"`
	AllowedHosts []string  `mapstructure:"allowed_origins"`
	//todo: create rate limiter instances here
	RateLimiter *rate.Limiter
}

APIKey main apikey structure (user)

type Auth

type Auth struct {
	APIKeys []*APIKey `mapstructure:"api_keys"`
	// contains filtered or unexported fields
}

Auth main auth config structure

func ReadAuth

func ReadAuth(file string) (*Auth, error)

ReadAuth read auth (user) info from a yaml file

func (*Auth) Auth

func (a *Auth) Auth(key string) (apikey *APIKey, found bool)

Auth main authentication method, checks if key is valid & get api info

type Balancer

type Balancer struct {
	TotalTimeout time.Duration `mapstructure:"total_timeout"`
	NodeTimeOut  time.Duration `mapstructure:"node_timeout"`
}

Balancer main Balancer config struct

type Config

type Config struct {
	LoadedFile string
	Webserver  *Webserver `mapstructure:"webserver"`
	Balancer   *Balancer  `mapstructure:"balancer"`
	Nodes      []*Node    `mapstructure:"nodes"`
}

Config main config struct

func ReadConfig

func ReadConfig(file string) (*Config, error)

ReadConfig read config from a yaml file

type Node

type Node struct {
	Name      string    `mapstructure:"name"`
	Chain     string    `mapstructure:"chain"`
	Provider  string    `mapstructure:"provider"`
	Endpoint  string    `mapstructure:"endpoint"`
	Protocol  string    `mapstructure:"protocol"`
	RateLimit RateLimit `mapstructure:"rate_limit"`
}

Node main Node config struct

type RateLimit

type RateLimit struct {
	Per  time.Duration `mapstructure:"per"`
	Rate int           `mapstructure:"rate"`
}

RateLimit main RateLimit config struct

type Webserver

type Webserver struct {
	Addr        string        `mapstructure:"addr"`
	ReadTimeout time.Duration `mapstructure:"read_timeout"`
}

Webserver main Webserver config struct

Jump to

Keyboard shortcuts

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