Fork me on GitHub
#off-topic
<
2017-11-20
>
pesterhazy15:11:15

Is there a counter API - a counter-as-a-service?

pesterhazy15:11:02

POST /api/counter?id=1234
Content-Length: n

5

pesterhazy15:11:14

each POST returns a new number?

pesterhazy15:11:04

Somebody must have built this

mnzt15:11:47

http://numeri.xyz First result on google for "counter as a service"

pesterhazy15:11:09

@mnzt, lol - I google for a bit but not with those search terms

mnzt15:11:28

😄 All about the foogle 😉

pesterhazy15:11:02

I feel as if I just willed an API into existence - just by insisting that it must exist

pesterhazy15:11:20

that API is perfect 🙂

danm15:11:58

We have an internal one that works very similarly. Written in Clojure too 😉

danm15:11:04

Not accessible to the world though

pesterhazy15:11:37

@carr0t let me guess - builder numbers?

danm15:11:57

builder numbers?

pesterhazy15:11:57

I meant "build numbers", sorry

pesterhazy15:11:25

that's my use case - a source for sequential serial numbers to use as a build number, without worrying about atomic data store

danm15:11:00

Aah, no. We track changes to a database, and want to identify, given 2 arbitrary events both of which represent a change, which came first

danm15:11:42

So we get them in order, the first thing we do more or less is assign each event a unique incrementing ID, and from then on anywhere we need to compare events and know which came first we can, and ordering becomes much less of an issue

borkdude15:11:43

@pesterhazy why not use a uuid for that

borkdude15:11:55

oh order, I see

borkdude15:11:16

UUID version 1 has a time-based component in it though. But an obvious solution would be to build this service yourself and just use increasing longs or whatever

borkdude15:11:01

Or if you’re using a database that all your services are talking to you could (ab)use that, by having an autoincrementing id 🙂

danm15:11:25

One of our legacy systems does that. It doesn't scale so well for large numbers of updates 😉

borkdude15:11:12

Add a database, just run a docker container 😉

borkdude15:11:44

I guess first requesting an id from a service also would be terribly slow with a large number of updates

danm15:11:57

The Clojure version basically grabs a 'block' of IDs per prefix, 10000 at a time, and hands them out as fast as requests can be made. If the service restarts or whatever we lose the remaining IDs from that block, but don't actually care

danm15:11:02

Each service uses a different prefix, so we only actually pay the cost in anything other than memory comparatively rarely

danm15:11:38

Can be a remote HTTP service, or just a local lib. But the local lib only works if you are sure you won't have 2 services using the same prefix

borkdude15:11:18

sounds good

bja16:11:43

you might look up "snowflake" or "flake" IDs

bja16:11:38

there are a bunch of java/clojure implementations and variations that are either coordinated over the network or uncoordinated (relying on something like ms precision over network time plus some number of bits for randomness)

bja16:11:53

it depends on your use case what you actually need

danm16:11:10

We considered flake IDs but they didn't fit our requirements. It was a good few months ago now though so I can't immediately recall why

borkdude16:11:27

@carr0t > you make a network call to get a unique ID this is probably the reason you didn’t choose this one (don’t know if that Twitter thing can generate many at once)

borkdude16:11:45

Also it seems they deprecated that library in favor of Finagle

bja16:11:46

I've used implementations that maintain a thread-safe collection of IDs in a background thread such that each request doesn't need to do a network call

bja16:11:23

I've also used them where there was no network coordination and relied on some number of bits identifying a shard or being something like timeset from an epoch + bits of randomness

Functional-Tom16:11:13

Hey Everyone! We are looking for more content for our new and shiny Blog feature. See here: https://goo.gl/yBzwpj - As long as it is related to functional programming it will be relevant. So if you have a side project you are particularly proud of, or maybe you are a regular writer of a blog and fancy giving it a new audience, please don't hesitate to get in touch!

pesterhazy17:11:18

@borkdude I would have loved to use something that doesn't require coordination, but the requirements are that it has to be sequential

qqq17:11:28

I need naming help. I'm building a GUI. I need a word to capture "state of entire screen" on a laptop/desktop, I would use the word "desktop" for a phone/tablet, what is the right word?

vemv17:11:17

home screen?

qqq17:11:57

home-screen brings up images of a phone showing all apps as icons

vemv17:11:17

I thought that's what you meant by desktop 😜

qqq17:11:21

is that what 'desktop' means ? I thought it was this system where you had windows + you could drag them around

qqq17:11:31

maybe what I meant to say is 'window manager'

vemv17:11:57

I'd say most people would use desktop for 'initial screen with a wallpaper and some shortcuts'

qqq18:11:38

alright, so I guess I really want is the phone/tablet version of "windowManager" - but that doesn't really exist since most phones/tablets either single task or splits creen at most

noisesmith18:11:43

@qqq the current android has more arbitrary window management (not to say it’s intuitive to use, but it’s more than just split windows)

vemv18:11:31

mobile-graphic-system?

noisesmith18:11:41

why not just “window-manager” or “window-system”