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) 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) 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) 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) 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) 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) 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) 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) SyncIndexes(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
}
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 for an explicitly selected local development fixture.
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) (CreatedArtifact, error)
CreateArtifact plans and atomically publishes one offline MongoDB migration with the frozen planner 1.0.0 contract retained for existing direct callers. New application migrations use CreateArtifactWithOptions and planner 2.0.0. This function reads only committed artifacts and the executable manifest; database URLs, secrets, and live MongoDB state are outside this boundary.
func CreateArtifactWithOptions ¶
func CreateArtifactWithOptions(ctx context.Context, directory, name string, after schema.Manifest, now time.Time, options ArtifactOptions) (CreatedArtifact, error)
CreateArtifactWithOptions publishes one immutable MongoDB planner 2.0.0 artifact with explicit semantic intent. Planning is offline and never opens MongoDB.
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) 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) BeginSnapshot ¶
BeginSnapshot opens the same stable snapshot in read-only adapter mode.
func (*Store) ChangePasswordHash ¶
func (*Store) ClaimTasks ¶
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) 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) ForceUnlock ¶
func (*Store) GetPreference ¶
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 preserves manifest-only readiness compatibility for callers that do not yet provide an executable migration-history digest.
func (*Store) ReadyWithMigrationHistory ¶
func (backend *Store) ReadyWithMigrationHistory(ctx context.Context, manifest schema.Manifest, expectedHistoryDigest string) error
ReadyWithMigrationHistory proves the executable manifest and exact ordered artifact history are the complete ledger head, then non-mutatingly verifies the physical index contract.
func (*Store) RecordFailedLogin ¶
func (*Store) ReleaseDocumentLock ¶
func (*Store) ReleaseTask ¶
func (*Store) ResetLoginAttempts ¶
func (*Store) ResetPasswordWithToken ¶
func (*Store) RotateSession ¶
func (*Store) SetPasswordHash ¶
func (*Store) SetPreference ¶
func (backend *Store) SetPreference(ctx context.Context, preference store.Preference) (store.Preference, error)
func (*Store) SyncIndexes ¶
SyncIndexes is the explicit development/bootstrap entry point for the bounded MongoDB index slice. It creates missing declared indexes, never drops or rewrites an existing index, and does not install migration state. MongoDB index builds are not transactional, so the operation is deliberately resumable and verifies the complete physical shape before authorizing writes.
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
- distinct.go
- documents.go
- indexes.go
- localization.go
- locks.go
- migration_execute.go
- migration_lease.go
- migration_ledger.go
- migration_runner.go
- migration_semantic_plan.go
- migration_transform.go
- migration_verify.go
- migrations.go
- mongodb.go
- physical_names.go
- population.go
- predicate.go
- preferences.go
- primitive_lists.go
- references.go
- relationship_schema.go
- system_references.go
- task_codec.go
- tasks.go
- transaction.go
- upload_locks.go
- upload_references.go
- upload_schema.go
- versions.go
- window.go