mhart / gelf-stream

A node.js stream to send JS objects to a Graylog2 server (in GELF format)
Other
29 stars 13 forks source link

Implement standard stream.Writeable interface #7

Closed milas closed 9 years ago

milas commented 9 years ago

Inherit from stream.Writeable and implement a _write() function, allowing the core library to take care of all other concerns. A destroy() method is added, and invoked after finish is emitted, which closes the underlying UDP client and emits a close event.

This supersedes #6. See that PR for my rationale for this. The big win is that if end() is called, it should wait until any outstanding client.send() calls finish before invoking the callback, and then destroying itself.

mhart commented 9 years ago

Awesome – thanks for writing this!

A couple of observations:

  1. This uses the Streams 2 interface, so will only be compatible with Node >= 0.10 from now on. I'm totally fine with this and I'll just bump the major version.
  2. Some minor style deviations (semicolons!) – I'll comment on them in the diff.

Apart from that, looks great, thanks again.

milas commented 9 years ago

Agh, thanks for pointing out the semi-colons! I tried to match the existing style where possible, but old habits die hard, and a couple slipped through.

Between my initial PR and this one, I realized this project was targeting 0.8, which explained why the implementation was such in the first place. Glad you're okay with making the jump to >0.10!

And thanks for this package -- using it with Bunyan + Graylog2 has been fantastic so far.

mhart commented 9 years ago

Brilliant, merging!

mhart commented 9 years ago

Released as v1.0.0 – thanks again, and glad it's working well for you – I haven't used it in ages! :smile_cat: