You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
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
importgithub.com/catmullet/one
Creating Keys
Theone.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.
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.Optionsoptions:=&redis.Options{Network:"tcp",Addr:"localhost:6379",Dialer:nil,Password:"",DB:0,}varoneStoreOneStoreoneStore=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
About
🚥 Idempotency Handler, for making sure incoming requests are idempotent. Useful for payments, "at least once delivery" systems and more.