Closed unscriptable closed 5 years ago
Hey @unscriptable, thanks for sharing this. It's quite different from other examples, and that's one reason I really like it. After skimming the code and trying it out locally, here are a couple initial thoughts to kick off the discussion of what we might want to add:
What do you think of those? Do they spark any additional ideas?
As for where to put it, the two most obvious choices in my mind are the most/core examples dir in this repo and giving it its own repo in mostjs-community. If the latter, then we could link to it from the examples page of the most/core docs.
What are your thoughts?
Filtering, merging (would require another stream), transforming (perhaps scan
or loop
), could make this example interesting as a most.js example. The code could also benefit from a few more comments showing intent.
All in all, I like the closer-to-a-real-world application this example has. Thank you, @unscriptable.
The original use case (that I never finished) was to watch for two signals on a single channel, combine them, and emit the result onto a second channel, but I'm cool with whatever we think is best. I'm going to continue working on the instructions and other docs while we think of a useful use case.
If we separate the publisher and subscriber into separate apps/containers, we could show two use cases: most
as a generator of events and most
as a consumer of events.
most
as a generator of events andmost
as a consumer of events.
👍 Yeah, that's what I was thinking, too. Showing both would be nice, and imho, using separate containers will make the whole thing more realistic, regardless of whatever kind of map/filter/merge/scan/loop things we decide on.
Here's one idea that just popped into my head:
One publisher and multiple consumer containers, where each consumer uses a filter to watch for specific messages. Each consumer logs matching messages with some consumer-specific tag, so they're distinguishable in docker-compose logs
. Two consumers is probably enough. Being able to start any number of consumer containers, each with its own filter could be an extra credit goal.
Does something like that seem interesting and within the amount of effort you're ok with?
I'm going to continue working on the instructions and other docs while we think of a useful use case.
Great, thanks!
I think this is getting close. It still need to do more than just tap()
, but I'll do that soon. I'd like to move it to its final destination. It mostjs-community the right place or @most/core/examples?
Latest is here: https://gist.github.com/unscriptable/5fc29408bedfdceb545c69e22f1f0bc0 I removed a lot of cruft.
Awesome, thanks @unscriptable. I should have time to look at it this weekend.
mostjs-community the right place or @most/core/examples?
I'll give it more thought. Any strong preference, @davidchase, @Frikki, @TylorS ?
lovely work @unscriptable i think the @most/core/examples
makes the most sense to me personally with maybe a link from the docs https://mostcore.readthedocs.io/en/latest/getting-started.html#examples just incase folks click that when they first hit the repo or have it bookmarked 🤷♂️
I agree with @davidchase
It still need to do more than just
tap()
, but I'll do that soon.
I assume that you refer to tap()
in the consume.js file and not tapping the emitPeriodicMonotonicNumbers
stream in publish.js, @unscriptable.
lovely work @unscriptable
Thanks. Very glad to find a way to contribute to such as awesome project. :)
i think the
@most/core/examples
makes the most sense
I'll create a PR accordingly.
I assume that you refer to
tap()
in the consume.js file
Yah. I've got an idea brewing. I'll try my idea and then do a PR so you can comment on it directly.
Wait. I just realized that there's https://github.com/mostjs/examples and (a whole repo) and https://github.com/mostjs/core/tree/master/examples (a subdir of mostjs/core repo). What's the difference and which is the right one for me to use?
One of my customers wanted to process pub-sub events from redis. I suggested using most.js and started creating a POC for them, but stopped early on because they decided to go a different direction. I decided to try to finish the POC on my own, anyways.
The code is in this gist. It's a very rough example, atm, but I could make it more interesting. The POC includes a Dockerfile and a docker-compose.yml file, but can also be run without docker.
Is this of interest? If so, what would you want to see in such an example and where should I put it?