All Projects → catmullet → one

catmullet / one

Licence: MIT license
🚥 Idempotency Handler, for making sure incoming requests are idempotent. Useful for payments, "at least once delivery" systems and more.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to one

laravel-idempotency
Laravel Idempotency Middleware
Stars: ✭ 22 (+22.22%)
Mutual labels:  idempotent, idempotency
Ionic-2-sqlite-demo
Simple demo to show how to work with Sqlite Storage in Ionic 2
Stars: ✭ 20 (+11.11%)
Mutual labels:  storage
DemoInPutPasswordView
仿微信支付密码输入框 (A input password alert view like wechat pay.)
Stars: ✭ 44 (+144.44%)
Mutual labels:  payment
modernstorage
ModernStorage is a group of libraries that provide an abstraction layer over storage on Android to simplify its interactions
Stars: ✭ 982 (+5355.56%)
Mutual labels:  storage
laravel-viva-payments
A Laravel package for integrating the Viva Payments gateway
Stars: ✭ 29 (+61.11%)
Mutual labels:  payment
FoodiFi
FoodiFi App in flutter
Stars: ✭ 22 (+22.22%)
Mutual labels:  delivery
SimpleStorage
💾 Simplify Android Storage Access Framework for file management across API levels.
Stars: ✭ 498 (+2666.67%)
Mutual labels:  storage
EDS
💡 💾 💽 A simple, intuitive and Efficient single cell binary Data Storage format
Stars: ✭ 16 (-11.11%)
Mutual labels:  storage
minio-rclone-webdav-server
A @rclone served WebDAV server with @minio as the s3 storage backend docker example
Stars: ✭ 17 (-5.56%)
Mutual labels:  storage
iOS-Shared-CoreData-Storage-for-App-Groups
iOS Shared CoreData Storage for App Groups
Stars: ✭ 48 (+166.67%)
Mutual labels:  storage
drf-stripe-subscription
An out-of-box Django REST framework solution for payment and subscription management using Stripe.
Stars: ✭ 42 (+133.33%)
Mutual labels:  payment
ScopedStorageDemo
medium.com/better-programming/all-you-need-to-know-about-scoped-storage-in-android-10-e621f40bc8b9
Stars: ✭ 44 (+144.44%)
Mutual labels:  storage
lvm-localpv
CSI Driver for dynamic provisioning of Persistent Local Volumes for Kubernetes using LVM.
Stars: ✭ 86 (+377.78%)
Mutual labels:  storage
sqlweb
SqlWeb is an extension of JsStore which allows to use sql query for performing database operation in IndexedDB.
Stars: ✭ 38 (+111.11%)
Mutual labels:  storage
tag-storage
🗄CNCF Storage TAG
Stars: ✭ 94 (+422.22%)
Mutual labels:  storage
storage
Storage Standard
Stars: ✭ 92 (+411.11%)
Mutual labels:  storage
blobit
BlobIt - a Distributed Large Object Storage
Stars: ✭ 29 (+61.11%)
Mutual labels:  storage
perfmonger
No description or website provided.
Stars: ✭ 39 (+116.67%)
Mutual labels:  storage
crater
Open Source Invoicing Solution for Individuals & Businesses
Stars: ✭ 5,938 (+32888.89%)
Mutual labels:  payment
cruise
User space POSIX-like file system in main memory
Stars: ✭ 27 (+50%)
Mutual labels:  storage

one logo

(īdəmˌpōtənt) Idempotency Handler

Description

Easily check if you have recieved/processed an object before. Some examples may be:

  • Where PubSub services use "at least once delivery"
  • Cases of accepting requests to make payment
  • Deduping requests to your services

Getting Started

import the repo by running:

go get github.com/catmullet/one

import into your project

import github.com/catmullet/one

Creating Keys

The one.MakeKey() function takes in an array of any type and creates a key. This key is specific to the parameters you have passed in. If you pass in the exact same fields you will get the exact same key. Its how we tell if we are getting the same request. Choose Something that will give you a good indication that this is not the same object. you can be as strict or relaxed as you want with it.

Take for example this event from cloud storage

type Event struct {
  Bucket string
  Object string
  Version int
  UpdateTime time.Time
}

If you wanted to make sure that you never processed this storage object again you would use this:

key := one.MakeKey(event.Bucket, event.Object)

If you wanted to make sure you processed on every version update you would use this:

key := one.MakeKey(event.Bucket, event.Object, event.Version)

If you wanted to process based on any change to the storage object you could pass in the entire object like this:

key := one.MakeKey(event)

Redis

// import "gopkg.in/redis.v5" for redis.Options

options := &redis.Options{
		Network:            "tcp",
		Addr:               "localhost:6379",
		Dialer:             nil,
		Password:           "",
		DB:                 0,
	}
  
var oneStore OneStore
oneStore = redisstore.NewRedisOneStore(options, time.Second * 30)

Add Keys

ok, err := oneStore.Add(key)
if !ok {
  // Key already exists, so handle that here.
}

// Key doesn't exist and was added to the one store
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].