Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I made a dead simple Rails application that demonstrates how to use NATS Ruby client withing Rails application using new additions.
However, I'm incredibly bad at coming up with arbitrary examples, so for now idea is dumb: there is a web form which upon submit doesn't create a database record directly (as most typical applications do) but instead publishes a message into NATS and let different process to receive it and create database record instead.
Share your ideas, so I can add more interesting stuff.
Also for now it is not very pleasantly looking one (but this also can be fixed):
README.md
Files of interest:
config/initializers/nats.rb
— initialization of the NATS client early using lazy connection.app/controllers/test_controller.rb
— example of the controller.bin/nats-listener
— example of the separate standalone process.Main client features shown in the example:
A (somewhat artificial) distributed workflow:
Installation
This app has a Docker-first configuration based one the Ruby on Whales post.
You need:
Docker installed. For MacOS just use official app.
Dip installed.
Run the following command to build images and provision the application:
Running
You can start Rails server along with AnyCable by running:
Then go to http://localhost:3000/ and see the application in action.