elastic / elastic/logstash

Add synchronous codec encode method to aid in testing, debugging

Open
#3,486 21 comments 0 reactions 1 assignee Claimed by @andrewvc View on GitHub
breaking change discuss enhancement
Dominant language
Java
Stars
14.9k
Forks
3.5k
Avg merge
19h 14m
Merged PRs (30d)
63

Description

Mocking out a codec for plugin testing is irritatingly hard due to the async API. While the async api is fine, I believe the synchronous logic should be wrapped in a blocking `#encode_sync` method. That would make tests like this:

``` ruby
let(:encoded) {
c = subject.codec.clone
result = nil;
c.on_event {|event, encoded| result = encoded }
c.encode(event)
result
}
```

look like this:

``` ruby
let(:encoded) { subject.codec.encode_sync(event) }
```

This was inspired by the discussion over this PR on the SNS input: https://github.com/logstash-plugins/logstash-output-sns/pull/6/files#r32961911

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.