# Help writing a streaming binary codec

**URL:** <https://discuss.elastic.co/t/help-writing-a-streaming-binary-codec/110986>\
**Category:** Logstash\
**Created:** [December 10, 2017, 8:45pm UTC](https://discuss.elastic.co/t/help-writing-a-streaming-binary-codec/110986 "2017-12-10T20:45:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zslayton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zslayton/32/25357_2.png) [@zslayton](https://discuss.elastic.co/u/zslayton)\
**Post date:** [December 10, 2017, 8:45pm UTC](https://discuss.elastic.co/t/help-writing-a-streaming-binary-codec/110986/1 "2017-12-10T20:45:32Z")

</div>

Hi all,

I'd like to create a codec to decode [Ion, a binary data format](https://amzn.github.io/ion-docs/binary.html). I'm new to both LogStash and Ruby.

The [`Codec` how-to](https://www.elastic.co/guide/en/logstash/6.0/_how_to_write_a_logstash_codec_plugin.html) shows that I need to define a `decode` method that accepts a single parameter: a variable called `data`.

What type is `data`? The [docs for input plugins](https://www.elastic.co/guide/en/logstash/current/_how_to_write_a_logstash_input_plugin.html#_literal_run_literal_method) appear to indicate that `data` will be a `String` containing the bytes that were last read from the input. Is that right?

I'm concerned that `data` might contain an incomplete `Event`. That would mean that a parser would not be able to do anything with it when it was passed in.

Since the `decode` method `yield`s events as it decodes them, would it be possible to have some sort of `InputStream`-type value instead of a `String`?

Thanks for any guidance!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 7, 2018, 8:46pm UTC](https://discuss.elastic.co/t/help-writing-a-streaming-binary-codec/110986/2 "2018-01-07T20:46:16Z")

</div>

Closed on January 7, 2018, 8:46pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
