idempotency

package
v3.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

package idempotency contains the services in charge of generating a unique keys to be passed in POST requests to ensure operation uniqueness.

See: https://docs.mollie.com/overview/api-idempotency

The std generator uses google's uuid library to return a new uuid as unique idempotency key.

You can build your own generator and pass it to the library by implementing the KeyGenerator interface.

Index

Constants

View Source
const (
	TestKeyExpected = "test_ikg_key"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyGenerator

type KeyGenerator interface {
	// Generate encapsulates the logic to return a string representation of
	// a unique idempotency key.
	Generate() string
}

KeyGenerator describes the service in charge of generating a unique idempotency key to be passed in POST requests to ensure operation uniqueness.

See: https://docs.mollie.com/overview/api-idempotency

func NewNopGenerator

func NewNopGenerator(exp string) KeyGenerator

NewNopGenerator returns a dummy implementation of the IdempotencyKeyGenerator interface.

Good for testing or when a predictable result is required.

If exp is an empty string, then TestKeyExpected is used as default value for the NOpGenerator.

func NewStdGenerator

func NewStdGenerator() KeyGenerator

NewStdGenerator returns an standard and common way of generating idempotency unique keys.

Jump to

Keyboard shortcuts

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