signoz/pkg/sqlstore/config.go
Nityananda Gohain 7a03a09ac1
fix: add migration and postgres provider (#7089)
* fix: move migrations to bun

* fix: use anonymous structs and move modes to types package

* fix: minor changes after tests

* fix: remove bun relations and add foreign keys

* fix: minor changes

* Update pkg/types/agent.go

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* fix: add migration and postgres provider

* fix: address minor comments

* fix: use bun create index

* fix: add migration

* fix: support for postgres in migrations

* Update pkg/sqlstore/pgstore/provider.go

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* Update pkg/sqlmigration/001_add_organization.go

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* fix: address comments

* fix: move max connection to base config

* fix: update scope

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-02-12 13:23:40 +00:00

53 lines
1.2 KiB
Go

package sqlstore
import (
"go.signoz.io/signoz/pkg/factory"
)
type Config struct {
// Provider is the provider to use.
Provider string `mapstructure:"provider"`
// Connection is the connection configuration.
Connection ConnectionConfig `mapstructure:",squash"`
// Sqlite is the sqlite configuration.
Sqlite SqliteConfig `mapstructure:"sqlite"`
// Postgres is the postgres configuration.
Postgres PostgresConfig `mapstructure:"postgres"`
}
type PostgresConfig struct {
// DSN is the database source name.
DSN string `mapstructure:"dsn"`
}
type SqliteConfig struct {
// Path is the path to the sqlite database.
Path string `mapstructure:"path"`
}
type ConnectionConfig struct {
// MaxOpenConns is the maximum number of open connections to the database.
MaxOpenConns int `mapstructure:"max_open_conns"`
}
func NewConfigFactory() factory.ConfigFactory {
return factory.NewConfigFactory(factory.MustNewName("sqlstore"), newConfig)
}
func newConfig() factory.Config {
return Config{
Provider: "sqlite",
Connection: ConnectionConfig{
MaxOpenConns: 100,
},
Sqlite: SqliteConfig{
Path: "/var/lib/signoz/signoz.db",
},
}
}
func (c Config) Validate() error {
return nil
}