Add synchronous codec encode method to aid in testing, debugging
Open
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
Assessment
This issue has not been assessed yet.