web_bootstrap

package module
v0.4.10 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: BSD-3-Clause Imports: 18 Imported by: 0

README

gouef/web-bootstrap

web-bootstrap

GoDoc GitHub stars Go Report Card codecov

Versions

Stable Version GitHub Release GitHub Release

Contributors

JanGalek actions-user dependabot[bot]

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Website  *BootstrapInterface
	DB       *o_gorm.DB
	Router   *router.Router
	Renderer renderer.Renderer
)

Functions

func IndexComma added in v0.4.0

func IndexComma(tag string) int

func ParseKnownAndCustom added in v0.4.0

func ParseKnownAndCustom(node *yaml.Node, out any, knownFields []string) (map[string]any, error)

func ParseKnownAndCustomAuto added in v0.4.0

func ParseKnownAndCustomAuto(node *yaml.Node, out any) (map[string]any, error)

func ParseScalarValue added in v0.4.0

func ParseScalarValue(s string) any

func ValueParse added in v0.4.0

func ValueParse(k any, node *yaml.Node) any

Types

type BootstrapInterface added in v0.2.3

type BootstrapInterface struct {
	// contains filtered or unexported fields
}

func Bootstrap

func Bootstrap() *BootstrapInterface

func NewBootstrap

func NewBootstrap() *BootstrapInterface

func (*BootstrapInterface) AddConfig added in v0.4.0

func (b *BootstrapInterface) AddConfig(path string) *BootstrapInterface

func (*BootstrapInterface) Boot added in v0.2.3

func (b *BootstrapInterface) Boot()

func (*BootstrapInterface) GetGorm added in v0.4.5

func (b *BootstrapInterface) GetGorm() *o_gorm.DB

func (*BootstrapInterface) GetRouter added in v0.2.3

func (b *BootstrapInterface) GetRouter() *router.Router

func (*BootstrapInterface) LoadConfiguration added in v0.4.0

func (b *BootstrapInterface) LoadConfiguration() *Config

func (*BootstrapInterface) LoadGorm added in v0.4.4

func (b *BootstrapInterface) LoadGorm(cfg *Config)

func (*BootstrapInterface) LoadRouter added in v0.4.4

func (b *BootstrapInterface) LoadRouter(cfg *Config)

func (*BootstrapInterface) Static added in v0.3.3

func (b *BootstrapInterface) Static(relativePath string, root string) *BootstrapInterface

type Ca added in v0.4.3

type Ca struct {
}

type CacheConfig added in v0.4.0

type CacheConfig struct {
	Storages []CacheStorageItemConfig `yaml:"storages"`
	Custom   Custom
}

func (*CacheConfig) UnmarshalYAML added in v0.4.0

func (r *CacheConfig) UnmarshalYAML(value *yaml.Node) error

type CacheFileConfig added in v0.4.3

type CacheFileConfig struct {
	Name string `yaml:"name"`
	Dir  string `yaml:"dir"`
}

type CacheMemoryConfig added in v0.4.3

type CacheMemoryConfig struct {
	Name string `yaml:"name"`
}

type CacheRedisConfig added in v0.4.3

type CacheRedisConfig struct {
	Name    string            `yaml:"name"`
	Options CacheRedisOptions `yaml:"options"`
}

type CacheRedisOptions added in v0.4.3

