dalgostore

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 12 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func (s *ProjectStore) DeleteEnvDbCatalog(context.Context, string, string, string) error

DeleteEnvDbCatalog is not implemented; see the package doc comment.

func (*ProjectStore) DeleteEnvDbServer

func (s *ProjectStore) DeleteEnvDbServer(context.Context, string, string) error

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

LoadBoard is not implemented; see the package doc comment.

func (*ProjectStore) LoadBoards

LoadBoards is not implemented; see the package doc comment.

func (*ProjectStore) LoadEntities

LoadEntities is not implemented; see the package doc comment.

func (*ProjectStore) LoadEntity

LoadEntity is not implemented; see the package doc comment.

func (*ProjectStore) LoadEnvDbCatalog

LoadEnvDbCatalog is not implemented; see the package doc comment.

func (*ProjectStore) LoadEnvDbCatalogs

LoadEnvDbCatalogs is not implemented; see the package doc comment.

func (*ProjectStore) LoadEnvDbServer

LoadEnvDbServer is not implemented; see the package doc comment.

func (*ProjectStore) LoadEnvDbServers

LoadEnvDbServers is not implemented; see the package doc comment.

func (*ProjectStore) LoadEnvironment

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

LoadEnvironments is not implemented; see the package doc comment.

func (*ProjectStore) LoadFolder

LoadFolder is not implemented; see the package doc comment.

func (*ProjectStore) LoadFolders

LoadFolders is not implemented; see the package doc comment.

func (*ProjectStore) LoadProjDbDriver

LoadProjDbDriver is not implemented; see the package doc comment.

func (*ProjectStore) LoadProjDbDrivers

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

LoadQueries is not implemented; see the package doc comment.

func (*ProjectStore) LoadQuery

LoadQuery is not implemented; see the package doc comment.

func (*ProjectStore) LoadRecordsetData

func (s *ProjectStore) LoadRecordsetData(context.Context, string) (datatug.Recordset, error)

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) SaveBoard

func (s *ProjectStore) SaveBoard(context.Context, *datatug.Board) error

SaveBoard is not implemented; see the package doc comment.

func (*ProjectStore) SaveEntity

func (s *ProjectStore) SaveEntity(context.Context, *datatug.Entity) error

SaveEntity is not implemented; see the package doc comment.

func (*ProjectStore) SaveEnvDbCatalog

SaveEnvDbCatalog is not implemented; see the package doc comment.

func (*ProjectStore) SaveEnvDbCatalogs

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

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

SaveProjDbDriver is not implemented; see the package doc comment.

func (*ProjectStore) SaveProject

func (s *ProjectStore) SaveProject(ctx context.Context, p *datatug.Project) error

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

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

func NewStore(db dal.DB, id string) *Store

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

func (s *Store) DeleteProject(ctx context.Context, id string) error

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

func (s *Store) GetProjects(ctx context.Context) ([]datatug.ProjectBrief, error)

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.

func (*Store) ID added in v0.39.0

func (s *Store) ID() string

ID returns the id of this store.

Jump to

Keyboard shortcuts

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