Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
func Load[T Validatable]() (T, error)
Types ¶
type Config ¶
type Config struct {
Repo RepoConfig `mapstructure:"repo" toml:"repo"`
Gateway GatewayConfig `mapstructure:"gateway" toml:"gateway"`
Network NetworkConfig `mapstructure:"network" toml:"network"`
Upload UploadConfig `mapstructure:"upload" toml:"upload"`
}
type GatewayConfig ¶
type GatewayConfig struct {
// Port is the port to run the gateway on.
Port int `mapstructure:"port" flag:"port" toml:"port"`
// AdvertiseURL is the external HTTPS URL at which this gateway is reachable
// by peers (e.g. via an nginx TLS proxy). Used to construct the multiaddr
// advertised in delegated routing responses. Must be an HTTPS URL.
// Leave empty to disable routing responses.
AdvertiseURL string `mapstructure:"advertise_url" flag:"advertise-url" toml:"advertise_url"`
// BlockCacheCapacity defines the number of blocks to cache in memory. Blocks
// are typically <1MB due to IPFS chunking, so an upper bound for how much
// memory the cache will utilize is approximately this number multiplied by
// 1MB. e.g. capacity for 1,000 blocks ~= 1GB of memory.
BlockCacheCapacity int `mapstructure:"block_cache_capacity" flag:"block-cache-capacity" toml:"block_cache_capacity"`
// LogLevel sets the logging level for the gateway server (debug, info, warn
// or error).
LogLevel string `mapstructure:"log_level" flag:"log-level" toml:"log_level"`
// Subdomain configures subdomain gateway mode.
Subdomain SubdomainConfig `mapstructure:"subdomain" toml:"subdomain"`
// Trusted indicates whether to enable trusted gateway mode, which allows
// deserialized responses.
Trusted bool `mapstructure:"trusted" flag:"trusted" toml:"trusted"`
}
func (GatewayConfig) Validate ¶
func (c GatewayConfig) Validate() error
type NetworkConfig ¶ added in v0.5.1
type NetworkConfig struct {
// Name is the name of a preset network (forge, hot, warm-staging).
// If set, other fields override values from the preset.
Name string `mapstructure:"name" toml:"name"`
// UploadID is the DID of the upload service.
UploadID string `mapstructure:"upload_id" toml:"upload_id"`
// UploadURL is the URL of the upload service.
UploadURL string `mapstructure:"upload_url" toml:"upload_url"`
// ReceiptsURL is the URL of the receipts service.
ReceiptsURL string `mapstructure:"receipts_url" toml:"receipts_url"`
// IndexerID is the DID of the indexing service.
IndexerID string `mapstructure:"indexer_id" toml:"indexer_id"`
// IndexerURL is the URL of the indexing service.
IndexerURL string `mapstructure:"indexer_url" toml:"indexer_url"`
// AuthorizedRetrievals indicates whether UCAN authorized retrievals are supported.
// Use a pointer to distinguish between unset and false.
AuthorizedRetrievals *bool `mapstructure:"authorized_retrievals" toml:"authorized_retrievals"`
// InsecureDIDResolution enables HTTP (instead of HTTPS) for did:web resolution.
// NB: this should only be used for development purposes.
InsecureDIDResolution bool `mapstructure:"insecure_did_resolution" toml:"insecure_did_resolution,omitempty"`
}
NetworkConfig holds network-related configuration that can be specified in the config file. All fields are optional. If Name is set, it refers to a preset network configuration (forge, hot, warm-staging). Other fields can override individual values from the preset.
func (NetworkConfig) IsEmpty ¶ added in v0.5.1
func (n NetworkConfig) IsEmpty() bool
IsEmpty returns true if no network configuration fields are set.
func (NetworkConfig) ToPresetConfig ¶ added in v0.5.1
func (n NetworkConfig) ToPresetConfig(baseName string) (presets.NetworkConfig, error)
ToPresetConfig converts this config to a presets.NetworkConfig, using the specified base preset name as a starting point. If baseName is empty and this config's Name is also empty, the default network is used. Config values override preset values when set.
func (NetworkConfig) Validate ¶ added in v0.5.1
func (n NetworkConfig) Validate() error
Validate validates the network configuration.
type RepoConfig ¶ added in v0.5.0
type RepoConfig struct {
Dir string `mapstructure:"data_dir"`
DatabaseURL string `mapstructure:"database_url"`
}
func (RepoConfig) DatabasePath ¶ added in v0.5.0
func (r RepoConfig) DatabasePath() string
func (RepoConfig) IsPostgres ¶ added in v0.5.1
func (r RepoConfig) IsPostgres() bool
IsPostgres returns true if the configured database URL points to a PostgreSQL server.
func (RepoConfig) Validate ¶ added in v0.5.0
func (r RepoConfig) Validate() error
type SubdomainConfig ¶
type SubdomainConfig struct {
// Enabled indicates whether to enable subdomain gateway mode.
Enabled bool
// Hosts is the list of gateway hosts for subdomain mode.
Hosts []string
}
func (SubdomainConfig) Validate ¶
func (c SubdomainConfig) Validate() error
type UploadConfig ¶ added in v0.7.0
type UploadConfig struct {
// Number of replicas to request per shard. Cannot be greater than 3. Not
// recommended to set less than 3 except for testing purposes. Should be
// 1 or more if set.
Replicas uint `mapstructure:"replicas" toml:"replicas"`
}
func (UploadConfig) Validate ¶ added in v0.7.0
func (c UploadConfig) Validate() error
type Validatable ¶
type Validatable interface {
Validate() error
}