config

package
v0.0.0-...-9518a5e Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package config provides configuration structs for every service

Index

Constants

View Source
const (
	// DevelopmentRunMode is the run mode for a development environment.
	DevelopmentRunMode runMode = "development"
	// TestingRunMode is the run mode for a testing environment.
	TestingRunMode runMode = "testing"
	// ProductionRunMode is the run mode for a production environment.
	ProductionRunMode runMode = "production"
)

Variables

View Source
var (
	// Providers represents this package's offering to the dependency injector.
	Providers = wire.NewSet(
		ProvideDatabaseClient,
		wire.FieldsOf(
			new(*InstanceConfig),
			"Database",
			"Observability",
			"Meta",
			"Encoding",
			"Uploads",
			"Search",
			"Events",
			"Server",
			"Services",
		),
		wire.FieldsOf(
			new(*ServicesConfigurations),
			"Auth",
			"Frontend",
			"Webhooks",
			"Websockets",
			"Accounts",
			"Items",
		),
	)
)

Functions

func ProvideDatabaseClient

func ProvideDatabaseClient(ctx context.Context, logger logging.Logger, cfg *InstanceConfig) (database.DataManager, error)

ProvideDatabaseClient provides a database implementation dependent on the configuration. NOTE: you may be tempted to move this to the database/config package. This is a fool's errand.

Types

type InstanceConfig

type InstanceConfig struct {
	Events        msgconfig.Config       `json:"events" mapstructure:"events" toml:"events,omitempty"`
	Search        search.Config          `json:"search" mapstructure:"search" toml:"search,omitempty"`
	Encoding      encoding.Config        `json:"encoding" mapstructure:"encoding" toml:"encoding,omitempty"`
	Uploads       uploads.Config         `json:"uploads" mapstructure:"uploads" toml:"uploads,omitempty"`
	Observability observability.Config   `json:"observability" mapstructure:"observability" toml:"observability,omitempty"`
	Routing       routing.Config         `json:"routing" mapstructure:"routing" toml:"routing,omitempty"`
	Database      dbconfig.Config        `json:"database" mapstructure:"database" toml:"database,omitempty"`
	Meta          MetaSettings           `json:"meta" mapstructure:"meta" toml:"meta,omitempty"`
	Services      ServicesConfigurations `json:"services" mapstructure:"services" toml:"services,omitempty"`
	Server        server.Config          `json:"server" mapstructure:"server" toml:"server,omitempty"`
	// contains filtered or unexported fields
}

InstanceConfig configures an instance of the service. It is composed of all the other setting structs.

func (*InstanceConfig) EncodeToFile

func (cfg *InstanceConfig) EncodeToFile(path string, marshaller func(v interface{}) ([]byte, error)) error

EncodeToFile renders your config to a file given your favorite encoder.

func (*InstanceConfig) ValidateWithContext

func (cfg *InstanceConfig) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates a InstanceConfig struct.

type MetaSettings

type MetaSettings struct {
	RunMode runMode `json:"run_mode" mapstructure:"run_mode" toml:"run_mode,omitempty"`
	Debug   bool    `json:"debug" mapstructure:"debug" toml:"debug,omitempty"`
}

MetaSettings is primarily used for development.

func (MetaSettings) ValidateWithContext

func (s MetaSettings) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates an MetaSettings struct.

type ServicesConfigurations

type ServicesConfigurations struct {
	Items      itemsservice.Config      `json:"items" mapstructure:"items" toml:"items,omitempty"`
	Websockets websocketsservice.Config `json:"websockets" mapstructure:"websockets" toml:"websockets,omitempty"`
	Webhooks   webhooksservice.Config   `json:"webhooks" mapstructure:"webhooks" toml:"webhooks,omitempty"`
	Accounts   accountsservice.Config   `json:"accounts" mapstructure:"accounts" toml:"accounts,omitempty"`
	Auth       authservice.Config       `json:"auth" mapstructure:"auth" toml:"auth,omitempty"`
	Frontend   frontendservice.Config   `json:"frontend" mapstructure:"frontend" toml:"frontend,omitempty"`
	// contains filtered or unexported fields
}

ServicesConfigurations collects the various service configurations.

Jump to

Keyboard shortcuts

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