config

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RetrievalPricingDefault configures the node to use the default retrieval pricing policy.
	RetrievalPricingDefaultMode = "default"
	// RetrievalPricingExternal configures the node to use the external retrieval pricing script
	// configured by the user.
	RetrievalPricingExternalMode = "external"
)

Variables

View Source
var Doc = map[string][]DocField{
	"CandidateCfg": []DocField{
		{
			Name: "WebRedirect",
			Type: "string",

			Comment: ``,
		},
		{
			Name: "ExternalURL",
			Type: "string",

			Comment: ``,
		},
	},
	"EdgeCfg": []DocField{
		{
			Name: "ListenAddress",
			Type: "string",

			Comment: `host address and port the edge node api will listen on`,
		},
		{
			Name: "Timeout",
			Type: "string",

			Comment: `used when 'ListenAddress' is unspecified. must be a valid duration recognized by golang's time.ParseDuration function`,
		},
		{
			Name: "NodeID",
			Type: "string",

			Comment: `node id`,
		},
		{
			Name: "AreaID",
			Type: "string",

			Comment: `area id`,
		},
		{
			Name: "Secret",
			Type: "string",

			Comment: `used auth when connect to scheduler`,
		},
		{
			Name: "MetadataPath",
			Type: "string",

			Comment: `metadata path`,
		},
		{
			Name: "AssetsPaths",
			Type: "[]string",

			Comment: `assets path`,
		},
		{
			Name: "BandwidthUp",
			Type: "int64",

			Comment: `upload file bandwidth, unit is B/s`,
		},
		{
			Name: "BandwidthDown",
			Type: "int64",

			Comment: `download file bandwidth, unit is B/s`,
		},
		{
			Name: "Locator",
			Type: "bool",

			Comment: `if true, get scheduler url from locator`,
		},
		{
			Name: "InsecureSkipVerify",
			Type: "bool",

			Comment: `InsecureSkipVerify http3 client skip tls verify`,
		},
		{
			Name: "CertificatePath",
			Type: "string",

			Comment: `used for http3 server
be used if InsecureSkipVerify is true`,
		},
		{
			Name: "PrivateKeyPath",
			Type: "string",

			Comment: `used for http3 server
be used if InsecureSkipVerify is true`,
		},
		{
			Name: "CaCertificatePath",
			Type: "string",

			Comment: `self sign certificate, use for client`,
		},
		{
			Name: "PullBlockTimeout",
			Type: "int",

			Comment: `PullBlockTimeout get block timeout`,
		},
		{
			Name: "PullBlockRetry",
			Type: "int",

			Comment: `PullBlockRetry retry when get block failed`,
		},
		{
			Name: "PullBlockParallel",
			Type: "int",

			Comment: `PullBlockParallel the number of goroutine to pull block`,
		},
		{
			Name: "TCPSrvAddr",
			Type: "string",

			Comment: ``,
		},
		{
			Name: "IPFSAPIURL",
			Type: "string",

			Comment: ``,
		},
		{
			Name: "ValidateDuration",
			Type: "int",

			Comment: `seconds`,
		},
		{
			Name: "MaxSizeOfUploadFile",
			Type: "int",

			Comment: ``,
		},
		{
			Name: "Storage",
			Type: "int64",

			Comment: `Storage for use by node`,
		},
		{
			Name: "Memory",
			Type: "int64",

			Comment: `Memory for use by node`,
		},
		{
			Name: "CPU",
			Type: "int",

			Comment: `CPU for use by node`,
		},
		{
			Name: "Bandwidth",
			Type: "int64",

			Comment: `Bandwidth for use by node`,
		},
	},
	"LocatorCfg": []DocField{
		{
			Name: "ListenAddress",
			Type: "string",

			Comment: `host address and port the edge node api will listen on`,
		},
		{
			Name: "Timeout",
			Type: "string",

			Comment: `used when 'ListenAddress' is unspecified. must be a valid duration recognized by golang's time.ParseDuration function`,
		},
		{
			Name: "GeoDBPath",
			Type: "string",

			Comment: `geodb path`,
		},
		{
			Name: "InsecureSkipVerify",
			Type: "bool",

			Comment: `InsecureSkipVerify http3 client skip tls verify`,
		},
		{
			Name: "CertificatePath",
			Type: "string",

			Comment: `used for http3 server
be used if InsecureSkipVerify is false`,
		},
		{
			Name: "PrivateKeyPath",
			Type: "string",

			Comment: `used for http3 server
be used if InsecureSkipVerify is false`,
		},
		{
			Name: "CaCertificatePath",
			Type: "string",

			Comment: `self sign certificate, use for client`,
		},
		{
			Name: "EtcdAddresses",
			Type: "[]string",

			Comment: `etcd server addresses`,
		},
		{
			Name: "DefaultAreaID",
			Type: "string",

			Comment: ``,
		},
		{
			Name: "DNSServerAddress",
			Type: "string",

			Comment: ``,
		},
		{
			Name: "DNSRecords",
			Type: "map[string]string",

			Comment: ``,
		},
	},
	"MinioConfig": []DocField{
		{
			Name: "Endpoint",
			Type: "string",

			Comment: ``,
		},
		{
			Name: "AccessKeyID",
			Type: "string",

			Comment: ``,
		},
		{
			Name: "SecretAccessKey",
			Type: "string",

			Comment: ``,
		},
	},
	"SchedulerCfg": []DocField{
		{
			Name: "ExternalURL",
			Type: "string",

			Comment: `host external address and port`,
		},
		{
			Name: "ListenAddress",
			Type: "string",

			Comment: `host address and port the edge node api will listen on`,
		},
		{
			Name: "DatabaseAddress",
			Type: "string",

			Comment: `database address`,
		},
		{
			Name: "AreaID",
			Type: "string",

			Comment: `area id`,
		},
		{
			Name: "InsecureSkipVerify",
			Type: "bool",

			Comment: `InsecureSkipVerify skip tls verify`,
		},
		{
			Name: "CertificatePath",
			Type: "string",

			Comment: `used for http3 server
be used if InsecureSkipVerify is true`,
		},
		{
			Name: "PrivateKeyPath",
			Type: "string",

			Comment: `used for http3 server
be used if InsecureSkipVerify is true`,
		},
		{
			Name: "CaCertificatePath",
			Type: "string",

			Comment: `self sign certificate, use for client`,
		},
		{
			Name: "EnableValidation",
			Type: "bool",

			Comment: `config to enabled node validation, default: true`,
		},
		{
			Name: "EtcdAddresses",
			Type: "[]string",

			Comment: `etcd server addresses`,
		},
		{
			Name: "CandidateReplicas",
			Type: "int",

			Comment: `Number of candidate node replicas (does not contain 'seed')`,
		},
		{
			Name: "ValidatorRatio",
			Type: "float64",

			Comment: `Proportion of validator in candidate nodes (0 ~ 1)`,
		},
		{
			Name: "ValidatorBaseBwDn",
			Type: "int",

			Comment: `The base downstream bandwidth per validator window (unit : MiB)`,
		},
		{
			Name: "ValidationProfit",
			Type: "float64",

			Comment: `Increased profit after node validation passes`,
		},
		{
			Name: "WorkloadProfit",
			Type: "float64",

			Comment: `Increased profit after node workload passes`,
		},
		{
			Name: "ElectionCycle",
			Type: "int",

			Comment: `ElectionCycle cycle (Unit:day)`,
		},
		{
			Name: "NodeScoreLevel",
			Type: "map[string][]int",

			Comment: `Node score level scale
The key of map is the rank name, and the value of map is a int array containing two elements,
the first element of which is the minimum value of score,
and the second element is the maximum value of score. (scores out of 100)`,
		},
		{
			Name: "LevelSelectWeight",
			Type: "map[string]int",

			Comment: `Node level weight
The key of the map is the name of the level, and the value of the map is an int,
indicating how many select weight this level can get (the more select weight, the greater the probability of the node being selected)`,
		},
		{
			Name: "UserFreeStorageSize",
			Type: "int64",

			Comment: ``,
		},
		{
			Name: "UserVipStorageSize",
			Type: "int64",

			Comment: ``,
		},
		{
			Name: "LotusRPCAddress",
			Type: "string",

			Comment: ``,
		},
		{
			Name: "LotusToken",
			Type: "string",

			Comment: ``,
		},
		{
			Name: "EdgeDownloadRatio",
			Type: "float64",

			Comment: `The ratio of edge nodes returned to the user for download`,
		},
		{
			Name: "AssetPullTaskLimit",
			Type: "int",

			Comment: `Maximum number of concurrent asset pulls`,
		},
		{
			Name: "NatDetectConcurrency",
			Type: "int",

			Comment: ``,
		},
		{
			Name: "UploadAssetReplicaCount",
			Type: "int",

			Comment: `Default number of backups for user uploaded files`,
		},
		{
			Name: "UploadAssetExpiration",
			Type: "int",

			Comment: `Default expiration time for user uploaded files`,
		},
		{
			Name: "MaxCountOfVisitShareLink",
			Type: "int",

			Comment: `Non vip user`,
		},
		{
			Name: "Weight",
			Type: "int",

			Comment: `if the area has several scheduler, node will connect to the scheduler which weight is bigger`,
		},
		{
			Name: "MaxAPIKey",
			Type: "int",

			Comment: ``,
		},
	},
}
View Source
var MaxTraversalLinks uint64 = 32 * (1 << 20)

