config

package
v0.2.0-beta Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version string = "development"

Functions

This section is empty.

Types

type Config

type Config struct {
	// DB contains database connection config.
	DB DB `json:"db"`
	// SocketFile contains path to socket.
	SocketFile string `json:"socket_file"`
	// Server contains API server config.
	Server *Server `json:"server"`
	// Invoker contains invoker config.
	Invoker *Invoker `json:"invoker"`
	// Storage contains configuration for storage.
	Storage *Storage `json:"storage"`
	// Security contains security config.
	Security *Security `json:"security"`
	// SMTP contains SMTP config.
	SMTP *SMTP `json:"smtp"`
	// LogLevel contains level of logging.
	//
	// You can use following values:
	//  * debug
	//  * info (default)
	//  * warn
	//  * error
	//  * off
	LogLevel LogLevel `json:"log_level,omitempty"`
}

Config stores configuration for Solve API and Invoker.

func LoadFromFile

func LoadFromFile(file string) (Config, error)

LoadFromFile loads configuration from json file.

type DB

type DB struct {
	// Options contains options for database driver.
	//
	// For SQLiteDriver field should contains SQLiteOptions.
	// For PostgresDriver field should contains PostgresOptions.
	Options any
}

DB stores configuration for database connection.

func (*DB) Create

func (c *DB) Create() (*gosql.DB, error)

Create creates database connection using current configuration.

func (DB) MarshalJSON

func (c DB) MarshalJSON() ([]byte, error)

func (*DB) UnmarshalJSON

func (c *DB) UnmarshalJSON(bytes []byte) error

UnmarshalJSON parses JSON to create appropriate connection configuration.

type DBDriver

type DBDriver string

DBDriver represents database driver name.

const (
	// SQLiteDriver represents SQLite driver.
	SQLiteDriver DBDriver = "sqlite"
	// PostgresDriver represents Postgres driver.
	PostgresDriver DBDriver = "postgres"
)

type Invoker

type Invoker struct {
	// Workers contains amount of parallel workers.
	Workers int `json:"workers"`
	// Safeexec contains config for safeexec binary.
	Safeexec Safeexec `json:"safeexec"`
}

Invoker contains invoker config.

type LocalStorageOptions

type LocalStorageOptions struct {
	FilesDir string `json:"files_dir"`
}

func (LocalStorageOptions) Driver

type LogLevel

type LogLevel log.Lvl

func (LogLevel) MarshalText

func (l LogLevel) MarshalText() ([]byte, error)

func (*LogLevel) UnmarshalText

func (l *LogLevel) UnmarshalText(text []byte) error

type PostgresOptions

type PostgresOptions struct {
	// Hosts contains list of hosts.
	Hosts []string `json:"hosts"`
	// User contains username of user.
	User string `json:"user"`
	// Password contains password of user.
	Password string `json:"password"`
	// Name contains name of database.
	Name string `json:"name"`
	// SSLMode contains sslmode configuration.
	SSLMode string `json:"sslmode"`
}

PostgresOptions stores Postgres connection options.

type S3StorageOptions

type S3StorageOptions struct {
	Region          string `json:"region"`
	AccessKeyID     string `json:"access_key_id"`
	SecretAccessKey string `json:"secret_access_key"`
	Endpoint        string `json:"endpoint"`
	Bucket          string `json:"bucket"`
	PathPrefix      string `json:"path_prefix,omitempty"`
	UsePathStyle    bool   `json:"use_path_style,omitempty"`
}

func (S3StorageOptions) Driver

func (o S3StorageOptions) Driver() StorageDriver

type SMTP

type SMTP struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	Email    string `json:"email"`
	Password string `json:"password"`
	Name     string `json:"name,omitempty"`
}

type SQLiteOptions

type SQLiteOptions struct {
	// Path contains path to SQLite database file.
	Path string `json:"path"`
}

SQLiteOptions stores SQLite connection options.

type Safeexec

type Safeexec struct {
	Path   string `json:"path"`
	Cgroup string `json:"cgroup"`
}

type Security

type Security struct {
	// PasswordSalt contains salt for password hashing.
	PasswordSalt string `json:"password_salt"`
}

Security contains security config.

type Server

type Server struct {
	// Host contains server host.
	Host string `json:"host"`
	// Port contains server port.
	Port int `json:"port"`
	// SiteURL contains site index url.
	SiteURL string `json:"site_url"`
}

Server contains server config.

func (Server) Address

func (s Server) Address() string

Address returns string representation of server address.

type Storage

type Storage struct {
	Options StorageOptions `json:"options"`
}

Storage contains storage config.

func (Storage) MarshalJSON

func (c Storage) MarshalJSON() ([]byte, error)

func (*Storage) UnmarshalJSON

func (c *Storage) UnmarshalJSON(bytes []byte) error

type StorageDriver

type StorageDriver string
const (
	LocalStorageDriver StorageDriver = "local"
	S3StorageDriver    StorageDriver = "s3"
)

type StorageOptions

type StorageOptions interface {
	Driver() StorageDriver
}

Jump to

Keyboard shortcuts

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