storage

package
v0.4.72 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 7 Imported by: 0

README

Code for storing & retrieving DataTug projects

  • filestore - stores to file system (folders & JSON files)

Documentation

Index

Constants

View Source
const SingleProjectID = "."

SingleProjectID defines a short version of project ID for a single project storage

Variables

View Source
var NewDatatugStore = func(id string) (Store, error) {
	panic("var 'NewDatatugStore' is not initialized")
}

NewDatatugStore creates new instance of Store for a specific storage

Functions

func ContextWithDatatugStore

func ContextWithDatatugStore(ctx context.Context, store Store) context.Context

func Init

func Init()

Types

type BoardsStore

type BoardsStore interface {
	ProjectStoreRef
	CreateBoard(ctx context.Context, board models.Board) (*models.Board, error)
	SaveBoard(ctx context.Context, board models.Board) (*models.Board, error)
	GetBoard(ctx context.Context, id string) (board *models.Board, err error)
	DeleteBoard(ctx context.Context, id string) (err error)
}

BoardsStore provides access to board records

type CreateFolderRequest

type CreateFolderRequest struct {
	Name string
	Path string
	Note string
}

func (CreateFolderRequest) Validate

func (v CreateFolderRequest) Validate() error

type DbCatalogStore

type DbCatalogStore interface {
	Catalogs() DbCatalogsStore
	LoadDbCatalogSummary(ctx context.Context) (catalog *models.DbCatalogSummary, err error)
}

type DbCatalogsStore

type DbCatalogsStore interface {
	Server() DbServerStore
	DbCatalog(id string) DbCatalogStore
}

type DbModelStore

type DbModelStore interface {
	ProjectStoreRef
	ID() string
	DbModels() DbModelsStore
}

type DbModelsStore

type DbModelsStore interface {
	DbModel(id string) DbModelStore
}

type DbServerStore

type DbServerStore interface {
	ID() models.ServerReference
	Catalogs() DbCatalogsStore

	// LoadDbServerSummary loads summary on DB server
	LoadDbServerSummary(ctx context.Context, dbServer models.ServerReference) (summary *models.ProjDbServerSummary, err error)
	SaveDbServer(ctx context.Context, dbServer models.ProjDbServer, project models.DatatugProject) (err error)
	DeleteDbServer(ctx context.Context, dbServer models.ServerReference) (err error)
}

type DbServersStore

type DbServersStore interface {
	ProjectStoreRef
	DbServer(id models.ServerReference) DbServerStore
}

type EntitiesStore

type EntitiesStore interface {
	ProjectStoreRef
	Entity(id string) EntityStore
	// LoadEntities loads entities
	LoadEntities(ctx context.Context) (entities models.Entities, err error)
}

type EntityStore

type EntityStore interface {
	ID() string
	Entities() EntitiesStore
	// LoadEntity loads entity
	LoadEntity(ctx context.Context) (entity *models.Entity, err error)
	DeleteEntity(ctx context.Context) (err error)
	SaveEntity(ctx context.Context, entity *models.Entity) (err error)
}

EntityStore defines DAL for entities

type EnvDbCatalogStore

type EnvDbCatalogStore interface {
	Catalogs() EnvDbCatalogsStore
	// LoadEnvironmentCatalog returns DB info for a specific environment
	LoadEnvironmentCatalog() (*models.EnvDb, error)
}

type EnvDbCatalogsStore

type EnvDbCatalogsStore interface {
	Catalog(id string) EnvDbCatalogStore
}

type EnvServerStore

type EnvServerStore interface {
	Catalogs() EnvDbCatalogsStore
	LoadEnvServer() (*models.EnvDbServer, error)
	SaveEnvServer(envServer *models.EnvDbServer) error
}

type EnvServersStore

type EnvServersStore interface {
	Server(id string) EnvServerStore
}

type EnvironmentStore

