config

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: Apache-2.0 Imports: 4 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasQueueConfig added in v0.1.16

func HasQueueConfig(v *viper.Viper) bool

HasQueueConfig checks if any queue service is configured

Types

type Config

type Config struct {
	*Database  `yaml:"database" json:"database"`
	*Redis     `yaml:"redis" json:"redis"`
	*Search    `yaml:"search" json:"search"`
	*MongoDB   `yaml:"mongodb" json:"mongodb"`
	*Neo4j     `yaml:"neo4j" json:"neo4j"`
	*RabbitMQ  `yaml:"rabbitmq" json:"rabbitmq"`
	*Kafka     `yaml:"kafka" json:"kafka"`
	*Metrics   `yaml:"metrics" json:"metrics"`
	*Messaging `yaml:"messaging" json:"messaging"`
}

Config data config struct

func GetConfig

func GetConfig(v *viper.Viper) *Config

GetConfig returns data config

type DBNode

type DBNode struct {
	Driver          string        `json:"driver" yaml:"driver"`
	Source          string        `json:"source" yaml:"source"`
	Logging         bool          `json:"logging" yaml:"logging"`
	MaxIdleConn     int           `json:"max_idle_conn" yaml:"max_idle_conn"`
	MaxOpenConn     int           `json:"max_open_conn" yaml:"max_open_conn"`
	ConnMaxLifeTime time.Duration `json:"conn_max_life_time" yaml:"conn_max_life_time"`
	Weight          int           `json:"weight" yaml:"weight"`
}

DBNode represents a single database node configuration

type Database

type Database struct {
	Master   *DBNode   `json:"master" yaml:"master"`
	Slaves   []*DBNode `json:"slaves" yaml:"slaves"`
	Migrate  bool      `json:"migrate" yaml:"migrate"`
	Strategy string    `json:"strategy" yaml:"strategy"`
	MaxRetry int       `json:"max_retry" yaml:"max_retry"`
}

Database database config struct

type Elasticsearch

type Elasticsearch struct {
	Addresses []string `json:"addresses" yaml:"addresses"`
	Username  string   `json:"username" yaml:"username"`
	Password  string   `json:"password" yaml:"password"`
}

Elasticsearch elasticsearch config struct

type IndexSettings added in v0.1.17

type IndexSettings struct {
	Shards           int      `yaml:"shards" json:"shards"`
	Replicas         int      `yaml:"replicas" json:"replicas"`
	RefreshInterval  string   `yaml:"refresh_interval" json:"refresh_interval"`
	SearchableFields []string `yaml:"searchable_fields" json:"searchable_fields"`
	FilterableFields []string `yaml:"filterable_fields" json:"filterable_fields"`
}

IndexSettings represents default index configuration

type Kafka

type Kafka struct {
	Brokers        []string      `json:"brokers" yaml:"brokers"`
	ClientID       string        `json:"client_id" yaml:"client_id"`
	ConsumerGroup  string        `json:"consumer_group" yaml:"consumer_group"`
	Topic          string        `json:"topic" yaml:"topic"`
	ReadTimeout    time.Duration `json:"read_timeout" yaml:"read_timeout"`
	WriteTimeout   time.Duration `json:"write_timeout" yaml:"write_timeout"`
	ConnectTimeout time.Duration `json:"connect_timeout" yaml:"connect_timeout"`
}

Kafka kafka config struct

type Meilisearch

type Meilisearch struct {
	Host   string `json:"host" yaml:"host"`
	APIKey string `json:"api_key" yaml:"api_key"`
}

Meilisearch meilisearch config struct

type Messaging added in v0.1.15

type Messaging struct {
	Enabled          bool          `json:"enabled" yaml:"enabled"`
	PublishTimeout   time.Duration `json:"publish_timeout" yaml:"publish_timeout"`
	CrossRegionMode  bool          `json:"cross_region_mode" yaml:"cross_region_mode"`
	RetryAttempts    int           `json:"retry_attempts" yaml:"retry_attempts"`
	RetryBackoffMax  time.Duration `json:"retry_backoff_max" yaml:"retry_backoff_max"`
	FallbackToMemory bool          `json:"fallback_to_memory" yaml:"fallback_to_memory"`
}

