-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge listener and replay functionality #46
Conversation
I like the idea and new, clean flag names. |
This is also allow to bring much more Go-like architecture with simple modules and interfaces. |
👍 from me. |
@slawosz @dcarley pls check this branch, concept is working, and it's more awesome than i thought :) https://github.com/buger/gor/tree/modules_refactoring You can start by playing like this:
And continue with smth like:
|
So, after 2 minutes of looking (no more time now :() here is core of gor now?: https://github.com/buger/gor/blob/modules_refactoring/emitter.go#L20 Each type of i/o implements io.{Read,Write} and uses |
Wow, I like the look of it. Will have a play around. |
@slawosz basically yes. Input and Output just satisfy standard io.Reader and io.Writer interfaces, which gives you ability to use any standard library (bufio ?). |
It is beautiful piece of code 👍 |
Converted issue to pull-request |
|
||
func (i *RAWInput) Read(data []byte) (int, error) { | ||
buf := <-i.data | ||
copy(data, buf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we have copy here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's not needed here. Just want to make sure that data will be immutable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, btw, i remembered. It needed :)
Thing is that io.Reader interface says that Read
function should received slice as argument and we should write to it.
If i just do data = buf
it will rewrite original data
pointer, and original data
still be empty. Thats why we use copy.
This pull-request is long-going, and require adding lot of tests. Also it not support rate-limiting. |
Oh, testing right now will be much easier :) |
Added custom headers and ElasticSearch plugin. Also added option to round-robin traffic if have multiple outputs:
|
Merge listener and replay functionality
MERGED! |
Awesome work 🍻 |
I like architecture of http://fluentd.org/, it have multiple input and output sources, and fluentd instances can be combined like LEGO bricks.
I want same for Gor, and think It should be logical move, and it will improve overall flexibility.
Examples of current functionality:
Listen data raw socket and replay it different Gor instance
File replay:
Replay to multiple hosts:
Examples of functionality that will be possible after change:
Listen and replay with one Gor instance:
HTTP Input #45:
And much more.
What would you think @slawosz @dcarley ?