idempotency

package
v2.10.55 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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