Add LineParserPlugin base class or LineDecoder bridge for Ruby #231

Open
frsyuki opened this Issue Jul 7, 2015 · 0 comments

Projects

None yet

1 participant

@frsyuki
Contributor
frsyuki commented Jul 7, 2015

There are no simple way to initialize LineDecoder in Ruby. However, a lot of parser plugin (especially simple plugins) are based on lines. Plugins should not have these lines: https://github.com/treasure-data/embulk-parser-query_string/blob/261cec3a69d9ecf840fb560e4f36c6d0c53138d3/lib/embulk/parser/query_string.rb#L13

A discussion point is the design of bridge or mixin. This design can be reused when we want to have many other utilities for each domains.

Design options:

  • Utility class: add LineDecoder class. Plugins needs to get configuration parameters from config, and pass them to the constructor of LineDecoder class.
    • Pros: Loosely-coupled. Easy to test. Less likely to break backward compatibility when changed.
    • Cons: Getting config parameters from config in plugin code is very verbose.
  • Base class: add LineParserPlugin class. Plugins extend the class and override `run(line_decoder)@ method.
    • Pros: Minimum amount of code (in plugin).
    • Cons: Difficult to use with other base classes because Ruby uses single inheritance. We often miss to call super because we need to call super in some cases but we must not call super in the other cases (inconsistent).
  • Mixin: add LineParserPluginMixin module. Plugins include the module.
    • Pros: small amount of code (in plugin), and no need of super call.
    • Cons: Difficult to design consistent API. Avoid mess of many mixins.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment