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

memory

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package memory provides an in-memory implementation of store.Store for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is an in-memory implementation of the composite store interface.

func New

func New() *Store

New creates a new in-memory store.

func (*Store) AddUserEmail

func (s *Store) AddUserEmail(_ context.Context, e *user.UserEmail) error

AddUserEmail attaches an additional email to a user. The address must be free within (app_id, env_id), else account.ErrEmailTaken.

func (*Store) BatchResolve

func (s *Store) BatchResolve(ctx context.Context, keys []string, opts settings.ResolveOpts) (map[string][]*settings.Setting, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) ConsumePasswordReset

func (s *Store) ConsumePasswordReset(_ context.Context, token string) error

func (*Store) ConsumeVerification

func (s *Store) ConsumeVerification(_ context.Context, token string) error

ConsumeVerification marks a verification consumed, returning ErrNotFound if it was missing or already consumed. The already-consumed case must be distinguishable so callers can reject a replay: checking Consumed on a prior read and setting it here are two steps, and only the store can make them one.

func (*Store) CreateAPIKey

func (s *Store) CreateAPIKey(_ context.Context, k *apikey.APIKey) error

func (*Store) CreateApp

func (s *Store) CreateApp(_ context.Context, a *app.App) error

func (*Store) CreateDelegation

func (s *Store) CreateDelegation(_ context.Context, d *principal.Delegation) error

func (*Store) CreateDevice

func (s *Store) CreateDevice(_ context.Context, d *device.Device) error

func (*Store) CreateEnvironment

func (s *Store) CreateEnvironment(_ context.Context, e *environment.Environment) error

func (*Store) CreateFormConfig

func (s *Store) CreateFormConfig(_ context.Context, fc *formconfig.FormConfig) error

func (*Store) CreateInvitation

func (s *Store) CreateInvitation(_ context.Context, inv *organization.Invitation) error

func (*Store) CreateMember

func (s *Store) CreateMember(_ context.Context, m *organization.Member) error

func (*Store) CreateNotification

func (s *Store) CreateNotification(_ context.Context, n *notification.Notification) error

func (*Store) CreateOrganization

func (s *Store) CreateOrganization(_ context.Context, o *organization.Organization) error

func (*Store) CreatePasswordReset

func (s *Store) CreatePasswordReset(_ context.Context, pr *account.PasswordReset) error

func (*Store) CreateServiceAccount

func (s *Store) CreateServiceAccount(_ context.Context, svc *serviceaccount.ServiceAccount) error

func (*Store) CreateSession

func (s *Store) CreateSession(_ context.Context, sess *session.Session) error

func (*Store) CreateTeam

func (s *Store) CreateTeam(_ context.Context, t *organization.Team) error

func (*Store) CreateUser

func (s *Store) CreateUser(_ context.Context, u *user.User) error

func (*Store) CreateUserWithPrimaryEmail

func (s *Store) CreateUserWithPrimaryEmail(_ context.Context, u *user.User, primary *user.UserEmail) error

CreateUserWithPrimaryEmail creates a user together with its primary email row. The email address must be free within (app_id, env_id).

func (*Store) CreateVerification

func (s *Store) CreateVerification(_ context.Context, v *account.Verification) error

func (*Store) CreateWebhook

func (s *Store) CreateWebhook(_ context.Context, w *webhook.Webhook) error

func (*Store) DeleteAPIKey

func (s *Store) DeleteAPIKey(_ context.Context, keyID id.APIKeyID) error

func (*Store) DeleteApp

func (s *Store) DeleteApp(_ context.Context, appID id.AppID) error

DeleteApp removes the app and every child record scoped to it, mirroring the ON DELETE CASCADE behaviour of the PostgreSQL backend so the in-memory store stays consistent (no orphaned users/sessions/etc.). Plugin-owned tables (passkey, oauth connections, oauth2 clients, ...) live in their own stores and are not tracked here.

func (*Store) DeleteAppClientConfig

func (s *Store) DeleteAppClientConfig(_ context.Context, appID id.AppID) error

