idempotency

package
v2.4.39 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 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 IdempotencyRequest

type IdempotencyRequest struct {
	Key             string        `db:"idempotency_key"`
	Status          Status        `db:"status"`
	ResponseCode    sql.NullInt64 `db:"response_code"`
	ResponseHeaders []byte        `db:"response_headers"`
	ResponseBody    []byte        `db:"response_body"`
	CreatedAt       time.Time     `db:"created_at"`
	UpdatedAt       sql.NullTime  `db:"updated_at"`
}

IdempotencyRequest represents a stored request in the database.

type IdempotencyStore

type IdempotencyStore interface {
	io.Closer
	Get(ctx context.Context, key string) (*IdempotencyRequest, error)
	Create(ctx context.Context, key string) error
	Update(ctx context.Context, key string, code int, headers, body []byte) error
	Error(ctx context.Context, key string, code int, headers, body []byte) error
	Cleanup(ctx context.Context) error
	DB() *sqlx.DB
}

func NewIdempotencyStore

func NewIdempotencyStore(db *sqlx.DB, cleanUpThresholdInDays int) (IdempotencyStore, error)

NewIdempotencyStore creates a new store for idempotency checks.

type Status

type Status string
const (
	Error     Status = "error"
	Pending   Status = "pending"
	Completed Status = "completed"
)

Jump to

Keyboard shortcuts

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