MaxTraversalLinks configures the maximum number of links to traverse in a DAG while calculating CommP and traversing a DAG with graphsync; invokes a budget on DAG depth and density.

Functions

func FromFile

func FromFile(path string, def interface{}) (interface{}, error)

FromFile loads config from a specified file overriding defaults specified in the def parameter. If file does not exist or is empty defaults are assumed.

func FromReader

func FromReader(reader io.Reader, def interface{}) (interface{}, error)

FromReader loads config from a reader instance.

func GenerateConfigComment

func GenerateConfigComment(t interface{}) ([]byte, error)

GenerateConfigComment generates a commented version of the specified configuration, with comments describing each configuration field.

func GenerateConfigUpdate

func GenerateConfigUpdate(cfgCur, cfgDef interface{}, comment bool) ([]byte, error)

GenerateConfigUpdate generates an updated configuration based on the current configuration and the specified defaults. If 'comment' is true, the updated configuration will contain comments describing each configuration field.

Types

type Bandwidth added in v0.1.11

type Bandwidth struct {
	// unit is MB/s
	BandwidthMB int64
	// upload file bandwidth, unit is MB/s
	BandwidthUp int64
	// download file bandwidth, unit is <B/s
	BandwidthDown int64
}

type Basic added in v0.1.11

type Basic struct {
	Token string
}