func (*Store) DeleteAppSessionConfig

func (s *Store) DeleteAppSessionConfig(_ context.Context, appID id.AppID) error

func (*Store) DeleteBranding

func (s *Store) DeleteBranding(_ context.Context, orgID id.OrgID) error

func (*Store) DeleteDevice

func (s *Store) DeleteDevice(_ context.Context, deviceID id.DeviceID) error

func (*Store) DeleteEnvironment

func (s *Store) DeleteEnvironment(_ context.Context, envID id.EnvironmentID) error

func (*Store) DeleteExpiredPasswordResets

func (s *Store) DeleteExpiredPasswordResets(_ context.Context, before time.Time, batch int) (int64, error)

DeleteExpiredPasswordResets implements store.Retention.

func (*Store) DeleteExpiredRevokedRefreshTokens

func (s *Store) DeleteExpiredRevokedRefreshTokens(_ context.Context, before time.Time, batch int) (int64, error)

DeleteExpiredRevokedRefreshTokens implements store.Retention.

func (*Store) DeleteExpiredSessions

func (s *Store) DeleteExpiredSessions(_ context.Context, before time.Time, batch int) (int64, error)

DeleteExpiredSessions implements store.Retention.

func (*Store) DeleteExpiredVerifications

func (s *Store) DeleteExpiredVerifications(_ context.Context, before time.Time, batch int) (int64, error)

DeleteExpiredVerifications implements store.Retention.

func (*Store) DeleteFormConfig

func (s *Store) DeleteFormConfig(_ context.Context, appID id.AppID, formType string) error

func (*Store) DeleteInvitation

func (s *Store) DeleteInvitation(_ context.Context, invID id.InvitationID) error

func (*Store) DeleteMember

func (s *Store) DeleteMember(_ context.Context, memberID id.MemberID) error

func (*Store) DeleteOrganization

func (s *Store) DeleteOrganization(_ context.Context, orgID id.OrgID) error

func (*Store) DeleteOrganizationCascade

func (s *Store) DeleteOrganizationCascade(ctx context.Context, orgID id.OrgID) error

DeleteOrganizationCascade deletes the organization and all of its dependent rows (members, teams, invitations) atomically via the snapshot/restore WithTx wrapper. On any inner-store error (e.g. a fault injection) the entire cascade rolls back.

Returns nil if the org doesn't exist (idempotent — matches the SQL-backend behaviour where DELETE on a missing PK is a no-op).

func (*Store) DeleteServiceAccount

func (s *Store) DeleteServiceAccount(_ context.Context, svcID id.ServiceAccountID) error

func (*Store) DeleteSession

func (s *Store) DeleteSession(_ context.Context, sessionID id.SessionID) error

func (*Store) DeleteSessionsByGrant

func (s *Store) DeleteSessionsByGrant(_ context.Context, grantID id.AgentGrantID) error

func (*Store) DeleteSetting

func (s *Store) DeleteSetting(_ context.Context, key string, scope settings.Scope, scopeID string) error

func (*Store) DeleteSettingsByNamespace

func (s *Store) DeleteSettingsByNamespace(_ context.Context, namespace string) error

func (*Store) DeleteTeam

func (s *Store) DeleteTeam(_ context.Context, teamID id.TeamID) error

func (*Store) DeleteUser

func (s *Store) DeleteUser(_ context.Context, userID id.UserID) error

func (*Store) DeleteUserEmail

func (s *Store) DeleteUserEmail(_ context.Context, userID id.UserID, email string) error

DeleteUserEmail soft-deletes a non-primary email. Deleting the primary is refused with store.ErrConflict.

func (*Store) DeleteUserSessions

func (s *Store) DeleteUserSessions(_ context.Context, userID id.UserID) error

func (*Store) DeleteWebhook

func (s *Store) DeleteWebhook(_ context.Context, webhookID id.WebhookID) error

func (*Store) FindActiveDelegation

