config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const RAND_INT_MAX = 9999999999

Maximum bound for random integer

View Source
const RAND_INT_MIN = 1000000000

Minimum bound for random integer

View Source
const STRING_LENGTH = 10

Length of random string

Variables

View Source
var DefaultConfig = Config{
	DBPath: fmt.Sprintf(
		"file::memory:?mode=memory&cache=shared&_auth&_auth_user=%s&_auth_pass=%s&_auth_salt=%s&_auth_crypt=sha512",
		__USERNAME__,
		__PASSWORD__,
		__SALT__),
	Timezone:              "UTC",
	LogLevel:              "SILENT",
	EnablePrintRoutes:     false,
	ReduceMemoryUsage:     true,
	DisableStartupMessage: true,
	Prefork:               false,
	BodyLimit:             4 * 1024 * 1024,
	Concurrency:           256 * 1024,
	ReadBufferSize:        4096,
	WriteBufferSize:       4096,
	ReadTimeout:           15,
	WriteTimeout:          15,
	IdleTimeout:           60,
}

DefaultConfig is the default configuration.

Functions

func RandomString

func RandomString() string

RandomString generates a random string

Types

type Config

type Config struct {
	// DBPath is the path to sqlite.
	DBPath string
	// Timezone is the timezone used for the database.
	Timezone string
	// LogLevel is the log level used for the database.
	LogLevel string
	// EnablePrintRoutes is the flag to enable print routes.
	EnablePrintRoutes bool
	// ReduceMemoryUsage is the flag to reduce memory usage.
	ReduceMemoryUsage bool
	// DisableStartupMessage is the flag to disable startup message.
	DisableStartupMessage bool
	// BodyLimit is the maximum request body size.
	BodyLimit int
	// Concurrency is the maximum number of concurrent connections.
	Concurrency int
	// ReadBufferSize is the maximum buffer size for reading.
	ReadBufferSize int
	// WriteBufferSize is the maximum buffer size for writing.
	WriteBufferSize int
	// ReadTimeout is the maximum duration for reading the entire request, including the body.
	ReadTimeout int
	// WriteTimeout is the maximum duration before timing out writes of the response.
	WriteTimeout int
	// IdleTimeout is the maximum amount of time to wait for the next request when keep-alives are enabled.
	IdleTimeout int
	// Prefork is the flag to enable prefork
	Prefork bool
}

func (*Config) SetBodyLimit

func (c *Config) SetBodyLimit(bodyLimit int)

It sets the maximum request body size.

func (*Config) SetConcurrency

func (c *Config) SetConcurrency(concurrency int)

It sets the maximum number of concurrent connections.

func (*Config) SetDBPath

func (c *Config) SetDBPath(dbPath string)

It sets the database path.

func (*Config) SetDisableStartMessage

func (c *Config) SetDisableStartMessage(disableStartupMessage bool)

It sets the flag to disable startup message.

func (*Config) SetEnablePrintRoutes

func (c *Config) SetEnablePrintRoutes(enablePrintRoutes bool)

It sets the flag to enable print routes.

func (*Config) SetIdleTimeout

func (c *Config) SetIdleTimeout(idleTimeout int)

It sets the maximum amount of time to wait for the next request when keep-alives are enabled.

func (*Config) SetLogLevel

func (c *Config) SetLogLevel(logLevel string)

It sets the log level.

func (*Config) SetPrefork

func (c *Config) SetPrefork(prefork bool)

It sets the flag to enable prefork.

func (*Config) SetReadBufferSize

func (c *Config) SetReadBufferSize(readBufferSize int)

It sets the maximum buffer size for reading.

func (*Config) SetReadTimeout

func (c *Config) SetReadTimeout(readTimeout int)

It sets the maximum duration for reading the entire request, including the body.

func (*Config) SetReduceMemoryUsage

func (c *Config) SetReduceMemoryUsage(reduceMemoryUsage bool)

It sets the flag to reduce memory usage.

func (*Config) SetTimezone

func (c *Config) SetTimezone(timezone string)

It sets the timezone.

func (*Config) SetWriteBufferSize

func (c *Config) SetWriteBufferSize(writeBufferSize int)

It sets the maximum buffer size for writing.

func (*Config) SetWriteTimeout

func (c *Config) SetWriteTimeout(writeTimeout int)

It sets the maximum duration before timing out writes of the response.

Jump to

Keyboard shortcuts

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