superfly / corrosion

Gossip-based service discovery (and more) for large distributed systems.
https://superfly.github.io/corrosion/
Apache License 2.0
624 stars 19 forks source link

client implementations #216

Open gedw99 opened 1 month ago

gedw99 commented 1 month ago

the docs reference basic rust one here: https://superfly.github.io/corrosion/api/subscriptions.html#client-implementation-guide

But I expect that Js and Golang and other devs would like some simple examples for using the API from their languages. Especially the Subscriptions.

https://superfly.github.io/corrosion/api/subscriptions.html#reconnections-and-retries begs the question of letting clients have a list of other Corrosion servers so that they can load balance in case the current one disappears. https://github.com/superfly/corrosion/pull/181 is the rust one.

gedw99 commented 1 month ago

I am looking for a golang client that can easily parse the subscriptions.

I wil then use nats Jetstream to de-duplicate the subscription feed so only one of the golang servers processes the changes . It’s quite important that only 1 golang server processes the changes of course.

Here is the NATS Jetstream reference

https://nats.io/blog/new-per-subject-discard-policy/

each subject is a sql subscription … or something like that.

Testing this is not easy . 5 data servers on fly with nats , corrosion on each server and a client in each geographical region . Try all run their tests and then the final aggregated result needs to be checked . Always fun . Fly does make this much easier at least than other offerings.

gedw99 commented 1 month ago

It looks like shadow dom and html out of order streaming is the way to go for making a simple example.

this is a golang example.

https://github.com/ryoid/go-streaming-html-ooo

This is the same using node.

https://kodus.pl/#close

—-

What I like is that is that it is alarmingly simple , and takes advantage if corrosion subscriptions.

For the browser it’s using the shadow dom and slots . https://developer.chrome.com/docs/css-ui/declarative-shadow-dom Works on all browsers now.

jeromegn commented 1 month ago

For reference, we are using this code for subscriptions from Go: https://gist.github.com/jeromegn/22d88b1b0399b40d4a714b4367dec430

gedw99 commented 1 month ago

thanks @jeromegn

I was going to use https://github.com/olivere/ndjson as the Corrosion docs said its that format structure.

I have had little time to dig into this, so some of my questions are probably naive, but :

Yours is a generic parser of ndjson ? Yours does not require types be setup ?