wybiral/hookah

User defined protocols

wybiral opened this issue · 1 comments

Two new methods should be introduced:

  • hookah.RegisterInput(proto string, fn func(arg string) (io.ReadCloser, error))
  • hookah.RegisterOutput(proto string, fn func(arg string) (io.WriteCloser, error))

This would allow user code to implement any arbitrary input/output type which would make testing easier and allow for more interesting forms of integration.

This should be included in v0.1.0

Side note: by v1.0.0 it might make sense to move all existing protocols to be added with this mechanism which would likely require the addition of a new root hookah app/client instance and a constructor.

A draft of this is implemented here: https://github.com/wybiral/hookah/tree/register

Unfortunately the only way I can think of to get the existing protocols to use the same strategy would be to require the whole hookah API to require a constructor, like:

h := hookah.New()

That way the New constructor could do the map assignments. I'm not opposed to the idea, but it would require a large rewrite and major version increment.