type CPU added in v0.1.11

type CPU struct {
	Cores int
}

type CandidateCfg

type CandidateCfg struct {
	EdgeCfg
	// metadata path
	MetadataPath string
	// assets path
	AssetsPaths []string
	MinioConfig
	WebRedirect string
	ExternalURL string
}

CandidateCfg candidate node config

func DefaultCandidateCfg

func DefaultCandidateCfg() *CandidateCfg

DefaultCandidateCfg returns the default candidate config

type DocField

type DocField struct {
	Name    string
	Type    string
	Comment string
}

type Duration

type Duration time.Duration

Duration is a wrapper type for time.Duration for decoding and encoding from/to TOML

func (Duration) MarshalText

func (dur Duration) MarshalText() ([]byte, error)

MarshalText implements interface for TOML encoding

func (*Duration) UnmarshalText

func (dur *Duration) UnmarshalText(text []byte) error

UnmarshalText implements interface for TOML decoding

type EdgeCfg

type EdgeCfg struct {
	Network Network
	// area id
	AreaID string
	// used auth when connect to scheduler
	Secret string
	// InsecureSkipVerify http3 client skip tls verify
	InsecureSkipVerify bool
	// used for http3 server
	// be used if InsecureSkipVerify is true
	CertificatePath string
	// used for http3 server
	// be used if InsecureSkipVerify is true
	PrivateKeyPath string
	// self sign certificate, use for client
	CaCertificatePath string
	TCPSrvAddr        string
	IPFSAPIURL        string
	// seconds
	ValidateDuration    int
	MaxSizeOfUploadFile int

	Puller Puller

	Bandwidth Bandwidth
	Storage   Storage
	Memory    Memory
	CPU       CPU
	Basic     Basic
}

EdgeCfg edge node config

func DefaultEdgeCfg

func DefaultEdgeCfg() *EdgeCfg

DefaultEdgeCfg returns the default edge config

type LocatorCfg

