Documentation
¶
Overview ¶
Package mongodb provides Ridu's official MongoDB document store.
Index ¶
- func ProjectMigrations(transforms ...ridumigration.DataTransform) ridumigration.ProjectDriver
- func VerifyArtifacts(ctx context.Context, config Config, directory string, ...) error
- func VerifyArtifactsWithOptions(ctx context.Context, config Config, directory string, options RunnerOptions, ...) error
- type ArtifactOptions
- type Config
- type CreatedArtifact
- type MigrationPhaseStatus
- type MigrationStatus
- type MigrationStepStatus
- type RunnerOptions
- type SafetyError
- type Store
- func (backend *Store) AcquireDocumentLock(ctx context.Context, candidate store.DocumentLock, now time.Time, ...) (store.DocumentLock, bool, error)
- func (backend *Store) AdoptArtifacts(ctx context.Context, directory string) ([]string, error)
- func (backend *Store) AllowAuthAttempt(ctx context.Context, keyHash string, now time.Time, window time.Duration, ...) (bool, error)
- func (backend *Store) ApplyArtifacts(ctx context.Context, directory string, ...) error
- func (backend *Store) ApplyArtifactsWithOptions(ctx context.Context, directory string, options RunnerOptions, ...) error
- func (backend *Store) ArtifactPlan(ctx context.Context, directory string) ([]MigrationStatus, error)
- func (backend *Store) ArtifactStatus(ctx context.Context, directory string) ([]MigrationStatus, error)
- func (backend *Store) Begin(ctx context.Context) (store.Transaction, error)
- func (backend *Store) BeginSnapshot(ctx context.Context) (store.Transaction, error)
- func (backend *Store) CancelTask(ctx context.Context, id string) error
- func (backend *Store) ChangePasswordHash(ctx context.Context, collection schema.Collection, userID string, ...) error
- func (backend *Store) ClaimTasks(ctx context.Context, request store.TaskClaim) ([]store.Task, error)
- func (backend *Store) ClearDevelopmentFieldKinds(ctx context.Context, before, after schema.Manifest, ...) error
- func (backend *Store) Close() error
- func (backend *Store) CompleteTask(ctx context.Context, id, leaseToken string, output json.RawMessage) error
- func (backend *Store) CreateAPIKey(ctx context.Context, key store.AuthAPIKey, sessionTokenHash string, ...) error
- func (backend *Store) CreateAuthToken(ctx context.Context, token store.AuthToken) error
- func (backend *Store) CreateSession(ctx context.Context, session store.AuthSession, expectedPasswordHash []byte) error
- func (backend *Store) DeleteAPIKey(ctx context.Context, collectionID schema.StableID, userID, id string) error
- func (backend *Store) DeletePreference(ctx context.Context, collectionID schema.StableID, userID, key string) error
- func (backend *Store) DeletePreferences(ctx context.Context, collectionID schema.StableID, userID string) error
- func (backend *Store) DeleteSession(ctx context.Context, tokenHash string) error
- func (backend *Store) DeleteUserSession(ctx context.Context, collectionID schema.StableID, userID, sessionID string) error
- func (backend *Store) DeleteUserSessions(ctx context.Context, collectionID schema.StableID, userID string) error
- func (backend *Store) DevelopmentManifest(ctx context.Context) (schema.Manifest, bool, error)
- func (backend *Store) DismissTaskForTarget(ctx context.Context, id, slug string, target store.DocumentReference) error
- func (backend *Store) EnqueueTask(ctx context.Context, task store.Task) (store.Task, error)
- func (backend *Store) FailTask(ctx context.Context, failure store.TaskFailure) error
- func (backend *Store) FindAPIKey(ctx context.Context, id string, now time.Time) (store.AuthAPIKey, error)
- func (backend *Store) FindAuthCredential(ctx context.Context, collection schema.Collection, identity string) (store.AuthCredential, error)
- func (backend *Store) FindDocumentLock(ctx context.Context, collectionID schema.StableID, documentID string, ...) (store.DocumentLock, error)
- func (backend *Store) FindSession(ctx context.Context, tokenHash string, now time.Time) (store.AuthSession, error)
- func (backend *Store) FindSessionByID(ctx context.Context, id string, now time.Time) (store.AuthSession, error)
- func (backend *Store) FindTask(ctx context.Context, id string) (store.Task, error)
- func (backend *Store) ForceUnlock(ctx context.Context, collectionID schema.StableID, userID string) error
- func (backend *Store) GetPreference(ctx context.Context, collectionID schema.StableID, userID, key string) (store.Preference, error)
- func (backend *Store) HasMigrationHistory(ctx context.Context) (bool, error)
- func (backend *Store) HeartbeatTask(ctx context.Context, id, leaseToken string, leaseDuration time.Duration) error
- func (backend *Store) ListAPIKeys(ctx context.Context, collectionID schema.StableID, userID string, ...) ([]store.AuthAPIKey, error)
- func (backend *Store) ListSessions(ctx context.Context, collectionID schema.StableID, userID string, ...) ([]store.AuthSession, error)
- func (backend *Store) ListTasks(ctx context.Context, request store.TaskList) ([]store.Task, error)
- func (backend *Store) LockUploadObjects(ctx context.Context, objectKeys []string) (func(), error)
- func (backend *Store) Ping(ctx context.Context) error
- func (backend *Store) PruneExpiredAuth(ctx context.Context, limit int) (store.AuthPruneResult, error)
- func (backend *Store) PruneTasks(ctx context.Context, limit int) (int, error)
- func (backend *Store) Ready(ctx context.Context, manifest schema.Manifest) error
- func (backend *Store) ReadyWithMigrationHistory(ctx context.Context, manifest schema.Manifest, expectedHistoryDigest string) error
- func (backend *Store) RecordFailedLogin(ctx context.Context, collectionID schema.StableID, userID string, ...) (store.AuthCredential, error)
- func (backend *Store) ReleaseDocumentLock(ctx context.Context, collectionID schema.StableID, documentID string, ...) error
- func (backend *Store) ReleaseTask(ctx context.Context, id, leaseToken string, delay time.Duration, ...) error
- func (backend *Store) ReplaceBaseline(ctx context.Context, directory string, ...) ([]string, error)
- func (backend *Store) ResetLoginAttempts(ctx context.Context, collectionID schema.StableID, userID string, ...) (bool, error)
- func (backend *Store) ResetPasswordWithToken(ctx context.Context, collectionID schema.StableID, tokenHash string, ...) (string, error)
- func (backend *Store) ReviewDevelopmentFieldKinds(ctx context.Context, before, after schema.Manifest) ([]fieldchange.Report, error)
- func (backend *Store) ReviewDevelopmentVersions(ctx context.Context, before, after schema.Manifest) ([]enableversions.Report, error)
- func (backend *Store) RotateSession(ctx context.Context, currentHash string, replacement store.AuthSession, ...) error
- func (backend *Store) SetPasswordHash(ctx context.Context, collection schema.Collection, userID string, hash []byte, ...) error
- func (backend *Store) SetPreference(ctx context.Context, preference store.Preference) (store.Preference, error)
- func (backend *Store) SyncDevelopmentSchema(ctx context.Context, manifest schema.Manifest) error
- func (backend *Store) TouchAPIKey(ctx context.Context, id string, now time.Time) error
- func (backend *Store) UpgradePasswordHash(ctx context.Context, collection schema.Collection, userID string, ...) error
- func (backend *Store) VerifyEmailWithToken(ctx context.Context, collectionID schema.StableID, tokenHash string, ...) (string, error)
- func (backend *Store) VerifyIndexes(ctx context.Context, manifest schema.Manifest) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProjectMigrations ¶
func ProjectMigrations(transforms ...ridumigration.DataTransform) ridumigration.ProjectDriver
ProjectMigrations binds checksum-protected callbacks into the compiled project while MongoDB retains ownership of transactions, checkpoints, and the credential-bearing connection boundary.
func VerifyArtifacts ¶
func VerifyArtifacts(ctx context.Context, config Config, directory string, transforms ...ridumigration.DataTransform) error
VerifyArtifacts replays immutable history in an isolated shadow database.
func VerifyArtifactsWithOptions ¶
func VerifyArtifactsWithOptions(ctx context.Context, config Config, directory string, options RunnerOptions, transforms ...ridumigration.DataTransform) error
VerifyArtifactsWithOptions exercises the production runner, ledger, status, and readiness checks against an isolated database which is always dropped.
Types ¶
type ArtifactOptions ¶
type ArtifactOptions struct {
AllowDestructive bool
Renames []ridumigration.Rename
DataTransforms []ridumigration.DataTransformDescriptor
// ExistingDocuments says, for each resource that starts keeping versions,
// what becomes of the documents it already stores.
ExistingDocuments map[schema.StableID]ridumigration.ExistingDocuments
}
ArtifactOptions contains only reviewed semantic intent that can be frozen into an immutable MongoDB artifact. Callbacks themselves are never serialized; only their checksum-bound descriptors cross this boundary.
type Config ¶
type Config struct {
DatabaseURL string
// AllowInsecureTransport permits plaintext or certificate verification
// bypasses to a remote host for an explicitly selected development
// fixture. Loopback and Unix-socket databases never need it.
AllowInsecureTransport bool
ApplicationName string
ConnectTimeout time.Duration
ServerSelectionTimeout time.Duration
MaxConnectionIdleTime time.Duration
MaxPoolSize uint64
MinPoolSize uint64
}
Config controls MongoDB connection behavior. DatabaseURL is runtime-only infrastructure and must never be copied into a schema manifest or artifact.
type CreatedArtifact ¶
type CreatedArtifact struct {
Path string `json:"path"`
Name string `json:"name"`
Checksum string `json:"checksum"`
Version uint32 `json:"version"`
}
CreatedArtifact is the stable filesystem identity of one newly published immutable MongoDB migration artifact.
func CreateArtifact ¶
func CreateArtifact(ctx context.Context, directory, name string, after schema.Manifest, now time.Time, options ArtifactOptions) (CreatedArtifact, error)
CreateArtifact plans and atomically publishes one immutable MongoDB migration artifact with explicit semantic intent. Planning is offline: it reads only committed artifacts and the executable manifest; database URLs, secrets, and live MongoDB state are outside this boundary.
type MigrationPhaseStatus ¶
type MigrationPhaseStatus struct {
ID string `json:"id"`
Mode ridumigration.PhaseMode `json:"mode"`
State string `json:"state"`
Steps []MigrationStepStatus `json:"steps"`
}
MigrationPhaseStatus describes one immutable execution boundary.
type MigrationStatus ¶
type MigrationStatus struct {
Name string `json:"name"`
Checksum string `json:"checksum"`
Version uint32 `json:"version"`
Applied bool `json:"applied"`
Phases []MigrationPhaseStatus `json:"phases,omitempty"`
}
MigrationStatus describes one immutable MongoDB artifact relative to the database ledger.
func InspectArtifacts ¶
func InspectArtifacts(ctx context.Context, config Config, directory string, executableManifest schema.Manifest) ([]MigrationStatus, error)
InspectArtifacts binds status and plan inspection to the executable manifest, validates and precompiles that exact in-memory history before connecting, and uses the retained files for every database-backed check.
type MigrationStepStatus ¶
type MigrationStepStatus struct {
ID string `json:"id"`
Kind ridumigration.StepKind `json:"kind"`
State string `json:"state"`
}
MigrationStepStatus describes one durable MongoDB executor invocation.
type RunnerOptions ¶
type RunnerOptions struct {
AllowMaintenance bool
AllowUnbounded bool
LeaseWait time.Duration
LeaseDuration time.Duration
OperationTimeout time.Duration
}
RunnerOptions bounds MongoDB migration coordination and index builds. AllowUnbounded permits a zero wait or operation timeout; lease expiry is always bounded so a crashed migrator cannot permanently block recovery.
type SafetyError ¶
type SafetyError struct {
Risks []ridumigration.Risk
}
SafetyError reports a valid MongoDB transition that still requires explicit destructive review before publication.
func (*SafetyError) Error ¶
func (err *SafetyError) Error() string
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is one replica-set-backed MongoDB database with immutable migration ledger readiness and transactional document storage.
func OpenWithConfig ¶
OpenWithConfig validates the credential-bearing URL without echoing it, connects, and proves transaction-capable replica-set topology. It does not create collections, indexes, or migration state.
func (*Store) AcquireDocumentLock ¶
func (*Store) AdoptArtifacts ¶ added in v0.9.0
AdoptArtifacts records pending migrations as applied, without running them, through the newest one whose schema the database already has, such as a database ridu dev synchronized. See ridu migrate baseline.
func (*Store) AllowAuthAttempt ¶
func (*Store) ApplyArtifacts ¶
func (backend *Store) ApplyArtifacts(ctx context.Context, directory string, transforms ...ridumigration.DataTransform) error
ApplyArtifacts applies the complete immutable MongoDB migration history.
func (*Store) ApplyArtifactsWithOptions ¶
func (backend *Store) ApplyArtifactsWithOptions(ctx context.Context, directory string, options RunnerOptions, transforms ...ridumigration.DataTransform) error
ApplyArtifactsWithOptions applies planner-validated physical and semantic MongoDB steps, including registered transforms, and durably records each resumable boundary.
func (*Store) ArtifactPlan ¶
func (backend *Store) ArtifactPlan(ctx context.Context, directory string) ([]MigrationStatus, error)
ArtifactPlan returns the same strict state with phase and step detail for deterministic CLI rendering.
func (*Store) ArtifactStatus ¶
func (backend *Store) ArtifactStatus(ctx context.Context, directory string) ([]MigrationStatus, error)
ArtifactStatus validates immutable history and reports durable progress.
func (*Store) Begin ¶
Begin opens a majority-committed, snapshot-isolated write transaction. Until its first content write, a transient conflict restarts it on a newer snapshot (see lockDocument), so its reads are snapshot-isolated from that point, as a read-committed PostgreSQL transaction's statements are.
func (*Store) BeginSnapshot ¶
BeginSnapshot opens the same stable snapshot in read-only adapter mode.
func (*Store) ChangePasswordHash ¶
func (*Store) ClaimTasks ¶
func (*Store) ClearDevelopmentFieldKinds ¶ added in v0.12.0
func (backend *Store) ClearDevelopmentFieldKinds(ctx context.Context, before, after schema.Manifest, expected []fieldchange.Report) error
ClearDevelopmentFieldKinds clears only the reviewed field values from working documents, published heads, and retained snapshots, with references in one transaction. Immutable applied or incomplete migration history requires the reviewed runner.
func (*Store) Close ¶
Close releases the MongoDB client. It is idempotent and uses an internal bound so it satisfies the framework runtime's context-free close contract.
func (*Store) CompleteTask ¶
func (*Store) CreateAPIKey ¶
func (*Store) CreateAuthToken ¶
func (*Store) CreateSession ¶
func (*Store) DeleteAPIKey ¶
func (*Store) DeletePreference ¶
func (*Store) DeletePreferences ¶
func (*Store) DeleteSession ¶
func (*Store) DeleteUserSession ¶
func (*Store) DeleteUserSessions ¶
func (*Store) DevelopmentManifest ¶ added in v0.12.0
DevelopmentManifest returns the database-owned last synchronized schema. Existing indexes or JSON documents do not prove the previous field kinds, so collections without a record are an error; a fresh database has none.
func (*Store) DismissTaskForTarget ¶
func (*Store) EnqueueTask ¶
func (*Store) FindAPIKey ¶
func (*Store) FindAuthCredential ¶
func (backend *Store) FindAuthCredential(ctx context.Context, collection schema.Collection, identity string) (store.AuthCredential, error)
func (*Store) FindDocumentLock ¶
func (*Store) FindSession ¶
func (*Store) FindSessionByID ¶ added in v0.4.0
func (*Store) ForceUnlock ¶
func (*Store) GetPreference ¶
func (*Store) HasMigrationHistory ¶ added in v0.12.0
HasMigrationHistory includes partial semantic work, which development recovery must never mutate outside the immutable runner.
func (*Store) HeartbeatTask ¶
func (*Store) ListAPIKeys ¶
func (*Store) ListSessions ¶
func (*Store) LockUploadObjects ¶
LockUploadObjects acquires one separately committed exact-owner lock set. Acquisition is all-or-none, and rows remain held until release. Graceful shutdown must drain callers before Store.Close; crash-abandoned rows require explicit operator recovery.
func (*Store) PruneExpiredAuth ¶
func (*Store) PruneTasks ¶
func (*Store) Ready ¶
Ready checks the manifest and physical schema for development and adapter diagnostics when no executable migration history digest is available.
func (*Store) ReadyWithMigrationHistory ¶
func (backend *Store) ReadyWithMigrationHistory(ctx context.Context, manifest schema.Manifest, expectedHistoryDigest string) error
ReadyWithMigrationHistory verifies the complete ordered artifact history, recorded head and executable storage schema, then the physical index contract. Admin presentation may differ.
func (*Store) RecordFailedLogin ¶
func (*Store) ReleaseDocumentLock ¶
func (*Store) ReleaseTask ¶
func (*Store) ReplaceBaseline ¶ added in v0.12.0
func (backend *Store) ReplaceBaseline(ctx context.Context, directory string, options migration.BaselineReplacementOptions) ([]string, error)
ReplaceBaseline atomically replaces a verified development artifact/step ledger. Content, snapshots, namespaces, and indexes are never changed. Replacement artifacts from the first unrecorded semantic step onward stay pending for ApplyArtifacts.
func (*Store) ResetLoginAttempts ¶
func (*Store) ResetPasswordWithToken ¶
func (*Store) ReviewDevelopmentFieldKinds ¶ added in v0.12.0
func (backend *Store) ReviewDevelopmentFieldKinds(ctx context.Context, before, after schema.Manifest) ([]fieldchange.Report, error)
ReviewDevelopmentFieldKinds reads both active heads and every snapshot under one stable database snapshot, counting each logical document once.
func (*Store) ReviewDevelopmentVersions ¶ added in v0.19.0
func (backend *Store) ReviewDevelopmentVersions(ctx context.Context, before, after schema.Manifest) ([]enableversions.Report, error)
ReviewDevelopmentVersions counts the documents, trashed ones included, that each resource starting to keep versions between before and after already stores in this database. It changes nothing.
func (*Store) RotateSession ¶
func (*Store) SetPasswordHash ¶
func (*Store) SetPreference ¶
func (backend *Store) SetPreference(ctx context.Context, preference store.Preference) (store.Preference, error)
func (*Store) SyncDevelopmentSchema ¶ added in v0.12.0
SyncDevelopmentSchema verifies additive index sync under the migration lease, then records its manifest in a fenced transaction. Failed builds never certify the candidate schema.
func (*Store) TouchAPIKey ¶
func (*Store) UpgradePasswordHash ¶
func (*Store) VerifyEmailWithToken ¶
func (*Store) VerifyIndexes ¶
VerifyIndexes is a non-mutating physical check for the complete current manifest plan. A successful verification authorizes this Store instance to serve every resource in that plan; Open itself remains free of schema mutations.
Source Files
¶
- auth.go
- auth_api_keys.go
- auth_codec.go
- auth_maintenance.go
- auth_sessions.go
- auth_tokens.go
- codec.go
- collection_contracts.go
- development_field_kind.go
- development_schema.go
- distinct.go
- documents.go
- fences.go
- head_uniqueness.go
- indexes.go
- localization.go
- lock_queue.go
- locks.go
- migration_adopt.go
- migration_execute.go
- migration_lease.go
- migration_ledger.go
- migration_rebaseline.go
- migration_runner.go
- migration_semantic_plan.go
- migration_transform.go
- migration_verify.go
- migrations.go
- mongodb.go
- nested_predicate.go
- physical_names.go
- population.go
- predicate.go
- preferences.go
- primitive_lists.go
- published_heads.go
- references.go
- relationship_schema.go
- required_audit.go
- statements.go
- system_references.go
- task_codec.go
- tasks.go
- transaction.go
- upload_locks.go
- upload_references.go
- upload_schema.go
- versions.go
- versions_enable.go
- window.go