pkgdash/storage/storage.go

36 lines
796 B
Go

package storage
import (
"context"
"database/sql"
"embed"
"go.unistack.org/unistack-org/pkgdash/models"
pb "go.unistack.org/unistack-org/pkgdash/proto/go_generate"
"go.unistack.org/unistack-org/pkgdash/storage/postgres"
cmsstorage "go.unistack.org/cms-service/storage"
)
//go:embed migrations
var fs embed.FS
var (
storages = cmsstorage.NewStorageInterface()
)
func init() {
storages.RegisterStorage("postgres", postgres.NewStorageFS(fs))
}
type Storage interface {
cmsstorage.Migrator
ListPackage(ctx context.Context) (models.ListPackage, error)
AddComment(ctx context.Context, rsp *pb.AddCommentRsp) error
AddPackage(ctx context.Context, rsp *pb.AddPackageRsp) error
}
func NewStorage(name string, db *sql.DB) (interface{}, error) {
return storages.NewStorage(name, db)
}