type CacheRedisOptions struct {
	// The network type, either tcp or unix.
	// Default is tcp.
	Network string
	// host:port address.
	Addr string

	// ClientName will execute the `CLIENT SETNAME ClientName` command for each conn.
	ClientName string

	// Protocol 2 or 3. Use the version to negotiate RESP version with redis-server.
	// Default is 3.
	Protocol int
	// Use the specified Username to authenticate the current connection
	// with one of the connections defined in the ACL list when connecting
	// to a Redis 6.0 instance, or greater, that is using the Redis ACL system.
	Username string
	// Optional password. Must match the password specified in the
	// requirepass server configuration option (if connecting to a Redis 5.0 instance, or lower),
	// or the User Password when connecting to a Redis 6.0 instance, or greater,
	// that is using the Redis ACL system.
	Password string

	// Database to be selected after connecting to the server.
	DB int

	// Maximum number of retries before giving up.
	// Default is 3 retries; -1 (not 0) disables retries.
	MaxRetries int
	// Minimum backoff between each retry.
	// Default is 8 milliseconds; -1 disables backoff.
	MinRetryBackoff time.Duration
	// Maximum backoff between each retry.
	// Default is 512 milliseconds; -1 disables backoff.
	MaxRetryBackoff time.Duration

	// Dial timeout for establishing new connections.
	// Default is 5 seconds.
	DialTimeout time.Duration
	// Timeout for socket reads. If reached, commands will fail
	// with a timeout instead of blocking. Supported values:
	//   - `0` - default timeout (3 seconds).
	//   - `-1` - no timeout (block indefinitely).
	//   - `-2` - disables SetReadDeadline calls completely.
	ReadTimeout time.Duration
	// Timeout for socket writes. If reached, commands will fail
	// with a timeout instead of blocking.  Supported values:
	//   - `0` - default timeout (3 seconds).
	//   - `-1` - no timeout (block indefinitely).
	//   - `-2` - disables SetWriteDeadline calls completely.
	WriteTimeout time.Duration
	// ContextTimeoutEnabled controls whether the client respects context timeouts and deadlines.
	// See https://redis.uptrace.dev/guide/go-redis-debugging.html#timeouts
	ContextTimeoutEnabled bool

	// Type of connection pool.
	// true for FIFO pool, false for LIFO pool.
	// Note that FIFO has slightly higher overhead compared to LIFO,
	// but it helps closing idle connections faster reducing the pool size.
	PoolFIFO bool
	// Base number of socket connections.
	// Default is 10 connections per every available CPU as reported by runtime.GOMAXPROCS.
	// If there is not enough connections in the pool, new connections will be allocated in excess of PoolSize,
	// you can limit it through MaxActiveConns
	PoolSize int
	// Amount of time client waits for connection if all connections
	// are busy before returning an error.
	// Default is ReadTimeout + 1 second.
	PoolTimeout time.Duration
	// Minimum number of idle connections which is useful when establishing
	// new connection is slow.
	// Default is 0. the idle connections are not closed by default.
	MinIdleConns int
	// Maximum number of idle connections.
	// Default is 0. the idle connections are not closed by default.
	MaxIdleConns int
	// Maximum number of connections allocated by the pool at a given time.
	// When zero, there is no limit on the number of connections in the pool.
	MaxActiveConns int
	// ConnMaxIdleTime is the maximum amount of time a connection may be idle.
	// Should be less than server's timeout.
	//
	// Expired connections may be closed lazily before reuse.
	// If d <= 0, connections are not closed due to a connection's idle time.
	//
	// Default is 30 minutes. -1 disables idle timeout check.
	ConnMaxIdleTime time.Duration
	// ConnMaxLifetime is the maximum amount of time a connection may be reused.
	//
	// Expired connections may be closed lazily before reuse.
	// If <= 0, connections are not closed due to a connection's age.
	//
	// Default is to not close idle connections.
	ConnMaxLifetime time.Duration

	// TLS Config to use. When set, TLS will be negotiated.
	TLSConfig *tls.Config

	// Disable set-lib on connect. Default is false.
	DisableIndentity bool

	// Add suffix to client name. Default is empty.
	IdentitySuffix string

	// UnstableResp3 enables Unstable mode for Redis Search module with RESP3.
	UnstableResp3 bool
	// contains filtered or unexported fields
}

type CacheRedisOptionsTLS added in v0.4.3

type CacheRedisOptionsTLS struct {
}

type CacheStorageItemConfig added in v0.4.0

type CacheStorageItemConfig struct {
	Type     string            `yaml:"type"`
	Instance string            `yaml:"instance"`
	Name     string            `yaml:"name"`
	File     CacheFileConfig   `yaml:"file"`
	Memory   CacheMemoryConfig `yaml:"memory"`
	Redis    CacheRedisConfig  `yaml:"redis"`
	Custom   Custom
}

func (*CacheStorageItemConfig) UnmarshalYAML added in v0.4.0

func (r *CacheStorageItemConfig) UnmarshalYAML(value *yaml.Node) error

type CacheType added in v0.4.3

type CacheType string

type Config added in v0.4.0

