Documentation
¶
Overview ¶
Package dalgostore implements storage.Store and datatug.ProjectStore over a caller-supplied dal.DB (dalgo-project-store plan): Store (store.go) creates, lists, opens and deletes projects in one store, and ProjectStore (this file) addresses one project in it. It depends on the github.com/dal-go/dalgo and github.com/dal-go/record interfaces only: no DALgo driver (dalgo2ingitdb, dalgo2ingitdb4github, dalgo2openvaultdb) is imported here, and no code in this package branches on which concrete driver backs db (REQ:project-store-is-a-dalgo-database). The driver is selected at the edge — whichever code constructs the dal.DB this package is handed (a later task in the plan).
Every DataTug record lives under the extension namespace ext/datatug/ (REQ:extension-namespace): a project's key path is ext/datatug/projects/<project-id>, and every project item nests below it (REQ:hierarchy-is-a-key-path).
Only the project record itself is implemented so far: Store's four members and ProjectStore's LoadProjectFile, LoadProject and SaveProject create, list, delete, read and write the record at that key path. Every other project-item collection (queries, boards, folders, entities, environments, env db servers/catalogs, project db drivers/servers, recordset definitions) is a stub that returns ErrNotImplemented; later tasks in the dalgo-project-store plan implement them one collection at a time. SaveProject and LoadProject also return ErrNotImplemented — writing or loading nothing — rather than silently dropping or omitting a collection they do not yet persist or load; see their doc comments.
Index ¶
- Variables
- type ProjectStore
- func (s *ProjectStore) DbServersStore(dbDriver string) datatug.ProjDbServersStore
- func (s *ProjectStore) DeleteBoard(context.Context, string) error
- func (s *ProjectStore) DeleteEntity(context.Context, string) error
- func (s *ProjectStore) DeleteEnvDbCatalog(context.Context, string, string, string) error
- func (s *ProjectStore) DeleteEnvDbServer(context.Context, string, string) error
- func (s *ProjectStore) DeleteEnvironment(context.Context, string) error
- func (s *ProjectStore) DeleteFolder(context.Context, string) error
- func (s *ProjectStore) DeleteProjDbDriver(context.Context, string) error
- func (s *ProjectStore) DeleteQuery(context.Context, string) error
- func (s *ProjectStore) LoadBoard(context.Context, string, ...datatug.StoreOption) (*datatug.Board, error)
- func (s *ProjectStore) LoadBoards(context.Context, ...datatug.StoreOption) (datatug.Boards, error)
- func (s *ProjectStore) LoadEntities(context.Context, ...datatug.StoreOption) (datatug.Entities, error)
- func (s *ProjectStore) LoadEntity(context.Context, string, ...datatug.StoreOption) (*datatug.Entity, error)
- func (s *ProjectStore) LoadEnvDbCatalog(context.Context, string, string, string, ...datatug.StoreOption) (datatug.DbCatalog, error)
- func (s *ProjectStore) LoadEnvDbCatalogs(context.Context, string, ...datatug.StoreOption) (datatug.DbCatalogs, error)
- func (s *ProjectStore) LoadEnvDbServer(context.Context, string, string, ...datatug.StoreOption) (*datatug.EnvDbServer, error)
- func (s *ProjectStore) LoadEnvDbServers(context.Context, string, ...datatug.StoreOption) (datatug.EnvDbServers, error)
- func (s *ProjectStore) LoadEnvironment(context.Context, string, ...datatug.StoreOption) (*datatug.Environment, error)
- func (s *ProjectStore) LoadEnvironmentSummary(context.Context, string) (*datatug.EnvironmentSummary, error)
- func (s *ProjectStore) LoadEnvironments(context.Context, ...datatug.StoreOption) (datatug.Environments, error)
- func (s *ProjectStore) LoadFolder(context.Context, string, ...datatug.StoreOption) (*datatug.Folder, error)
- func (s *ProjectStore) LoadFolders(context.Context, ...datatug.StoreOption) (datatug.Folders, error)
- func (s *ProjectStore) LoadProjDbDriver(context.Context, string, ...datatug.StoreOption) (*datatug.ProjDbDriver, error)
- func (s *ProjectStore) LoadProjDbDrivers(context.Context, ...datatug.StoreOption) (datatug.ProjDbDrivers, error)
- func (s *ProjectStore) LoadProject(ctx context.Context, o ...datatug.StoreOption) (*datatug.Project, error)
- func (s *ProjectStore) LoadProjectFile(ctx context.Context) (datatug.ProjectFile, error)
- func (s *ProjectStore) LoadQueries(context.Context, string, ...datatug.StoreOption) (*datatug.QueriesFolder, error)
- func (s *ProjectStore) LoadQuery(context.Context, string, ...datatug.StoreOption) (*datatug.QueryDef, error)
- func (s *ProjectStore) LoadRecordsetData(context.Context, string) (datatug.Recordset, error)
- func (s *ProjectStore) LoadRecordsetDefinition(context.Context, string, ...datatug.StoreOption) (*datatug.RecordsetDefinition, error)
- func (s *ProjectStore) LoadRecordsetDefinitions(context.Context, ...datatug.StoreOption) ([]*datatug.RecordsetDefinition, error)
- func (s *ProjectStore) ProjectID() string
- func (s *ProjectStore) SaveBoard(context.Context, *datatug.Board) error
- func (s *ProjectStore) SaveEntity(context.Context, *datatug.Entity) error
- func (s *ProjectStore) SaveEnvDbCatalog(context.Context, string, string, string, *datatug.DbCatalog) error
- func (s *ProjectStore) SaveEnvDbCatalogs(context.Context, string, string, string, datatug.DbCatalogs) error
- func (s *ProjectStore) SaveEnvDbServer(context.Context, string, *datatug.EnvDbServer) error
- func (s *ProjectStore) SaveEnvServers(context.Context, string, datatug.EnvDbServers) error
- func (s *ProjectStore) SaveEnvironment(context.Context, *datatug.Environment) error
- func (s *ProjectStore) SaveEnvironments(context.Context, datatug.Environments) error
- func (s *ProjectStore) SaveFolder(context.Context, string, *datatug.Folder) error
- func (s *ProjectStore) SaveFolders(context.Context, string, datatug.Folders) error
- func (s *ProjectStore) SaveProjDbDriver(context.Context, *datatug.ProjDbDriver, ...datatug.StoreOption) error
- func (s *ProjectStore) SaveProject(ctx context.Context, p *datatug.Project) error
- func (s *ProjectStore) SaveQuery(context.Context, *datatug.QueryDefWithFolderPath) error
- type Store
- func (s *Store) CreateProject(ctx context.Context, request dto.CreateProjectRequest) (*datatug.ProjectSummary, error)
- func (s *Store) DeleteProject(ctx context.Context, id string) error
- func (s *Store) GetProjectStore(projectID string) datatug.ProjectStore
- func (s *Store) GetProjects(ctx context.Context) ([]datatug.ProjectBrief, error)
- func (s *Store) ID() string
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = errors.New("dalgostore: not implemented")
ErrNotImplemented is returned by every ProjectStore member this package does not implement yet, and by SaveProject/LoadProject when the caller asks for more than the project record (see the package doc comment).
Functions ¶
This section is empty.
Types ¶
type ProjectStore ¶
type ProjectStore struct {
// contains filtered or unexported fields
}
ProjectStore is a datatug.ProjectStore backed by a dal.DB the caller constructs and hands in.
func NewProjectStore ¶
func NewProjectStore(db dal.DB, projectID string) *ProjectStore
NewProjectStore returns a ProjectStore for projectID backed by db. db is constructed by the caller — the edge (CLI or backend) — never by this package, so no driver is named here. Like filestore's own constructor (newFsProjectStore, pkg/storage/filestore/project_store.go:10-26), NewProjectStore assigns its arguments without validating them.
func (*ProjectStore) DbServersStore ¶
func (s *ProjectStore) DbServersStore(dbDriver string) datatug.ProjDbServersStore
DbServersStore returns a stub ProjDbServersStore for dbDriver; every member of it is not implemented (see the package doc comment).
func (*ProjectStore) DeleteBoard ¶
func (s *ProjectStore) DeleteBoard(context.Context, string) error
DeleteBoard is not implemented; see the package doc comment.
func (*ProjectStore) DeleteEntity ¶
func (s *ProjectStore) DeleteEntity(context.Context, string) error
DeleteEntity is not implemented; see the package doc comment.
func (*ProjectStore) DeleteEnvDbCatalog ¶
DeleteEnvDbCatalog is not implemented; see the package doc comment.
func (*ProjectStore) DeleteEnvDbServer ¶
DeleteEnvDbServer is not implemented; see the package doc comment.
func (*ProjectStore) DeleteEnvironment ¶
func (s *ProjectStore) DeleteEnvironment(context.Context, string) error
DeleteEnvironment is not implemented; see the package doc comment.
func (*ProjectStore) DeleteFolder ¶
func (s *ProjectStore) DeleteFolder(context.Context, string) error
DeleteFolder is not implemented; see the package doc comment.
func (*ProjectStore) DeleteProjDbDriver ¶
func (s *ProjectStore) DeleteProjDbDriver(context.Context, string) error
DeleteProjDbDriver is not implemented; see the package doc comment.
func (*ProjectStore) DeleteQuery ¶
func (s *ProjectStore) DeleteQuery(context.Context, string) error
DeleteQuery is not implemented; see the package doc comment.
func (*ProjectStore) LoadBoard ¶
func (s *ProjectStore) LoadBoard(context.Context, string, ...datatug.StoreOption) (*datatug.Board, error)
LoadBoard is not implemented; see the package doc comment.
func (*ProjectStore) LoadBoards ¶
func (s *ProjectStore) LoadBoards(context.Context, ...datatug.StoreOption) (datatug.Boards, error)
LoadBoards is not implemented; see the package doc comment.
func (*ProjectStore) LoadEntities ¶
func (s *ProjectStore) LoadEntities(context.Context, ...datatug.StoreOption) (datatug.Entities, error)
LoadEntities is not implemented; see the package doc comment.
func (*ProjectStore) LoadEntity ¶
func (s *ProjectStore) LoadEntity(context.Context, string, ...datatug.StoreOption) (*datatug.Entity, error)
LoadEntity is not implemented; see the package doc comment.
func (*ProjectStore) LoadEnvDbCatalog ¶
func (s *ProjectStore) LoadEnvDbCatalog(context.Context, string, string, string, ...datatug.StoreOption) (datatug.DbCatalog, error)
LoadEnvDbCatalog is not implemented; see the package doc comment.
func (*ProjectStore) LoadEnvDbCatalogs ¶
func (s *ProjectStore) LoadEnvDbCatalogs(context.Context, string, ...datatug.StoreOption) (datatug.DbCatalogs, error)
LoadEnvDbCatalogs is not implemented; see the package doc comment.
func (*ProjectStore) LoadEnvDbServer ¶
func (s *ProjectStore) LoadEnvDbServer(context.Context, string, string, ...datatug.StoreOption) (*datatug.EnvDbServer, error)
LoadEnvDbServer is not implemented; see the package doc comment.
func (*ProjectStore) LoadEnvDbServers ¶
func (s *ProjectStore) LoadEnvDbServers(context.Context, string, ...datatug.StoreOption) (datatug.EnvDbServers, error)
LoadEnvDbServers is not implemented; see the package doc comment.
func (*ProjectStore) LoadEnvironment ¶
func (s *ProjectStore) LoadEnvironment(context.Context, string, ...datatug.StoreOption) (*datatug.Environment, error)
LoadEnvironment is not implemented; see the package doc comment.
func (*ProjectStore) LoadEnvironmentSummary ¶
func (s *ProjectStore) LoadEnvironmentSummary(context.Context, string) (*datatug.EnvironmentSummary, error)
LoadEnvironmentSummary is not implemented; see the package doc comment.
func (*ProjectStore) LoadEnvironments ¶
func (s *ProjectStore) LoadEnvironments(context.Context, ...datatug.StoreOption) (datatug.Environments, error)
LoadEnvironments is not implemented; see the package doc comment.
func (*ProjectStore) LoadFolder ¶
func (s *ProjectStore) LoadFolder(context.Context, string, ...datatug.StoreOption) (*datatug.Folder, error)
LoadFolder is not implemented; see the package doc comment.
func (*ProjectStore) LoadFolders ¶
func (s *ProjectStore) LoadFolders(context.Context, ...datatug.StoreOption) (datatug.Folders, error)
LoadFolders is not implemented; see the package doc comment.
func (*ProjectStore) LoadProjDbDriver ¶
func (s *ProjectStore) LoadProjDbDriver(context.Context, string, ...datatug.StoreOption) (*datatug.ProjDbDriver, error)
LoadProjDbDriver is not implemented; see the package doc comment.
func (*ProjectStore) LoadProjDbDrivers ¶
func (s *ProjectStore) LoadProjDbDrivers(context.Context, ...datatug.StoreOption) (datatug.ProjDbDrivers, error)
LoadProjDbDrivers is not implemented; see the package doc comment.
func (*ProjectStore) LoadProject ¶
func (s *ProjectStore) LoadProject(ctx context.Context, o ...datatug.StoreOption) (*datatug.Project, error)
LoadProject reads the project record and returns a Project carrying it. Depth follows filestore's own convention (pkg/storage/filestore/store_loader.go:27): Depth()==0 — the default, when the caller passes no options — or a depth greater than 1 asks for the full project graph (sub-item collections included), which this package does not load yet. Rather than return a Project with those collections silently left empty, LoadProject returns ErrNotImplemented naming what it cannot load. Only an explicit datatug.Depth(1) — "just this record" — is served.
func (*ProjectStore) LoadProjectFile ¶
func (s *ProjectStore) LoadProjectFile(ctx context.Context) (datatug.ProjectFile, error)
LoadProjectFile reads the project record at ext/datatug/projects/<project-id>.
func (*ProjectStore) LoadQueries ¶
func (s *ProjectStore) LoadQueries(context.Context, string, ...datatug.StoreOption) (*datatug.QueriesFolder, error)
LoadQueries is not implemented; see the package doc comment.
func (*ProjectStore) LoadQuery ¶
func (s *ProjectStore) LoadQuery(context.Context, string, ...datatug.StoreOption) (*datatug.QueryDef, error)
LoadQuery is not implemented; see the package doc comment.
func (*ProjectStore) LoadRecordsetData ¶
LoadRecordsetData is not implemented; see the package doc comment.
func (*ProjectStore) LoadRecordsetDefinition ¶
func (s *ProjectStore) LoadRecordsetDefinition(context.Context, string, ...datatug.StoreOption) (*datatug.RecordsetDefinition, error)
LoadRecordsetDefinition is not implemented; see the package doc comment.
func (*ProjectStore) LoadRecordsetDefinitions ¶
func (s *ProjectStore) LoadRecordsetDefinitions(context.Context, ...datatug.StoreOption) ([]*datatug.RecordsetDefinition, error)
LoadRecordsetDefinitions is not implemented; see the package doc comment.
func (*ProjectStore) ProjectID ¶
func (s *ProjectStore) ProjectID() string
ProjectID returns the id of the project this store addresses.
func (*ProjectStore) SaveEntity ¶
SaveEntity is not implemented; see the package doc comment.
func (*ProjectStore) SaveEnvDbCatalog ¶
func (s *ProjectStore) SaveEnvDbCatalog(context.Context, string, string, string, *datatug.DbCatalog) error
SaveEnvDbCatalog is not implemented; see the package doc comment.
func (*ProjectStore) SaveEnvDbCatalogs ¶
func (s *ProjectStore) SaveEnvDbCatalogs(context.Context, string, string, string, datatug.DbCatalogs) error
SaveEnvDbCatalogs is not implemented; see the package doc comment.
func (*ProjectStore) SaveEnvDbServer ¶
func (s *ProjectStore) SaveEnvDbServer(context.Context, string, *datatug.EnvDbServer) error
SaveEnvDbServer is not implemented; see the package doc comment.
func (*ProjectStore) SaveEnvServers ¶
func (s *ProjectStore) SaveEnvServers(context.Context, string, datatug.EnvDbServers) error
SaveEnvServers is not implemented; see the package doc comment.
func (*ProjectStore) SaveEnvironment ¶
func (s *ProjectStore) SaveEnvironment(context.Context, *datatug.Environment) error
SaveEnvironment is not implemented; see the package doc comment.
func (*ProjectStore) SaveEnvironments ¶
func (s *ProjectStore) SaveEnvironments(context.Context, datatug.Environments) error
SaveEnvironments is not implemented; see the package doc comment.
func (*ProjectStore) SaveFolder ¶
SaveFolder is not implemented; see the package doc comment.
func (*ProjectStore) SaveFolders ¶
SaveFolders is not implemented; see the package doc comment.
func (*ProjectStore) SaveProjDbDriver ¶
func (s *ProjectStore) SaveProjDbDriver(context.Context, *datatug.ProjDbDriver, ...datatug.StoreOption) error
SaveProjDbDriver is not implemented; see the package doc comment.
func (*ProjectStore) SaveProject ¶
SaveProject writes the project record at ext/datatug/projects/<project-id>, matching filestore's own SaveProject semantics for the part this package implements:
- the whole project is validated first, exactly as filestore does (pkg/storage/filestore/store_project_saver.go:23, project.Validate());
- the fields persisted are exactly the ones filestore's saveProjectFile builds — ID, Title, Access, Repository and Created (pkg/storage/filestore/store_project_saver.go:133-149). Folder, tags and UserIDs are not part of the project record there, and are not carried here either;
- the assembled ProjectFile is validated again before being written, exactly as filestore's putProjectFile does (pkg/storage/filestore/store_project_saver.go:113-115).
Before any of that, SaveProject refuses a project whose ID does not match this store's own project ID with a typed validation.ErrBadFieldValue, and a project carrying data in a collection this package does not persist yet (queries, boards, entities, environments, db models or db drivers) with a wrapped ErrNotImplemented naming the collection — so nothing is silently dropped and nothing is written. Sub-item persistence is later work (see the package doc comment).
func (*ProjectStore) SaveQuery ¶
func (s *ProjectStore) SaveQuery(context.Context, *datatug.QueryDefWithFolderPath) error
SaveQuery is not implemented; see the package doc comment.
type Store ¶ added in v0.39.0
type Store struct {
// contains filtered or unexported fields
}
Store is a storage.Store backed by a dal.DB the caller constructs and hands in. It keeps many projects, each addressed at ext/datatug/projects/<project-id> (REQ:extension-namespace).
Store works over the DALgo interfaces alone and touches no file system: it runs unchanged on any backend a dal.DB can front. Installing the static inGitDB schema (ingitdbschema.WriteSchema) is deliberately not part of it — that is a property of a git-backed store root, known only to whoever opens the driver over that directory, and it is done there, before a Store is built on top.
func NewStore ¶ added in v0.39.0
NewStore returns a Store with the given store id backed by db. db is constructed by the caller — the edge (CLI or backend) — never by this package, so no driver is named here. Like filestore's own constructor (newStore, pkg/storage/filestore/store.go:57-62) and NewProjectStore above, NewStore assigns its arguments without validating them.
func (*Store) CreateProject ¶ added in v0.39.0
func (s *Store) CreateProject(ctx context.Context, request dto.CreateProjectRequest) (*datatug.ProjectSummary, error)
CreateProject creates a new DataTug project in this store: the request is validated (dto.CreateProjectRequest.Validate requires a store, an id and a title, and applies the project-id rules), its StoreID must name this store, and the project record is then inserted at ext/datatug/projects/<id>.
The id is the caller's: it addresses the project for the rest of its life and is never derived from the title here. The record is written with Insert, not Set, so creating a project whose id is taken fails with record.ErrRecordExists — naming the id — instead of overwriting the project that holds it.
The title is persisted with the record: GetProjects — here and in filestore alike — reads a project's title back out of the project record, so a created project that did not carry its title would list with no title at all.
Failure states. CreateProject is a single record insert in one transaction, and it rolls nothing back:
- a refusal before the insert (an invalid request, a request for another store, an invalid assembled record) writes nothing at all;
- a failed insert — a duplicate id, or a backend failure — leaves the store exactly as it was, because the transaction that carries it is the only write. Whatever the backend already held under that id (the project that caused a duplicate) is untouched, and a retry is safe;
- it does NOT install the inGitDB schema, create a directory, or initialise a store: a store whose schema was never installed fails here in whatever way its driver reports an unknown collection. See Store's own doc comment for where the schema install belongs.
func (*Store) DeleteProject ¶ added in v0.39.0
DeleteProject deletes the project record at ext/datatug/projects/<id>. Deleting a project that does not exist is not an error: DALgo's Deleter contract has no not-found signal, so this mirrors the delete-is-idempotent semantics every adapter implements.
Only the project record is deleted. This store persists no project-item collection yet (see the package doc comment), so a project it created has no sub-items to cascade to; once a collection is implemented, its records must be deleted here too.
func (*Store) GetProjectStore ¶ added in v0.39.0
func (s *Store) GetProjectStore(projectID string) datatug.ProjectStore
GetProjectStore returns the datatug.ProjectStore addressing projectID in this store, mirroring filestore's own GetProjectStore (pkg/storage/filestore/store.go:31-34): it builds the project store without checking that the project exists.
func (*Store) GetProjects ¶ added in v0.39.0
GetProjects lists the ext/datatug/projects collection and returns a brief per project record. Each brief carries what filestore's own GetProjects carries — id, title, access and repository (pkg/storage/filestore/store.go:40-59). The id comes from the record's key, the authority for it, exactly as LoadProjectFile takes it from the key rather than from the stored data: a record whose stored id disagrees with its key lists under the key's id.
TODO: GetProjects has no pagination — it reads every project record in the store into memory in one call, and the dal.IQueryBuilder Limit/Offset and cursor support it would need (StartFrom/StartAfter, Reader.Cursor) is not plumbed through storage.Store's signature, which returns a plain slice and takes no page. A store with many projects needs that signature widened before this can be paged.