postgres
import "github.com/prescriptoo/prescriptoo-api/services/identity/internal/adapters/postgres"Package postgres provides PostgreSQL database driven adapter implementations.
Index
- func NewPgAccountRepository(db *pgxpool.Pool) ports.AccountRepository
- func NewPgSessionRepository(db *pgxpool.Pool) ports.SessionRepository
- func NewPgUserRepository(db sqlc.DBTX) ports.UserRepository
- type AccountStatusManager
- type Provisioner
func NewPgAccountRepository
func NewPgAccountRepository(db *pgxpool.Pool) ports.AccountRepositoryNewPgAccountRepository provides transactional account and email-token operations.
func NewPgSessionRepository
func NewPgSessionRepository(db *pgxpool.Pool) ports.SessionRepositoryNewPgSessionRepository persists sessions and refresh-token history in PostgreSQL.
func NewPgUserRepository
func NewPgUserRepository(db sqlc.DBTX) ports.UserRepositoryNewPgUserRepository returns a PostgreSQL implementation of ports.UserRepository.
type AccountStatusManager
AccountStatusManager owns the account lock, status mutation, session revocation and audit commit.
type AccountStatusManager struct {
DB *pgxpool.Pool
Audit audit.TransactionalRecorderFactory
}func (AccountStatusManager) ChangeAccountStatus
func (w AccountStatusManager) ChangeAccountStatus(ctx context.Context, input identitypublic.ChangeAccountStatusInput) (*identitypublic.Account, error)ChangeAccountStatus commits account status, disabled-session revocation and audit recording together.
func (AccountStatusManager) LockActiveAccounts
func (w AccountStatusManager) LockActiveAccounts(ctx context.Context, tx pgx.Tx, ids []string) errorLockActiveAccounts validates active Identity accounts while holding their row locks in the caller-owned transaction. It neither starts nor commits a transaction; Organization retains these locks until affiliation and audit writes complete.
A concurrent suspension uses the same account lock, so the assignment either commits before suspension or observes the committed inactive state and fails. Verification does not participate in this account eligibility check.
type Provisioner
Provisioner atomically creates an Identity account and its initiating audit entry.
type Provisioner struct {
DB *pgxpool.Pool
Audit audit.TransactionalRecorderFactory
}func (Provisioner) Create
func (w Provisioner) Create(ctx context.Context, op audit.OperationContext, u *domain.User) errorCreate commits account provisioning and its audit entry in one transaction.
Generated by gomarkdoc