diags/storage/storage.go

30 lines
540 B
Go
Raw Normal View History

2024-11-20 13:31:46 +00:00
package storage
import (
"fmt"
"github.com/spf13/viper"
)
type Storage interface {
CreateDiag(Diag) error
GetDiag(string) (*Diag, error)
GetDiags(namespaces []string) ([]Diag, error)
UpdateDiag(Diag) error}
type StorageImpl struct {
}
func NewStorage(cfg *viper.Viper) (Storage, error) {
var (
storage_type = cfg.GetString("storage.db.type")
)
switch storage_type {
case "mongodb":
s, err := NewMongoDBStorage(cfg)
return s, err
default:
return nil, fmt.Errorf("storage type %v is not supported", storage_type)
}
}