idempotency

package module
v0.0.0-...-cbeab30 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2025 License: MIT Imports: 7 Imported by: 0

README

idemgotency-postgres

idempotency library for go with PostgreSQL

Pre-requisite

  • Setup the dsn string
  • Create tables with schema.sql

How to use

  • Just call idempotency.ExecuteExactlyOne with default timeout is 3 seconds (you can fix it by yourself)
  • With customized timeout function, use idempotency.ExecuteExactlyOneWithTimeout

Note

  • The return result of your function should be in json format (yes, you have to marshall/unmarshall by your own)
  • With void function, you should return state of result in string like: SUCCESS/FAILURE/PENDING/...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EndProcess

func EndProcess(processName string, idempotencyKey uuid.UUID) error

func ExecuteExactlyOne

func ExecuteExactlyOne(fnc func() (string, error), idempotencyKey uuid.UUID, processName string, operationName string) (string, error)

ExecuteExactlyOne is a common function that to use to apply idempotency idea Input:

  • fnc: function need to be executed as an idempotency function
  • idempotencyKey: is in UUIDv4 format
  • processName
  • operationName

func StartProcess

func StartProcess(processName string, idempotencyKey uuid.UUID, timeout time.Duration, body string) error

StartProcess Init executor Try to lock process with idempotencyKey Validate input of request

Types

This section is empty.

Jump to

Keyboard shortcuts

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