func (s *Store) FindActiveDelegation(
	_ context.Context, appID id.AppID, actor, subject principal.Ref, grantKind principal.GrantKind,
) (*principal.Delegation, error)

func (*Store) FindByPrefix

func (s *Store) FindByPrefix(_ context.Context, prefix string) (*apikey.APIKey, error)

func (*Store) GetAPIKey

func (s *Store) GetAPIKey(_ context.Context, keyID id.APIKeyID) (*apikey.APIKey, error)

func (*Store) GetAPIKeyByPrefix

func (s *Store) GetAPIKeyByPrefix(_ context.Context, appID id.AppID, prefix string) (*apikey.APIKey, error)

func (*Store) GetAPIKeyByPublicKey

func (s *Store) GetAPIKeyByPublicKey(_ context.Context, appID id.AppID, publicKey string) (*apikey.APIKey, error)

func (*Store) GetActiveEmailVerification

func (s *Store) GetActiveEmailVerification(_ context.Context, userID id.UserID) (*account.Verification, error)

func (*Store) GetApp

func (s *Store) GetApp(_ context.Context, appID id.AppID) (*app.App, error)

func (*Store) GetAppByPublishableKey

func (s *Store) GetAppByPublishableKey(_ context.Context, key string) (*app.App, error)

func (*Store) GetAppBySlug

func (s *Store) GetAppBySlug(_ context.Context, slug string) (*app.App, error)

func (*Store) GetAppClientConfig

func (s *Store) GetAppClientConfig(_ context.Context, appID id.AppID) (*appclientconfig.Config, error)

func (*Store) GetAppSessionConfig

func (s *Store) GetAppSessionConfig(_ context.Context, appID id.AppID) (*appsessionconfig.Config, error)

func (*Store) GetBranding

func (s *Store) GetBranding(_ context.Context, orgID id.OrgID) (*formconfig.BrandingConfig, error)

func (*Store) GetDefaultEnvironment

func (s *Store) GetDefaultEnvironment(_ context.Context, appID id.AppID) (*environment.Environment, error)

func (*Store) GetDelegation

func (s *Store) GetDelegation(_ context.Context, delID id.DelegationID) (*principal.Delegation, error)

func (*Store) GetDevice

func (s *Store) GetDevice(_ context.Context, deviceID id.DeviceID) (*device.Device, error)

func (*Store) GetDeviceByFingerprint

func (s *Store) GetDeviceByFingerprint(_ context.Context, userID id.UserID, fingerprint string) (*device.Device, error)

func (*Store) GetEnvironment

func (s *Store) GetEnvironment(_ context.Context, envID id.EnvironmentID) (*environment.Environment, error)

func (*Store) GetEnvironmentBySlug

func (s *Store) GetEnvironmentBySlug(_ context.Context, appID id.AppID, slug string) (*environment.Environment, error)

func (*Store) GetFormConfig

func (s *Store) GetFormConfig(_ context.Context, appID id.AppID, formType string) (*formconfig.FormConfig, error)

func (*Store) GetInvitation

func (s *Store) GetInvitation(_ context.Context, invID id.InvitationID) (*organization.Invitation, error)

func (*Store) GetInvitationByToken

func (s *Store) GetInvitationByToken(_ context.Context, token string) (*organization.Invitation, error)

func (*Store) GetMember

func (s *Store) GetMember(_ context.Context, memberID id.MemberID) (*organization.Member, error)

func (*Store) GetMemberByUserAndOrg

func (s *Store) GetMemberByUserAndOrg(_ context.Context, userID id.UserID, orgID id.OrgID) (*organization.Member, error)

func (*Store) GetNotification

func (s *Store) GetNotification(_ context.Context, notifID id.NotificationID) (*notification.Notification, error)

func (*Store) GetOrganization

func (s *Store) GetOrganization(_ context.Context, orgID id.OrgID) (*organization.Organization, error)

func (*Store) GetOrganizationBySlug

func (s *Store) GetOrganizationBySlug(_ context.Context, appID id.AppID, slug string) (*organization.Organization, error)

func (*Store) GetPasswordReset

