Help us shape the future of Go! Take the 2026 Go Developer Survey

dalgostore

package
v0.72.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 17 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. Boards and entities have bounded native and caller-scoped item persistence. Other project-item collections (queries, folders, 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

View Source
const MaxProjectAssetBytes = 256 << 10
View Source
const MaxProjectAssetListBytes = 2 << 20
View Source
const MaxProjectAssets = 100

Variables

View Source
var ErrAssetConflict = errors.New("project asset already exists or is duplicated")
View Source
var ErrAssetInvalid = errors.New("invalid project asset")
View Source
var ErrAssetLimit = errors.New("project asset limit exceeded")
View Source
var ErrAssetReadOnly = errors.New("project asset session is read-only")
View Source
var ErrAssetTransactionRequired = errors.New("project asset batch requires a readwrite transaction or database")
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 ProjectAssetBatch added in v0.65.0

type ProjectAssetBatch struct {
	Boards   datatug.Boards
	Entities datatug.Entities
}

ProjectAssetBatch contains canonical definitions to create, never overwrite. Boards and entities have separate ID namespaces and per-kind capacity bounds.

type ProjectItemsOption added in v0.67.0

type ProjectItemsOption func(*ProjectStore)

ProjectItemsOption supplies metadata already authorized and read by the caller.

func WithEnvironmentOrder added in v0.67.0

func WithEnvironmentOrder(order []string) ProjectItemsOption

WithEnvironmentOrder binds the parent order read in the caller-owned session. It never grants the item store permission to access the parent document.

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 NewProjectItemsStore added in v0.62.0

func NewProjectItemsStore(session dal.ReadSession, projectID string, root *record.Key, options ...ProjectItemsOption) (*ProjectStore, error)

NewProjectItemsStore scopes the real ProjectStore to caller-owned metadata. The caller derives root from authenticated authority; this constructor is deliberately incapable of reading or changing the parent project document. A DALGO transaction is used directly, without starting a nested transaction.

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) CreateAssets added in v0.65.0

func (s *ProjectStore) CreateAssets(ctx context.Context, batch ProjectAssetBatch) error

CreateAssets atomically creates a bounded batch in this store's existing scope. A DB-backed store owns the transaction. A caller-owned transaction is reused; the caller MUST propagate any error to its coordinator to roll back all writes. A bare readwrite session is refused because it cannot guarantee atomicity. All caller policy/receipt reads must precede this call. Inside the batch all validation, absence and capacity reads precede the first create-only Insert. Definitions are encoded before transaction callbacks and are not read again.

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(ctx context.Context, id string) error

func (*ProjectStore) DeleteCard added in v0.72.0

func (s *ProjectStore) DeleteCard(ctx context.Context, id string) error

func (*ProjectStore) DeleteEntity

func (s *ProjectStore) DeleteEntity(ctx context.Context, id string) error

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(ctx context.Context, id string) error

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(ctx context.Context, id string, _ ...datatug.StoreOption) (*datatug.Board, error)

func (*ProjectStore) LoadBoards

func (s *ProjectStore) LoadBoards(ctx context.Context, _ ...datatug.StoreOption) (datatug.Boards, error)

func (*ProjectStore) LoadCard added in v0.72.0

func (s *ProjectStore) LoadCard(ctx context.Context, id string, _ ...datatug.StoreOption) (*datatug.Card, error)

func (*ProjectStore) LoadCards added in v0.72.0

func (s *ProjectStore) LoadCards(ctx context.Context, _ ...datatug.StoreOption) (datatug.Cards, error)

func (*ProjectStore) LoadEntities

func (s *ProjectStore) LoadEntities(ctx context.Context, _ ...datatug.StoreOption) (datatug.Entities, error)

func (*ProjectStore) LoadEntity

func (s *ProjectStore) LoadEntity(ctx context.Context, id string, _ ...datatug.StoreOption) (*datatug.Entity, error)

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

func (s *ProjectStore) LoadEnvironment(ctx context.Context, id string, _ ...datatug.StoreOption) (*datatug.Environment, error)

func (*ProjectStore) LoadEnvironmentSummary

func (s *ProjectStore) LoadEnvironmentSummary(ctx context.Context, id string) (*datatug.EnvironmentSummary, error)

func (*ProjectStore) LoadEnvironments

func (s *ProjectStore) LoadEnvironments(ctx context.Context, _ ...datatug.StoreOption) (datatug.Environments, error)

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(ctx context.Context, value *datatug.Board) error

func (*ProjectStore) SaveCard added in v0.72.0

func (s *ProjectStore) SaveCard(ctx context.Context, value *datatug.Card) error

func (*ProjectStore) SaveEntity

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

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(ctx context.Context, v *datatug.Environment) error

func (*ProjectStore) SaveEnvironments

func (s *ProjectStore) SaveEnvironments(ctx context.Context, values datatug.Environments) error

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.

A project with boards or entities is refused before any deletion. Item cleanup is an explicit owning operation; parent deletion never orphans the supported asset collections or cascades away authored content.

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