-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat(new sink): New nats
sink
#3605
Conversation
To begin with, the code is basically just a straight copy of the console sink. I copied some of the structure from various PRs I found in the repo, but definitely am missing a ton of things like documentation and metadata. |
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
Hi @erhlee-bird! Thanks for contributing. Anything we can help with here to get this out of draft? |
Hey @jamtur01, I just started looking at this again today. I've verified that I have a steel-thread running via hand-jammed integration tests. I believe the next steps are
Am I missing anything there?
|
We just replaced the |
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
@jamtur01, I think current is ready for review! Thanks for the poke |
@erhlee-bird Looks like you just need to run
Will work. |
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
I'm not sure why the cue docs check is failing. |
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.
This is a great, thanks @erhlee-bird . I left some inline comments to address, but it is pretty close.
In addition to the in-line comments, I'd like to see us handle failed publishes differently by:
- Using the
acker()
from theSinkContext
(available inbuild
) to only ack messages that were successfully published - Retry failed publishes indefinitely
- Set
reconnect_buffer_size
on the nats client to 0 bytes so that the client doesn't buffer internally (to avoid message loss)
You can see the kafka
sink for an example of the acking (open https://github.com/timberio/vector/blob/master/src/sinks/kafka.rs and search for "ack"). This will allow messages to sit in an intermediate buffer in vector until they can successfully be published to nats
.
Let me know if that isn't clear.
Just noting that we should probably follow this work up with:
- TLS support
- Credentials support (user/pass, token, credentials file, nkey)
We can open separate issues for those once this is merged.
Thanks again!
} | ||
|
||
configuration: { | ||
url: { |
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.
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.
Yeah I saw the endpoint for other examples like Pulsar that looked similar.
I set it to url
just to try and mimic the verbiage used by the nats.go library and the nats.io docs, but totally understand if it would make more sense to stay consistent within Vector context.
src/sinks/nats.rs
Outdated
impl NatsSink { | ||
fn new(config: NatsSinkConfig) -> Self { | ||
let options = nats::Options::new(); | ||
let nc = options.connect(&config.url).unwrap(); |
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.
This method seems to initialize the outbound connection, which we generally try to avoid during component build time. Could we defer the connect to the run
method? We should emit an error and propagate up an Err
if it fails to connect (rather than panicing). I do note that it handles reconnects internally.
Also, could we set a user configurable name here? https://docs.rs/nats/0.8.0/nats/struct.Options.html#method.with_name . We could default to vector
but let users override in the config.
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.
Added a separate connect
function to the SinkConfig.
Added the name config item.
I neglected that we aren't supporting |
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
@jszwedko I think I addressed all of your comments and am ready for another review. |
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.
A few last comments, but otherwise this looks good! Thanks for all of your work @erhlee-bird
And yes, @praveenperera , if you could sign-off the two commits, that would fix the DCO check.
I would like to get one more review on this just given it is a new component. |
Hey i’m not sure how to sign off on old commits. Since there have been new commits by @erhlee-bird after mine. I could rebase but don’t think I have permission to write to this branch. |
bbd7cf2
to
49d8c1b
Compare
@praveenperera 👍 it looks like you have access now at least? I think you can:
|
Signed-off-by: Praveen Perera <praveen@avencera.com>
Signed-off-by: Praveen Perera <praveen@avencera.com>
Store `nats::Options` in owned struct
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
49d8c1b
to
78d85a0
Compare
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
Signed-off-by: Eric Lee <erhlee.bird@gmail.com>
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.
I pushed one more commit adding the integration tests to CI and an example of templating for the subject
config.
Otherwise, this looks good to me! Thanks for pushing this over the line @erhlee-bird and @praveenperera !
And template example for subject config Signed-off-by: Jesse Szwedko <jesse@szwedko.me>
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.
Looks good to me!
@erhlee-bird @praveenperera Thanks! Awesome contribution. |
Co-authored-by: James Turnbull <james@lovedthanlost.net> Co-authored-by: Praveen Perera <ppraveen25@gmail.com> Co-authored-by: Jesse Szwedko <jesse@szwedko.me> Signed-off-by: Brian Menges <brian.menges@anaplan.com>
Introduces a new NATS log sink.
Closes #1399.