func (s *Store) GetPasswordReset(_ context.Context, token string) (*account.PasswordReset, error)

func (*Store) GetPlatformApp

func (s *Store) GetPlatformApp(_ context.Context) (*app.App, error)

func (*Store) GetPrincipal

func (s *Store) GetPrincipal(ctx context.Context, ref principal.Ref) (*principal.Principal, error)

func (*Store) GetRevokedRefreshTokenFamily

func (s *Store) GetRevokedRefreshTokenFamily(_ context.Context, tokenHash string) (id.SessionFamilyID, error)

GetRevokedRefreshTokenFamily returns the family of a previously-revoked token, or store.ErrNotFound if the hash is unknown.

func (*Store) GetServiceAccount

func (s *Store) GetServiceAccount(_ context.Context, svcID id.ServiceAccountID) (*serviceaccount.ServiceAccount, error)

func (*Store) GetSession

func (s *Store) GetSession(_ context.Context, sessionID id.SessionID) (*session.Session, error)

func (*Store) GetSessionByRefreshToken

func (s *Store) GetSessionByRefreshToken(_ context.Context, refreshToken string) (*session.Session, error)

func (*Store) GetSessionByToken

func (s *Store) GetSessionByToken(_ context.Context, token string) (*session.Session, error)

func (*Store) GetSetting

func (s *Store) GetSetting(_ context.Context, key string, scope settings.Scope, scopeID string) (*settings.Setting, error)

func (*Store) GetTeam

func (s *Store) GetTeam(_ context.Context, teamID id.TeamID) (*organization.Team, error)

func (*Store) GetUser

func (s *Store) GetUser(_ context.Context, userID id.UserID) (*user.User, error)

func (*Store) GetUserByAnyEmail

func (s *Store) GetUserByAnyEmail(_ context.Context, appID id.AppID, envID id.EnvironmentID, email string) (*user.User, error)

GetUserByAnyEmail resolves the user owning any (primary or secondary) email matching (appID, envID, email).

func (*Store) GetUserByEmail

func (s *Store) GetUserByEmail(_ context.Context, appID id.AppID, envID id.EnvironmentID, email string) (*user.User, error)

func (*Store) GetUserByPhone

func (s *Store) GetUserByPhone(_ context.Context, appID id.AppID, envID id.EnvironmentID, phone string) (*user.User, error)

func (*Store) GetUserByUsername

func (s *Store) GetUserByUsername(_ context.Context, appID id.AppID, envID id.EnvironmentID, username string) (*user.User, error)

func (*Store) GetUserEmailRecord

func (s *Store) GetUserEmailRecord(_ context.Context, appID id.AppID, envID id.EnvironmentID, email string) (*user.UserEmail, error)

GetUserEmailRecord returns the email row matching (appID, envID, email).

func (*Store) GetUserEmails

func (s *Store) GetUserEmails(_ context.Context, userID id.UserID) ([]*user.UserEmail, error)

GetUserEmails returns all live emails for a user, primary first then oldest.

func (*Store) GetVerification

func (s *Store) GetVerification(_ context.Context, token string) (*account.Verification, error)

func (*Store) GetWebhook

func (s *Store) GetWebhook(_ context.Context, webhookID id.WebhookID) (*webhook.Webhook, error)

func (*Store) HashLegacyTokens

func (s *Store) HashLegacyTokens(_ context.Context, batch int) (int64, error)

HashLegacyTokens implements store.LegacyTokenHasher.

func (*Store) InjectOneShotFault

func (s *Store) InjectOneShotFault(method string, err error)

InjectOneShotFault is a TEST-ONLY helper. The next call to <method> returns err. Production code must not depend on this.

func (*Store) IsRefreshTokenRevoked

func (s *Store) IsRefreshTokenRevoked(_ context.Context, tokenHash string) (bool, error)

IsRefreshTokenRevoked reports whether tokenHash is in the revoked set.

func (*Store) KVCounter

func (s *Store) KVCounter(_ context.Context, key string) (int64, error)

