mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-10-13 04:21:31 +08:00

* feat(sqlmigration): add sqlmigrations * feat(sqlmigration): test sqlmigrations * feat(sqlmigration): add remaining factories * feat(sqlmigration): consolidate into single package * fix(telemetrystore): remove existing env variables * fix(telemetrystore): fix DSN
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package sqlite
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/jmoiron/sqlx"
|
|
basedao "go.signoz.io/signoz/pkg/query-service/dao"
|
|
basedsql "go.signoz.io/signoz/pkg/query-service/dao/sqlite"
|
|
baseint "go.signoz.io/signoz/pkg/query-service/interfaces"
|
|
)
|
|
|
|
type modelDao struct {
|
|
*basedsql.ModelDaoSqlite
|
|
flags baseint.FeatureLookup
|
|
}
|
|
|
|
// SetFlagProvider sets the feature lookup provider
|
|
func (m *modelDao) SetFlagProvider(flags baseint.FeatureLookup) {
|
|
m.flags = flags
|
|
}
|
|
|
|
// CheckFeature confirms if a feature is available
|
|
func (m *modelDao) checkFeature(key string) error {
|
|
if m.flags == nil {
|
|
return fmt.Errorf("flag provider not set")
|
|
}
|
|
|
|
return m.flags.CheckFeature(key)
|
|
}
|
|
|
|
// InitDB creates and extends base model DB repository
|
|
func InitDB(inputDB *sqlx.DB) (*modelDao, error) {
|
|
dao, err := basedsql.InitDB(inputDB)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
// set package variable so dependent base methods (e.g. AuthCache) will work
|
|
basedao.SetDB(dao)
|
|
m := &modelDao{ModelDaoSqlite: dao}
|
|
return m, nil
|
|
}
|
|
|
|
func (m *modelDao) DB() *sqlx.DB {
|
|
return m.ModelDaoSqlite.DB()
|
|
}
|