storage

package
v0.16.3 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 10 Imported by: 0

README

Code for storing & retrieving DataTug projects

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

Documentation

Overview

Package dtprojcreator is a generated GoMock package.

Index

Constants

View Source
const (
	RepoRootDataTugFileName = ".datatug.yaml"
	BoardsFolder            = "boards"
	ProjectSummaryFileName  = "datatug-project.json"
	DataFolder              = "data"
	DbsFolder               = "dbs"
	EnvDbCatalogsFolder     = "catalogs"
	DbModelsFolder          = "dbmodels"
	EntitiesFolder          = "entities"
	EnvironmentsFolder      = "environments"
	QueriesFolder           = "queries"
	RecordsetsFolder        = "recordsets"
	ServersFolder           = "servers"
	SchemasFolder           = "schemas"
)
View Source
const (
	BoardFileSuffix           = "board"
	DbCatalogFileSuffix       = "db"
	DbCatalogObjectFileSuffix = "objects"
	DbCatalogRefsFileSuffix   = "refs"
	DbModelFileSuffix         = "dbmodel"
	//DbSchemaFileSuffix        = "schema"
	DbServerFileSuffix  = "dbserver"
	RecordsetFileSuffix = "recordset"
	EntityFileSuffix    = "entity"
	ServerFileSuffix    = "server"
	ColumnsFileSuffix   = "columns"
	QueryFileSuffix     = "query"
)
View Source
const (
	EnvironmentSummaryFileName = "environment-summary.json"
)
View Source
const SingleProjectID = "."

SingleProjectID defines a short version of project GetID 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 GetProjItemIDFromFileName added in v0.15.12

func GetProjItemIDFromFileName(fileName string) (id string, suffix string)

func GetProjectStore added in v0.15.0

func GetProjectStore(ctx context.Context, storeID, projectID string) (datatug.ProjectStore, error)

func JsonFileName added in v0.15.12

func JsonFileName(id, suffix string) string

Types

type BoardsStore

type BoardsStore interface {
	ProjectStoreRef
	CreateBoard(ctx context.Context, board datatug.Board) (*datatug.Board, error)
	SaveBoard(ctx context.Context, board datatug.Board) (*datatug.Board, error)
	GetBoard(ctx context.Context, id string) (board *datatug.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 DbModelStore

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

type DbModelsStore

type DbModelsStore interface {
	DbModel(id string) DbModelStore
}

type DbServerStore

type DbServerStore interface {
	ID() datatug.ServerRef

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

type DbServersStore

type DbServersStore interface {
	ProjectStoreRef
	DbServer(id datatug.ServerRef) DbServerStore
}

type EntitiesStore

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

type EntityStore

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

EntityStore defines DAL for entities

type FileLoadError added in v0.15.0

type FileLoadError struct {
	FileName string `json:"fileName,omitempty"`
	Err      string `json:"err,omitempty"`
	// contains filtered or unexported fields
}

func NewFileLoadError added in v0.15.0

func NewFileLoadError(fileName string, err error) FileLoadError

func (FileLoadError) Error added in v0.15.0

func (e FileLoadError) Error() string

func (FileLoadError) String added in v0.15.0

func (e FileLoadError) String() string

type FilesLoadError added in v0.15.0

type FilesLoadError struct {
	// contains filtered or unexported fields
}

func NewFilesLoadError added in v0.15.0

func NewFilesLoadError(errs []FileLoadError) FilesLoadError

func (FilesLoadError) Error added in v0.15.0

func (e FilesLoadError) Error() string

func (FilesLoadError) Errors added in v0.15.0

func (e FilesLoadError) Errors() []FileLoadError

func (FilesLoadError) String added in v0.15.0

func (e FilesLoadError) String() string

type FoldersStore

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

type MockStorage added in v0.15.12

type MockStorage struct {
	// contains filtered or unexported fields
}

MockStorage is a mock of Storage interface.

func NewMockStorage added in v0.15.12

func NewMockStorage(ctrl *gomock.Controller) *MockStorage

NewMockStorage creates a new mock instance.

func (*MockStorage) Commit added in v0.15.12

func (m *MockStorage) Commit(ctx context.Context, message string) error

Commit mocks base method.

func (*MockStorage) EXPECT added in v0.15.12

func (m *MockStorage) EXPECT() *MockStorageMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockStorage) FileExists added in v0.15.12

func (m *MockStorage) FileExists(ctx context.Context, filePath string) (bool, error)

FileExists mocks base method.

func (*MockStorage) OpenFile added in v0.15.12

func (m *MockStorage) OpenFile(ctx context.Context, filePath string) (io.ReadCloser, error)

OpenFile mocks base method.

func (*MockStorage) WriteFile added in v0.15.12

func (m *MockStorage) WriteFile(ctx context.Context, filePath string, reader io.Reader) error

WriteFile mocks base method.

type MockStorageMockRecorder added in v0.15.12

type MockStorageMockRecorder struct {
	// contains filtered or unexported fields
}

MockStorageMockRecorder is the mock recorder for MockStorage.

func (*MockStorageMockRecorder) Commit added in v0.15.12

func (mr *MockStorageMockRecorder) Commit(ctx, message any) *gomock.Call

Commit indicates an expected call of Commit.

func (*MockStorageMockRecorder) FileExists added in v0.15.12

func (mr *MockStorageMockRecorder) FileExists(ctx, filePath any) *gomock.Call

FileExists indicates an expected call of FileExists.

func (*MockStorageMockRecorder) OpenFile added in v0.15.12

func (mr *MockStorageMockRecorder) OpenFile(ctx, filePath any) *gomock.Call

OpenFile indicates an expected call of OpenFile.

func (*MockStorageMockRecorder) WriteFile added in v0.15.12

func (mr *MockStorageMockRecorder) WriteFile(ctx, filePath, reader any) *gomock.Call

WriteFile indicates an expected call of WriteFile.

type ProjectStoreDeprecated added in v0.15.0

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

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

	SaveProject(ctx context.Context, project datatug.Project) (err error)

	// LoadProject returns full DataTug project
	LoadProject(ctx context.Context) (*datatug.Project, error)

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

ProjectStoreDeprecated Deprecated: Use datatug.ProjectStore instead

type ProjectStoreRef

type ProjectStoreRef interface {
	Project() datatug.ProjectStore
}

type QueriesStore

type QueriesStore interface {
	ProjectStoreRef
	CreateQuery(ctx context.Context, query datatug.QueryDefWithFolderPath) (*datatug.QueryDefWithFolderPath, error)
	UpdateQuery(ctx context.Context, query datatug.QueryDef) (*datatug.QueryDefWithFolderPath, error)
	GetQuery(ctx context.Context, id string) (query *datatug.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 *datatug.RecordsetDefinition, err error)
	// LoadRecordsetData loads recordset data
	LoadRecordsetData(ctx context.Context, fileName string) (recordset *datatug.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 []*datatug.RecordsetDefinition, err error)
}

RecordsetsStore provides access to recordset records

type Store

type Store interface {
	GetProjectStore(projectID string) datatug.ProjectStore

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

	// GetProjects returns list of projects
	GetProjects(ctx context.Context) (projectBriefs []datatug.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

func NewNoOpStore() Store

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