Messaging config for all message channels

func (*Messaging) IsEnabled added in v0.1.16

func (m *Messaging) IsEnabled() bool

IsEnabled returns whether messaging is enabled

func (*Messaging) ShouldUseMemoryFallback added in v0.1.16

func (m *Messaging) ShouldUseMemoryFallback() bool

ShouldUseMemoryFallback returns whether to use memory fallback when queue is unavailable

type Metrics added in v0.1.5

type Metrics struct {
	Enabled       bool   `yaml:"enabled" json:"enabled"`
	StorageType   string `yaml:"storage_type" json:"storage_type"` // "memory", "redis"
	KeyPrefix     string `yaml:"key_prefix" json:"key_prefix"`
	RetentionDays int    `yaml:"retention_days" json:"retention_days"`
	BatchSize     int    `yaml:"batch_size" json:"batch_size"`
}

Metrics data metrics config

type MongoDB

type MongoDB struct {
	Master   *MongoNode   `json:"master" yaml:"master"`
	Slaves   []*MongoNode `json:"slaves" yaml:"slaves"`
	Strategy string       `json:"strategy" yaml:"strategy"`
	MaxRetry int          `json:"max_retry" yaml:"max_retry"`
}

MongoDB mongodb config struct

type MongoNode

type MongoNode struct {
	URI     string `json:"uri" yaml:"uri"`
	Logging bool   `json:"logging" yaml:"logging"`
	Weight  int    `json:"weight" yaml:"weight"`
}

MongoNode mongodb node config

type Neo4j

type Neo4j struct {
	URI      string `json:"uri" yaml:"uri"`
	Username string `json:"username" yaml:"username"`
	Password string `json:"password" yaml:"password"`
}

Neo4j neo4j config struct

type OpenSearch added in v0.1.4

type OpenSearch struct {
	Addresses       []string `json:"addresses" yaml:"addresses"`
	Username        string   `json:"username" yaml:"username"`
	Password        string   `json:"password" yaml:"password"`
	InsecureSkipTLS bool     `json:"insecure_skip_tls" yaml:"insecure_skip_tls"`
}

OpenSearch opensearch config struct

type RabbitMQ

type RabbitMQ struct {
	URL               string        `json:"url" yaml:"url"`
	Username          string        `json:"username" yaml:"username"`
	Password          string        `json:"password" yaml:"password"`
	Vhost             string        `json:"vhost" yaml:"vhost"`
	ConnectionTimeout time.Duration `json:"connection_timeout" yaml:"connection_timeout"`
	HeartbeatInterval time.Duration `json:"heartbeat_interval" yaml:"heartbeat_interval"`
}

RabbitMQ rabbitmq config struct

type Redis

type Redis struct {
	Addr         string        `json:"addr" yaml:"addr"`
	Username     string        `json:"username" yaml:"username"`
	Password     string        `json:"password" yaml:"password"`
	Db           int           `json:"db" yaml:"db"`
	ReadTimeout  time.Duration `json:"read_timeout" yaml:"read_timeout"`
	WriteTimeout time.Duration `json:"write_timeout" yaml:"write_timeout"`
	DialTimeout  time.Duration `json:"dial_timeout" yaml:"dial_timeout"`
}

Redis redis config struct

type Search struct {
	IndexPrefix     string         `yaml:"index_prefix" json:"index_prefix"`
	DefaultEngine   string         `yaml:"default_engine" json:"default_engine"`
	AutoCreateIndex bool           `yaml:"auto_create_index" json:"auto_create_index"`
	IndexSettings   *IndexSettings `yaml:"index_settings" json:"index_settings"`
	Meilisearch     *Meilisearch   `yaml:"meilisearch" json:"meilisearch"`
	Elasticsearch   *Elasticsearch `yaml:"elasticsearch" json:"elasticsearch"`
	OpenSearch      *OpenSearch    `yaml:"opensearch" json:"opensearch"`
}

Search represents search engine configuration

Jump to

Keyboard shortcuts

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