Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasQueueConfig ¶
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"`
*Space `yaml:"space" json:"space"` // optional; omit to disable Space-level isolation
}
Config data config struct
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 ¶
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 ¶
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) ShouldUseMemoryFallback ¶
ShouldUseMemoryFallback returns whether to use memory fallback when queue is unavailable
type Metrics ¶
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 ¶
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 ¶
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
type Space ¶ added in v0.2.5
type Space struct {
// Strategy selects the isolation model.
// "schema" – PostgreSQL schema-per-space via SET LOCAL search_path (recommended for PG)
// "database" – MySQL / PostgreSQL database-per-space with per-space connection pools
// "" – disabled (default; all Space-aware methods fall back to ordinary transactions)
Strategy string `json:"strategy" yaml:"strategy"`
// GlobalSchema is the PostgreSQL schema that holds shared (cross-space) tables
// such as users, auth tokens, and the spaces registry itself.
// Only relevant when Strategy is "schema". Defaults to "public".
GlobalSchema string `json:"global_schema" yaml:"global_schema"`
// SpacePrefix is prepended to the normalized space identifier to form the
// schema or database name (e.g. "space_" → schema "space_acme").
// Defaults to "space_".
SpacePrefix string `json:"space_prefix" yaml:"space_prefix"`
// MaxCachedPools is the maximum number of per-space connection pools kept
// open simultaneously. Excess pools are evicted using an LRU policy.
// Only relevant when Strategy is "database". Defaults to 100.
MaxCachedPools int `json:"max_cached_pools" yaml:"max_cached_pools"`
}
Space configures Space-level database isolation (multi-tenancy).
When Strategy is set, each Space operates in its own database namespace. Projects that do not need multi-tenancy can omit this section entirely.
YAML example (PostgreSQL schema-per-space):
data:
space:
strategy: schema
global_schema: public
space_prefix: space_
max_cached_pools: 200
YAML example (MySQL database-per-space):
data:
space:
strategy: database
space_prefix: space_
max_cached_pools: 100
func (*Space) EffectiveGlobalSchema ¶ added in v0.2.5
EffectiveGlobalSchema returns the global schema name, defaulting to "public".
func (*Space) EffectiveMaxCachedPools ¶ added in v0.2.5
EffectiveMaxCachedPools returns the max cached pools count, defaulting to 100.
func (*Space) EffectiveSpacePrefix ¶ added in v0.2.5
EffectiveSpacePrefix returns the space prefix, defaulting to "space_".