type EnvironmentStore interface {
	// ID returns environment ID
	ID() string

	Project() ProjectStore

	Servers() EnvServersStore

	// LoadEnvironmentSummary return summary metadata about environment
	LoadEnvironmentSummary() (*models.EnvironmentSummary, error)

	DeleteEnvironment() (err error)
	SaveEnvironment(environment *models.Environment) (err error)
}

EnvironmentStore provides access to environment record

type EnvironmentsLoader

type EnvironmentsLoader interface {
}

EnvironmentsLoader loads environments

type EnvironmentsSaver

type EnvironmentsSaver interface {
}

type EnvironmentsStore

type EnvironmentsStore interface {
	ProjectStoreRef
	Environment(id string) EnvironmentStore
}

type FoldersStore

type FoldersStore interface {
	CreateFolder(ctx context.Context, request CreateFolderRequest) (folder *models.Folder, err error)
	GetFolder(ctx context.Context, path string) (folder *models.Folder, err error)
	DeleteFolder(ctx context.Context, path string) (err error)
}

type ProjectStore

type ProjectStore interface {
	ProjectID() string
	Folders() FoldersStore
	Queries() QueriesStore
	Boards() BoardsStore

	Environments() EnvironmentsStore
	Entities() EntitiesStore
	DbModels() DbModelsStore
	DbServers() DbServersStore
	Recordsets() RecordsetsStore

	SaveProject(ctx context.Context, project models.DatatugProject) (err error)
	// LoadProject returns full DataTug project
	LoadProject(ctx context.Context) (*models.DatatugProject, error)

	// LoadProjectSummary return summary metadata about DataTug project
	LoadProjectSummary(ctx context.Context) (models.ProjectSummary, error)
}

type ProjectStoreRef

type ProjectStoreRef interface {
	Project() ProjectStore
}

type QueriesStore

type QueriesStore interface {
	ProjectStoreRef
	CreateQuery(ctx context.Context, query models.QueryDefWithFolderPath) (*models.QueryDefWithFolderPath, error)
	UpdateQuery(ctx context.Context, query models.QueryDef) (*models.QueryDefWithFolderPath, error)
	GetQuery(ctx context.Context, id string) (query *models.QueryDefWithFolderPath, err error)
	DeleteQuery(ctx context.Context, id string) (err error)
}

QueriesStore provides access to queries

type RecordsetLoader

type RecordsetLoader interface {
	// ID returns recordset id
	ID() string
	// LoadRecordsetDefinition loads recordset definition
	LoadRecordsetDefinition(ctx context.Context) (dataset *models.RecordsetDefinition, err error)
	// LoadRecordsetData loads recordset data
	LoadRecordsetData(ctx context.Context, fileName string) (recordset *models.Recordset, err error)
}

RecordsetLoader loads recordset data

type RecordsetsStore

type RecordsetsStore interface {
	ProjectStoreRef
	Recordset(id string) RecordsetLoader
	// LoadRecordsetDefinitions loads list of recordsets summary
	LoadRecordsetDefinitions(ctx context.Context) (datasets []*models.RecordsetDefinition, err error)
}

RecordsetsStore provides access to recordset records

type Store

type Store interface {
	GetProjectStore(projectID string) ProjectStore

	// CreateProject creates a new DataTug project
	CreateProject(ctx context.Context, request dto.CreateProjectRequest) (summary *models.ProjectSummary, err error)
	DeleteProject(ctx context.Context, id string) error

	// GetProjects returns list of projects
	GetProjects(ctx context.Context) (projectBriefs []models.ProjectBrief, err error)
}

Store defines interface for loading & saving DataTug projects Each store can keep multiple projects. Projects can be stored locally on file system or on server on some database.

var Current Store

Current holds currently active storage interface

TODO: to be replaced with `func NewDatatugStore(id string) Store`

func GetStore

func GetStore(ctx context.Context, id string) (Store, error)

func NewNoOpStore added in v0.3.0

func NewNoOpStore() Store

NewNoOpStore creates a DataTug store that panics in all methods

func StoreFromContext

func StoreFromContext(ctx context.Context) (Store, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL