mysql

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MySQLAuditLogRepository

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

MySQLAuditLogRepository implements AuditLog persistence for MySQL. Uses BINARY(16) for UUID storage with transaction support via database.GetTx().

func NewMySQLAuditLogRepository

func NewMySQLAuditLogRepository(db *sql.DB) *MySQLAuditLogRepository

NewMySQLAuditLogRepository creates a new MySQL AuditLog repository.

func (*MySQLAuditLogRepository) Create

func (m *MySQLAuditLogRepository) Create(ctx context.Context, auditLog *authDomain.AuditLog) error

Create inserts a new AuditLog into the MySQL database using BINARY(16) for UUIDs. Uses transaction support via database.GetTx(). Handles nil metadata as database NULL. Includes cryptographic signature fields for tamper detection. Returns an error if UUID/metadata marshaling or database insertion fails.

func (*MySQLAuditLogRepository) DeleteOlderThan

func (m *MySQLAuditLogRepository) DeleteOlderThan(
	ctx context.Context,
	olderThan time.Time,
	dryRun bool,
) (int64, error)

DeleteOlderThan removes audit logs created before the specified timestamp. When dryRun is true, returns count via SELECT COUNT(*) without deletion. When false, executes DELETE and returns affected rows. Uses transaction support via database.GetTx(). All timestamps are expected in UTC.

func (*MySQLAuditLogRepository) Get

Get retrieves a single audit log by ID from the MySQL database. UUIDs are stored as BINARY(16) and must be marshaled/unmarshaled. Returns error if the audit log is not found or if database operation fails.

func (*MySQLAuditLogRepository) List

func (m *MySQLAuditLogRepository) List(
	ctx context.Context,
	offset, limit int,
	createdAtFrom, createdAtTo *time.Time,
) ([]*authDomain.AuditLog, error)

List retrieves audit logs ordered by created_at descending (newest first) with pagination and optional time-based filtering. Accepts createdAtFrom and createdAtTo as optional filters (nil means no filter). Both boundaries are inclusive (>= and <=). All timestamps are expected in UTC. Returns empty slice if no audit logs found. Handles NULL metadata gracefully by returning nil map for those entries. UUIDs are stored as BINARY(16) and must be unmarshaled.

type MySQLClientRepository

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

MySQLClientRepository implements Client persistence for MySQL. Uses BINARY(16) for UUID storage with transaction support via database.GetTx().

func NewMySQLClientRepository

func NewMySQLClientRepository(db *sql.DB) *MySQLClientRepository

NewMySQLClientRepository creates a new MySQL Client repository.

func (*MySQLClientRepository) Create

func (m *MySQLClientRepository) Create(ctx context.Context, client *authDomain.Client) error

Create inserts a new Client into the MySQL database using BINARY(16) for UUIDs. Uses transaction support via database.GetTx(). Returns an error if UUID/policy marshaling or database insertion fails.

func (*MySQLClientRepository) Get

Get retrieves a Client by ID from the MySQL database using BINARY(16) for UUIDs. Uses transaction support via database.GetTx(). Returns ErrClientNotFound if the client doesn't exist, or an error if UUID/policy unmarshaling or database query fails.

func (*MySQLClientRepository) List

func (m *MySQLClientRepository) List(
	ctx context.Context,
	offset, limit int,
) ([]*authDomain.Client, error)

List retrieves clients ordered by ID descending with pagination support using BINARY(16) for UUIDs. Uses transaction support via database.GetTx(). Returns empty slice if no clients found, or an error if UUID/policy unmarshaling or database query fails.

func (*MySQLClientRepository) Update

func (m *MySQLClientRepository) Update(ctx context.Context, client *authDomain.Client) error

Update modifies an existing Client in the MySQL database using BINARY(16) for UUIDs. Uses transaction support via database.GetTx(). Returns an error if UUID/policy marshaling or database update fails.

func (*MySQLClientRepository) UpdateLockState

func (m *MySQLClientRepository) UpdateLockState(
	ctx context.Context,
	clientID uuid.UUID,
	failedAttempts int,
	lockedUntil *time.Time,
) error

UpdateLockState atomically updates the failed attempt counter and lock expiry for a client.

type MySQLTokenRepository

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

MySQLTokenRepository implements Token persistence for MySQL. Uses BINARY(16) for UUIDs with transaction support via database.GetTx().

func NewMySQLTokenRepository

func NewMySQLTokenRepository(db *sql.DB) *MySQLTokenRepository

NewMySQLTokenRepository creates a new MySQL Token repository.

func (*MySQLTokenRepository) Create

func (m *MySQLTokenRepository) Create(ctx context.Context, token *authDomain.Token) error

Create inserts a new Token into the MySQL database using BINARY(16) for UUIDs. Uses transaction support via database.GetTx(). Returns an error if UUID marshaling or database insertion fails.

func (*MySQLTokenRepository) Get

Get retrieves a Token by ID from the MySQL database using BINARY(16) for UUIDs. Uses transaction support via database.GetTx(). Returns ErrTokenNotFound if the token doesn't exist, or an error if UUID unmarshaling or database query fails.

func (*MySQLTokenRepository) GetByTokenHash

func (m *MySQLTokenRepository) GetByTokenHash(
	ctx context.Context,
	tokenHash string,
) (*authDomain.Token, error)

GetByTokenHash retrieves a Token by token hash from the MySQL database using BINARY(16) for UUIDs. Uses transaction support via database.GetTx(). Returns ErrTokenNotFound if the token doesn't exist, or an error if UUID unmarshaling or database query fails.

func (*MySQLTokenRepository) Update

func (m *MySQLTokenRepository) Update(ctx context.Context, token *authDomain.Token) error

Update modifies an existing Token in the MySQL database using BINARY(16) for UUIDs. Uses transaction support via database.GetTx(). Returns an error if UUID marshaling or database update fails.

Jump to

Keyboard shortcuts

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