KVCounter implements store.KV.

func (*Store) KVDelete

func (s *Store) KVDelete(_ context.Context, key string) error

KVDelete implements store.KV.

func (*Store) KVDeleteExpired

func (s *Store) KVDeleteExpired(_ context.Context, now time.Time) (int64, error)

KVDeleteExpired implements store.KV.

func (*Store) KVGet

func (s *Store) KVGet(_ context.Context, key string) ([]byte, error)

KVGet implements store.KV.

func (*Store) KVIncrement

func (s *Store) KVIncrement(_ context.Context, key string, ttl time.Duration) (int64, error)

KVIncrement implements store.KV.

func (*Store) KVSet

func (s *Store) KVSet(_ context.Context, key string, value []byte, ttl time.Duration) error

KVSet implements store.KV.

func (*Store) KVSetNX

func (s *Store) KVSetNX(_ context.Context, key string, value []byte, ttl time.Duration) (bool, error)

KVSetNX implements store.KV.

func (*Store) ListAPIKeysByApp

func (s *Store) ListAPIKeysByApp(_ context.Context, appID id.AppID) ([]*apikey.APIKey, error)

func (*Store) ListAPIKeysByUser

func (s *Store) ListAPIKeysByUser(_ context.Context, appID id.AppID, userID id.UserID) ([]*apikey.APIKey, error)

func (*Store) ListApps

func (s *Store) ListApps(_ context.Context) ([]*app.App, error)

func (*Store) ListDelegations

func (s *Store) ListDelegations(_ context.Context, q *principal.DelegationQuery) ([]*principal.Delegation, error)

func (*Store) ListDevices

func (s *Store) ListDevices(_ context.Context, limit int) ([]*device.Device, error)

func (*Store) ListEnvironments

func (s *Store) ListEnvironments(_ context.Context, appID id.AppID) ([]*environment.Environment, error)

func (*Store) ListFormConfigs

func (s *Store) ListFormConfigs(_ context.Context, appID id.AppID) ([]*formconfig.FormConfig, error)

func (*Store) ListInvitations

func (s *Store) ListInvitations(_ context.Context, orgID id.OrgID) ([]*organization.Invitation, error)

func (*Store) ListInvitationsPage

func (s *Store) ListInvitationsPage(_ context.Context, orgID id.OrgID, opts page.Opts) (page.Page[*organization.Invitation], error)

func (*Store) ListMembers

func (s *Store) ListMembers(_ context.Context, orgID id.OrgID) ([]*organization.Member, error)

func (*Store) ListMembersPage

func (s *Store) ListMembersPage(_ context.Context, orgID id.OrgID, opts page.Opts) (page.Page[*organization.Member], error)

func (*Store) ListOrganizations

func (s *Store) ListOrganizations(_ context.Context, appID id.AppID) ([]*organization.Organization, error)

func (*Store) ListOrganizationsPage

func (s *Store) ListOrganizationsPage(_ context.Context, appID id.AppID, opts page.Opts) (page.Page[*organization.Organization], error)

func (*Store) ListPrincipals

func (s *Store) ListPrincipals(_ context.Context, q *principal.Query) ([]*principal.Principal, error)

func (*Store) ListServiceAccounts

func (s *Store) ListServiceAccounts(_ context.Context, q *serviceaccount.Query) (*serviceaccount.List, error)

func (*Store) ListSessions

func (s *Store) ListSessions(_ context.Context, limit int) ([]*session.Session, error)

func (*Store) ListSettings

func (s *Store) ListSettings(_ context.Context, opts settings.ListOpts) ([]*settings.Setting, error)

func (*Store) ListTeams

func (s *Store) ListTeams(_ context.Context, orgID id.OrgID) ([]*organization.Team, error)

func (*Store) ListTeamsPage

func (s *Store) ListTeamsPage(_ context.Context, orgID id.OrgID, opts page.Opts) (page.Page[*organization.Team], error)

func (*Store) ListUserDevices

func (s *Store) ListUserDevices(_ context.Context, userID id.UserID) ([]*device.Device, error)

