SimpleSequence
SimpleSequence
SimpleSequence is a microservice for generating sequence numbers built on an appropriately leveraged, massively scalable AWS infrastructure: API Gateway, Lambda functions, and DynamoDB. The lambda source code is freely available
Why?
If you’ve built a system of any complexity, you’ve neeeded sequences. Most databases have them. But sometimes you need a database independent way to generate an increasing series of numbers, with no collisions. There are many ways to do this: this is one. Inspired by https://timercheck.io/
Create a new sequence
curl -XGET 'https://api.prohakr.com/sequence/YOURSEQUENCENAME'
{
"firstNumber": 1,
"lastNumber": 1
}
That’s it. You don’t need an API token, to create an account, or log in. The first HTTP GET you issue will create the sequence. If you don’t want somebody else to use your sequence name, pick something unguessable like a GUID
Get next number in the sequence
curl -XGET 'https://api.prohakr.com/sequence/YOURSEQUENCENAME'
{
"firstNumber": 2,
"lastNumber": 2
}
curl -XGET 'https://api.prohakr.com/sequence/YOURSEQUENCENAME'
{
"firstNumber": 3,
"lastNumber": 3
}
curl -XGET 'https://api.prohakr.com/sequence/YOURSEQUENCENAME'
{
"firstNumber": 4,
"lastNumber": 4
}
Each HTTP GET will return the next number. Distinct HTTP GET requests will never return the same number.
Concurrency
If more than one process is issuing HTTP GET requests, you might see something like this in one of your processes
curl -XGET 'https://api.prohakr.com/sequence/YOURSEQUENCENAME'
{
"firstNumber": 5,
"lastNumber": 5
}
curl -XGET 'https://api.prohakr.com/sequence/YOURSEQUENCENAME'
{
"firstNumber": 17,
"lastNumber": 17
}
curl -XGET 'https://api.prohakr.com/sequence/YOURSEQUENCENAME'
{
"firstNumber": 209,
"lastNumber": 209
}
Set the sequence to a specific number
curl -XGET 'https://api.prohakr.com/sequence/YOURSEQUENCENAME/1000'
{
"firstNumber": 1000,
"lastNumber": 1000
}
curl -XGET 'https://api.prohakr.com/sequence/YOURSEQUENCENAME'
{
"firstNumber": 1001,
"lastNumber": 1001
}
curl -XGET 'https://api.prohakr.com/sequence/YOURSEQUENCENAME'
{
"firstNumber": 1002,
"lastNumber": 1002
}
Retrieve a block of IDs
curl -XGET 'https://api.prohakr.com/sequence/YOURSEQUENCENAME?take=5'
{
"firstNumber": 12,
"lastNumber": 16
}
curl -XGET 'https://api.prohakr.com/sequence/YOURSEQUENCENAME?take=3'
{
"firstNumber": 17,
"lastNumber": 19
}
Guarantees
Absolutely none. I’m running this for free, as a service. But anything could change: I reserve the right to fully manage the system, restrict it’s use, or change it’s terms of use. There could be flaws, the system can go down, or might go away.
On the other hand, perhaps SimpleSequence.io will take over the world – in which case I will change the terms and introduce a pricing model.
If you’d like more than absolutely no guarantee, contact me. Perhaps we could work something out.