storage

package
v0.16.4 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 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 CreateFolderRequest

type CreateFolderRequest struct {
	Name string
	Path string
	Note string
}

func (CreateFolderRequest) Validate

func (v CreateFolderRequest) Validate() error

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 ProjectStoreRef

type ProjectStoreRef interface {
	ProjectStore() datatug.ProjectStore
}

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) (
		projectSummary *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