func (*Store) ListUserNotifications

func (s *Store) ListUserNotifications(_ context.Context, userID id.UserID) ([]*notification.Notification, error)

func (*Store) ListUserOrganizations

func (s *Store) ListUserOrganizations(_ context.Context, userID id.UserID) ([]*organization.Organization, error)

func (*Store) ListUserOrganizationsPage

func (s *Store) ListUserOrganizationsPage(_ context.Context, userID id.UserID, opts page.Opts) (page.Page[*organization.Organization], error)

func (*Store) ListUserSessions

func (s *Store) ListUserSessions(_ context.Context, userID id.UserID) ([]*session.Session, error)

func (*Store) ListUserSessionsPage

func (s *Store) ListUserSessionsPage(_ context.Context, userID id.UserID, opts page.Opts) (page.Page[*session.Session], error)

func (*Store) ListUsers

func (s *Store) ListUsers(_ context.Context, q *user.Query) (*user.List, error)

func (*Store) ListWebhooks

func (s *Store) ListWebhooks(_ context.Context, appID id.AppID) ([]*webhook.Webhook, error)

func (*Store) MarkRefreshTokenReplayed

func (s *Store) MarkRefreshTokenReplayed(_ context.Context, tokenHash string) (bool, error)

MarkRefreshTokenReplayed flips an already-revoked token's reason to "replay_detected", returning whether this call made the change. Guarded by the store mutex so concurrent presentations resolve to a single firstReplay=true — the engine's storm guard.

func (*Store) MarkRefreshTokenRevoked

func (s *Store) MarkRefreshTokenRevoked(_ context.Context, tokenHash string, familyID id.SessionFamilyID, reason string) error

MarkRefreshTokenRevoked records tokenHash as revoked. Idempotent: a duplicate insert keeps the original record (the original family + first-seen timestamp).

func (*Store) MarkSent

func (s *Store) MarkSent(_ context.Context, notifID id.NotificationID) error

func (*Store) MarkUserEmailVerified

func (s *Store) MarkUserEmailVerified(_ context.Context, userID id.UserID, email string) error

MarkUserEmailVerified marks a user's email verified, mirroring onto the user record when the email is primary.

func (*Store) Migrate

func (s *Store) Migrate(_ context.Context, _ ...*migrate.Group) error

func (*Store) Ping

func (s *Store) Ping(context.Context) error

func (*Store) ResolveSettings

func (s *Store) ResolveSettings(_ context.Context, key string, opts settings.ResolveOpts) ([]*settings.Setting, error)

func (*Store) RevokeDelegation

func (s *Store) RevokeDelegation(_ context.Context, delID id.DelegationID, at time.Time) error

func (*Store) RevokeRefreshTokenFamily

func (s *Store) RevokeRefreshTokenFamily(_ context.Context, familyID id.SessionFamilyID, reason string) error

RevokeRefreshTokenFamily revokes every active session sharing familyID. Each surviving refresh-token hash is also recorded as revoked with reason so that later replays of any sibling token are detected too.

func (*Store) RotateSession

func (s *Store) RotateSession(_ context.Context, sess *session.Session, expectedTokenHash string) (bool, error)

func (*Store) SaveBranding

func (s *Store) SaveBranding(_ context.Context, b *formconfig.BrandingConfig) error

func (*Store) SeedLegacyInvitation

func (s *Store) SeedLegacyInvitation(_ context.Context, inv *organization.Invitation) error

SeedLegacyInvitation writes inv the way releases before token hashing did: plaintext and no hash. Test seam for the conformance suite.

func (*Store) SeedLegacyPasswordReset

func (s *Store) SeedLegacyPasswordReset(_ context.Context, pr *account.PasswordReset) error

SeedLegacyPasswordReset writes pr the way releases before token hashing did: plaintext and no hash. Test seam for the conformance suite.

func (*Store) SeedLegacySession

func (s *Store) SeedLegacySession(_ context.Context, sess *session.Session) error