type LocatorCfg struct {
	// host address and port the edge node api will listen on
	ListenAddress string
	// used when 'ListenAddress' is unspecified. must be a valid duration recognized by golang's time.ParseDuration function
	Timeout string
	// geodb path
	GeoDBPath string
	// InsecureSkipVerify http3 client skip tls verify
	InsecureSkipVerify bool
	// used for http3 server
	// be used if InsecureSkipVerify is false
	CertificatePath string
	// used for http3 server
	// be used if InsecureSkipVerify is false
	PrivateKeyPath string
	// self sign certificate, use for client
	CaCertificatePath string
	// etcd server addresses
	EtcdAddresses          []string
	DefaultAreaID          string
	DNSServerAddress       string
	DNSRecords             map[string]string
	LoadBalanceExcludeArea []string
}

LocatorCfg locator config

func DefaultLocatorCfg

func DefaultLocatorCfg() *LocatorCfg

DefaultLocatorCfg returns the default locator config

type Memory added in v0.1.11

type Memory struct {
	MemoryGB int64
}

type MinioConfig added in v0.1.11

type MinioConfig struct {
	Endpoint        string
	AccessKeyID     string
	SecretAccessKey string
}

type Network added in v0.1.11

type Network struct {
	// host address and port the edge node api will listen on
	ListenAddress string
	// used when 'ListenAddress' is unspecified. must be a valid duration recognized by golang's time.ParseDuration function
	Timeout string
	// the url of locator
	LocatorURL string
}

type Puller added in v0.1.18

type Puller struct {
	// PullBlockTimeout get block timeout
	PullBlockTimeout int
	// PullBlockRetry retry when get block failed
	PullBlockRetry int
	// PullBlockParallel the number of goroutine to pull block
	PullBlockParallel int
}

type SchedulerCfg

type SchedulerCfg struct {
	// host external address and port
	ExternalURL string
	// host address and port the edge node api will listen on
	ListenAddress string
	// database address
	DatabaseAddress string
	// area id
	AreaID string
	// InsecureSkipVerify skip tls verify
	InsecureSkipVerify bool
	// used for http3 server
	// be used if InsecureSkipVerify is true
	CertificatePath string
	// used for http3 server
	// be used if InsecureSkipVerify is true
	PrivateKeyPath string
	// self sign certificate, use for client
	CaCertificatePath string
	// config to enabled node validation, default: true
	EnableValidation bool
	// etcd server addresses
	EtcdAddresses []string
	// Number of candidate node replicas (does not contain 'seed')
	CandidateReplicas int
	// Proportion of validator in candidate nodes (0 ~ 1)
	ValidatorRatio float64
	// The base downstream bandwidth per validator window (unit : MiB)
	ValidatorBaseBwDn int
	// Increased profit after node validation passes
	ValidationProfit float64
	// Increased profit after node workload passes
	WorkloadProfit float64
	// ElectionCycle cycle (Unit:Hour)
	ElectionCycle int
	// Node score level scale
	// The key of map is the rank name, and the value of map is a int array containing two elements,
	// the first element of which is the minimum value of score,
	// and the second element is the maximum value of score. (scores out of 100)
	NodeScoreLevel map[string][]int
	// Node level weight
	// The key of the map is the name of the level, and the value of the map is an int,
	// indicating how many select weight this level can get (the more select weight, the greater the probability of the node being selected)
	LevelSelectWeight map[string]int

	UserFreeStorageSize int64
	UserVipStorageSize  int64

	LotusRPCAddress string
	LotusToken      string

	// The ratio of edge nodes returned to the user for download
	EdgeDownloadRatio float64
	// Maximum number of concurrent asset pulls
	AssetPullTaskLimit int

	NatDetectConcurrency int
	// Default number of backups for user uploaded files
	UploadAssetReplicaCount int
	// Default expiration time for user uploaded files
	UploadAssetExpiration int // (Unit:day)
	// Non vip user
	MaxCountOfVisitShareLink int
	// if the area has several scheduler, node will connect to the scheduler which weight is bigger
	Weight                   int
	MaxAPIKey                int
	IPWhitelist              []string
	MaxNumberOfRegistrations int

	IPLimit            int
	FillAssetEdgeCount int64

	StorageCandidates []string

	L2ValidatorCount int
}

SchedulerCfg scheduler config

func DefaultSchedulerCfg

func DefaultSchedulerCfg() *SchedulerCfg

DefaultSchedulerCfg returns the default scheduler config

type Storage added in v0.1.11

type Storage struct {
	StorageGB int64
	Path      string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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