repository

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package repository implements data persistence for tokenization key and token management. Supports versioning, soft deletion, deterministic token lookups, and PostgreSQL persistence.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TokenRepository added in v0.29.0

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

TokenRepository implements token persistence for PostgreSQL databases.

func NewTokenRepository added in v0.29.0

func NewTokenRepository(db *sql.DB) *TokenRepository

NewTokenRepository creates a new PostgreSQL token repository instance.

func (*TokenRepository) CountExpired added in v0.29.0

func (p *TokenRepository) CountExpired(ctx context.Context, olderThan time.Time) (int64, error)

CountExpired counts tokens that expired before the specified timestamp without deleting them. Returns the count of matching tokens. Uses transaction support via database.GetTx(). All timestamps are expected in UTC.

func (*TokenRepository) Create added in v0.29.0

func (p *TokenRepository) Create(
	ctx context.Context,
	token *tokenizationDomain.Token,
) error

Create inserts a new token mapping into the PostgreSQL database.

func (*TokenRepository) CreateBatch added in v0.29.0

func (p *TokenRepository) CreateBatch(
	ctx context.Context,
	tokens []*tokenizationDomain.Token,
) error

CreateBatch inserts multiple token mappings into the PostgreSQL database.

func (*TokenRepository) DeleteExpired added in v0.29.0

func (p *TokenRepository) DeleteExpired(ctx context.Context, olderThan time.Time) (int64, error)

DeleteExpired deletes tokens that expired before the specified timestamp. Returns the number of deleted tokens. Uses transaction support via database.GetTx(). All timestamps are expected in UTC.

func (*TokenRepository) GetBatchByTokens added in v0.29.0

func (p *TokenRepository) GetBatchByTokens(
	ctx context.Context,
	tokenStrings []string,
) ([]*tokenizationDomain.Token, error)

GetBatchByTokens retrieves multiple token mappings by their token strings.

func (*TokenRepository) GetByToken added in v0.29.0

func (p *TokenRepository) GetByToken(
	ctx context.Context,
	tokenStr string,
) (*tokenizationDomain.Token, error)

GetByToken retrieves a token mapping by its token string.

func (*TokenRepository) GetByValueHash added in v0.29.0

func (p *TokenRepository) GetByValueHash(
	ctx context.Context,
	keyID uuid.UUID,
	valueHash string,
) (*tokenizationDomain.Token, error)

GetByValueHash retrieves a token by its value hash (for deterministic mode).

func (*TokenRepository) Revoke added in v0.29.0

func (p *TokenRepository) Revoke(ctx context.Context, tokenStr string) error

Revoke marks a token as revoked by setting its revoked_at timestamp.

type TokenizationKeyRepository added in v0.29.0

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

TokenizationKeyRepository implements tokenization key persistence for PostgreSQL databases.

func NewTokenizationKeyRepository added in v0.29.0

func NewTokenizationKeyRepository(db *sql.DB) *TokenizationKeyRepository

NewTokenizationKeyRepository creates a new PostgreSQL tokenization key repository instance.

func (*TokenizationKeyRepository) Create added in v0.29.0

Create inserts a new tokenization key into the PostgreSQL database.

func (*TokenizationKeyRepository) Delete added in v0.29.0

func (p *TokenizationKeyRepository) Delete(ctx context.Context, name string) error

Delete soft-deletes a tokenization key by setting its deleted_at timestamp.

func (*TokenizationKeyRepository) Get added in v0.29.0

Get retrieves a tokenization key by its ID.

func (*TokenizationKeyRepository) GetByName added in v0.29.0

GetByName retrieves the latest non-deleted version of a tokenization key by name.

func (*TokenizationKeyRepository) GetByNameAndVersion added in v0.29.0

func (p *TokenizationKeyRepository) GetByNameAndVersion(
	ctx context.Context,
	name string,
	version uint,
) (*tokenizationDomain.TokenizationKey, error)

GetByNameAndVersion retrieves a specific version of a tokenization key by name and version.

func (*TokenizationKeyRepository) HardDelete added in v0.29.0

func (p *TokenizationKeyRepository) HardDelete(
	ctx context.Context,
	olderThan time.Time,
	dryRun bool,
) (int64, error)

HardDelete permanently removes soft-deleted tokenization keys and their associated tokens.

func (*TokenizationKeyRepository) ListCursor added in v0.29.0

func (p *TokenizationKeyRepository) ListCursor(
	ctx context.Context,
	afterName *string,
	limit int,
) ([]*tokenizationDomain.TokenizationKey, error)

ListCursor retrieves tokenization keys ordered by name ascending using cursor-based pagination. Returns the latest version for each key.

Jump to

Keyboard shortcuts

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