feat(identity): store users, email tokens, and sessions

This commit is contained in:
shira committed 2026-10-06 00:15:22 +03:00
1 parent 15e2e50561
commit e7d0d92ef9
30 files changed
+4792 -32

No files matched your search

+12 -2
View File
@@ -17,13 +17,22 @@ var (
// transaction callback. Nested calls would silently use a second connection
// and commit independently of the outer transaction.
ErrNestedTransaction = errors.New("transaction already in progress")
// ErrTransactionConflict reports that PostgreSQL aborted the work with a
// deadlock (SQLSTATE 40P01) or a serialization failure (40001). Nothing
// was committed. The caller may retry the whole operation, ideally with a
// short backoff and a bounded number of attempts; a usecase or job that
// retries must stay idempotent.
ErrTransactionConflict = errors.New("transaction conflict")
)
// Transactor runs a business operation in one database transaction.
type Transactor interface {
// WithinTransaction commits when fn returns nil and rolls back when fn
// returns an error or panics. The error is returned unchanged in identity
// and a panic is re-raised after the rollback. fn must use only the
// returns an error or panics. The error keeps its identity for errors.Is
// and errors.As; a deadlock or serialization failure, from fn or from the
// commit, additionally matches ErrTransactionConflict. A panic is
// re-raised after the rollback. fn must use only the
// UnitOfWork and context it receives and must not retain them after
// returning. Calling WithinTransaction with that context returns
// ErrNestedTransaction. After a database error inside fn the transaction is
@@ -39,6 +48,7 @@ type Transactor interface {
// UnitOfWork exposes repositories bound to one transaction. Product
// repositories are added here as their usecases appear.
type UnitOfWork interface {
IdentityRepositories
Outbox() OutboxWriter
}