-
-
Notifications
You must be signed in to change notification settings - Fork 76
Integrate NATS client #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
wez
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
I have to confess that I hadn't encountered NATS until now.
I think the code looks reasonable!
We'll need to have some tests in here to verify that things are behaving reasonably.
I'd suggest using https://docs.rs/testcontainers-modules/latest/testcontainers_modules/nats/index.html to spawn a NATS container. Look at crates/integration-tests/src/rabbit.rs to see how we do the rabbitmq tests using testcontainers.
The rabbit tests load the "default" crates/integration-tests/source.lua policy file, which is now getting a bit overloaded with various env vars for different tests, so I'd suggest making a new dedicated test policy file for nats.
Please take a look at these two recent PRs for more general discussion on integration tests to see how to accommodate an alternate policy file for testing:
|
Thanks for your suggestions! I have implemented Keysource for credentials, as well as integration tests that test message publishing. |
1ba361f to
3a81380
Compare
Publish messages using the jetstream client.
Supports password and token authentication.
usage:
```
local nats = kumo.nats.connect {
servers = {"127.0.0.1:4222"},
}
nats:publish {
subject = "my.subject",
payload = "my payload",
headers = {
["Nats-Msg-Id"] = "unique-message-id",
},
await_ack = true,
}
nats:close()
```
Apply suggestions from code review
Co-authored-by: Wez Furlong <[email protected]>
Hello folks,
I'm proposing a NATS integration for kumo to publish messages to NATS servers with JetStream enabled. I think this is a good use case, since NATS is pretty popular, especially in the cloud-native environment. It supports publishing messages and authenticates itself via password or token. Unlike mod-kafka, a builder pattern is used in Rust, so the Lua input must be translated. The proposal employs the async-nats crate.
The interface looks like this:
I haven't written any documentation yet, as I wanted to wait for your response first.