SeedLegacySession writes sess exactly as a release before token hashing did: plaintext tokens and no hashes. It exists so the conformance suite can prove the upgrade path and is refused outside `go test`.

func (*Store) SeedLegacyVerification

func (s *Store) SeedLegacyVerification(_ context.Context, v *account.Verification) error

SeedLegacyVerification writes v the way releases before token hashing did: plaintext and no hash. Test seam for the conformance suite.

func (*Store) SetAppClientConfig

func (s *Store) SetAppClientConfig(_ context.Context, cfg *appclientconfig.Config) error

func (*Store) SetAppSessionConfig

func (s *Store) SetAppSessionConfig(_ context.Context, cfg *appsessionconfig.Config) error

func (*Store) SetDefaultEnvironment

func (s *Store) SetDefaultEnvironment(_ context.Context, appID id.AppID, envID id.EnvironmentID) error

func (*Store) SetPrimaryEmail

func (s *Store) SetPrimaryEmail(_ context.Context, userID id.UserID, email string) error

SetPrimaryEmail makes a verified, user-owned email the primary, clearing the previous primary and mirroring onto the user record.

func (*Store) SetSetting

func (s *Store) SetSetting(_ context.Context, st *settings.Setting) error

func (*Store) TouchAPIKey

func (s *Store) TouchAPIKey(_ context.Context, keyID id.APIKeyID, at time.Time) error

func (*Store) TouchSession

func (s *Store) TouchSession(_ context.Context, sessionID id.SessionID, lastActivityAt, expiresAt time.Time) error

func (*Store) UpdateAPIKey

func (s *Store) UpdateAPIKey(_ context.Context, k *apikey.APIKey) error

func (*Store) UpdateApp

func (s *Store) UpdateApp(_ context.Context, a *app.App) error

func (*Store) UpdateDevice

func (s *Store) UpdateDevice(_ context.Context, d *device.Device) error

func (*Store) UpdateEnvironment

func (s *Store) UpdateEnvironment(_ context.Context, e *environment.Environment) error

func (*Store) UpdateFormConfig

func (s *Store) UpdateFormConfig(_ context.Context, fc *formconfig.FormConfig) error

func (*Store) UpdateInvitation

func (s *Store) UpdateInvitation(_ context.Context, inv *organization.Invitation) error

func (*Store) UpdateMember

func (s *Store) UpdateMember(_ context.Context, m *organization.Member) error

func (*Store) UpdateOrganization

func (s *Store) UpdateOrganization(_ context.Context, o *organization.Organization) error

func (*Store) UpdateServiceAccount

func (s *Store) UpdateServiceAccount(_ context.Context, svc *serviceaccount.ServiceAccount) error

func (*Store) UpdateSession

func (s *Store) UpdateSession(_ context.Context, sess *session.Session) error

func (*Store) UpdateTeam

func (s *Store) UpdateTeam(_ context.Context, t *organization.Team) error

func (*Store) UpdateUser

func (s *Store) UpdateUser(_ context.Context, u *user.User) error

func (*Store) UpdateVerification

func (s *Store) UpdateVerification(_ context.Context, v *account.Verification) error

func (*Store) UpdateWebhook

func (s *Store) UpdateWebhook(_ context.Context, w *webhook.Webhook) error

func (*Store) WithTx

func (s *Store) WithTx(_ context.Context, fn func(tx organization.Store) error) error

WithTx runs fn against the memory store with snapshot/restore semantics for the four organization-related tables (orgs, members, invitations, teams). On error, those tables are restored to their pre-fn state.

snapshotOrgState covers only organization tables; do not use this WithTx for cross-table mutations until the snapshot is broadened.

Concurrency: NOT safe for concurrent calls — the lock is released while fn runs, so two concurrent WithTx calls each take their own snapshot and rollback is last-writer-wins on the four org tables. Real backends (postgres/sqlite/mongo) will get serializability from the DB once those WithTx implementations are wired; the memory store is only intended for single-threaded test paths.

Jump to

Keyboard shortcuts

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