type Config struct {
	Parameters map[string]any     `yaml:"parameters"`
	Renderer   RendererConfig     `yaml:"renderer"`
	Router     RouterConfig       `yaml:"router"`
	Cache      CacheConfig        `yaml:"cache"`
	Diago      DiagoConfig        `yaml:"diago"`
	Gorm       GormDatabaseConfig `yaml:"gorm"`
	Custom     Custom
}

func DefaultConfig added in v0.4.0

func DefaultConfig() *Config

func LoadConfig added in v0.4.0

func LoadConfig(path string) (*Config, error)

func (*Config) UnmarshalYAML added in v0.4.0

func (c *Config) UnmarshalYAML(value *yaml.Node) error

type ConfigInterface added in v0.4.0

type ConfigInterface interface {
	UnmarshalYAML(value *yaml.Node) error
}

type Custom added in v0.4.0

type Custom map[string]any

type DiagoConfig added in v0.4.0

type DiagoConfig struct {
	Enabled bool `yaml:"enabled"`
}

type GormDatabaseConfig added in v0.4.3

type GormDatabaseConfig struct {
	Driver          string                   `json:"driver" yaml:"driver" mapstructure:"driver"`
	Host            string                   `json:"host" yaml:"host" mapstructure:"host"`
	Port            int                      `json:"port" yaml:"port" mapstructure:"port"`
	User            string                   `json:"user" yaml:"user" mapstructure:"user"`
	Password        string                   `json:"password" yaml:"password" mapstructure:"password"`
	DBName          string                   `json:"dbname" yaml:"dbname" mapstructure:"dbname"`
	SSLMode         string                   `json:"sslmode" yaml:"sslmode" mapstructure:"sslmode"`
	TimeZone        string                   `json:"timezone" yaml:"timezone" mapstructure:"timezone"`
	MaxIdleConns    int                      `json:"max_idle_conns" yaml:"max_idle_conns" mapstructure:"max_idle_conns"`
	MaxOpenConns    int                      `json:"max_open_conns" yaml:"max_open_conns" mapstructure:"max_open_conns"`
	ConnMaxLifetime time.Duration            `json:"conn_max_lifetime" yaml:"conn_max_lifetime" mapstructure:"conn_max_lifetime"`
	Debug           bool                     `json:"debug" yaml:"debug" mapstructure:"debug"`
	Logger          GormDatabaseLoggerConfig `json:"logger" yaml:"logger" mapstructure:"logger"`
}

func (GormDatabaseConfig) ToGormConfig added in v0.4.3

func (db GormDatabaseConfig) ToGormConfig() *gorm.Config

type GormDatabaseLoggerConfig added in v0.4.7

type GormDatabaseLoggerConfig struct {
	SlowThreshold             time.Duration `json:"slow_threshold" yaml:"slow_threshold" mapstructure:"slow_threshold"`
	LogLevel                  string        `json:"log_level" yaml:"log_level" mapstructure:"log_level"`
	IgnoreRecordNotFoundError bool          `json:"ignore_record_not_found_error" yaml:"ignore_record_not_found_error" mapstructure:"ignore_record_not_found_error"`
	ParameterizedQueries      bool          `json:"parameterized_queries" yaml:"parameterized_queries" mapstructure:"parameterized_queries"`
	Colorful                  bool          `json:"colorful" yaml:"colorful" mapstructure:"colorful"`
}

type RendererConfig added in v0.4.0

type RendererConfig struct {
	Dir    string   `yaml:"dir"`
	Layout []string `yaml:"layout"`
	Custom Custom
}

func (*RendererConfig) UnmarshalYAML added in v0.4.0

func (c *RendererConfig) UnmarshalYAML(value *yaml.Node) error

type RouterConfig added in v0.4.0

type RouterConfig struct {
	Statics []RouterStaticConfig `yaml:"statics"`
	Proxy   RouterProxyConfig    `yaml:"proxy"`
	Custom  Custom
}

func (*RouterConfig) UnmarshalYAML added in v0.4.0

func (r *RouterConfig) UnmarshalYAML(value *yaml.Node) error

type RouterProxyConfig added in v0.4.0

type RouterProxyConfig struct {
	Trust  []string `yaml:"trust"`
	Custom Custom
}

type RouterStaticConfig added in v0.4.0

type RouterStaticConfig struct {
	Path   string `yaml:"path"`
	Root   string `yaml:"root"`
	Custom Custom
}

Jump to

Keyboard shortcuts

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