Skip to content
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

Merged
merged 20 commits into from
Oct 31, 2013
Merged

Merge listener and replay functionality #46

merged 20 commits into from
Oct 31, 2013

Conversation

buger
Copy link
Owner

@buger buger commented Oct 27, 2013

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

gor --input-raw 9000 --output-tcp replay.server:27017
gor --input-tcp 27017 --output-http staging.dev

File replay:

gor --input-raw 9000 --output-file requests.gor # capture
gor --input-file requests.gor --output-http staging.org # replay

Replay to multiple hosts:

gor --input-raw 9000 --output-tcp replay.server:27017
gor --input-tcp 27017 --output-http staging.org --output-http "dev.org|10"

Examples of functionality that will be possible after change:

Listen and replay with one Gor instance:

gor --input-raw 9000 --output-http "staging.org"

HTTP Input #45:

gor --input-http 8080 --output-tcp "replay.org:27017"

And much more.

What would you think @slawosz @dcarley ?

@slawosz
Copy link
Collaborator

slawosz commented Oct 21, 2013

I like the idea and new, clean flag names.

@buger
Copy link
Owner Author

buger commented Oct 21, 2013

This is also allow to bring much more Go-like architecture with simple modules and interfaces.

@buger
Copy link
Owner Author

buger commented Oct 21, 2013

Here is basic architecture diagram:

image

@dcarley
Copy link
Collaborator

dcarley commented Oct 21, 2013

👍 from me.

@buger buger mentioned this pull request Oct 23, 2013
@buger
Copy link
Owner Author

buger commented Oct 25, 2013

@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:

gor --input-dummie 0 --output-dummie 0

And continue with smth like:

gor --input-raw :27017 --output-http localhost:27018

@slawosz
Copy link
Collaborator

slawosz commented Oct 25, 2013

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 bytes?

@dcarley
Copy link
Collaborator

dcarley commented Oct 25, 2013

Wow, I like the look of it. Will have a play around.

@buger
Copy link
Owner Author

buger commented Oct 25, 2013

@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 ?).

@slawosz
Copy link
Collaborator

slawosz commented Oct 25, 2013

It is beautiful piece of code 👍

@buger
Copy link
Owner Author

buger commented Oct 27, 2013

Converted issue to pull-request


func (i *RAWInput) Read(data []byte) (int, error) {
buf := <-i.data
copy(data, buf)
Copy link
Collaborator

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?

Copy link
Owner Author

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.

Copy link
Owner Author

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.

@buger
Copy link
Owner Author

buger commented Oct 27, 2013

This pull-request is long-going, and require adding lot of tests. Also it not support rate-limiting.

@slawosz
Copy link
Collaborator

slawosz commented Oct 27, 2013

Oh, testing right now will be much easier :)

@buger
Copy link
Owner Author

buger commented Oct 29, 2013

@slawosz @dcarley I added tests and missing plugins. Now this branch should support all features of previous versions (except some minor stuff like custom headers and elastic search stats, but this will be added soon). If you have time pls test it. Thanks!

@buger
Copy link
Owner Author

buger commented Oct 30, 2013

Added custom headers and ElasticSearch plugin. Also added option to round-robin traffic if have multiple outputs:

--split-output=true

buger added a commit that referenced this pull request Oct 31, 2013
Merge listener and replay functionality
@buger buger merged commit ccf6723 into master Oct 31, 2013
@buger
Copy link
Owner Author

buger commented Oct 31, 2013

MERGED!

@dcarley
Copy link
Collaborator

dcarley commented Oct 31, 2013

Awesome work 🍻

@slimus slimus deleted the module_architecture branch June 3, 2020 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants