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

Configuration management and multi-service support #874

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

buger
Copy link
Owner

@buger buger commented Dec 20, 2020

Now you can use the config file and env variables to configure GoReplay.
Additionally, you now can manage multiple services with a single instance.

Example usage with a config file:

goreplay.yaml (looks up in current dir, /etc/goreplay/ and `~/.goreplay/ folders)

verbose: 2
services:
  app1:
    input-raw: 9090
    output-http: https://replay.com
  app2:
    input-raw: 8080
    output-s3: s3://mybucket/req.gor

Operations defined outside of the "services" section are global ones and applied to all services.
For example, you can have global input, but two different independent outputs, or vice versa.
Additionally, you can define global and per service modifiers and filters.

When you need to specify multiple values, just use YAML format. Both single and array values supported. Example:

verbose: 2
input-raw: 80
output-dummy: true
services:
  foo:
    input-raw: 8080
    output-http: http://example.com
    http-allow-header: "single:.*"
    http-set-header: 
      - "Foo: bar"
      - "Bar: foo"

Using environment variables

All env variables should start with GR_ prefix.
Should be way easier to use in CI/CD flows now. Example with env variables:
GR_SERVICE=foo GR_INPUT_RAW=:80 GR_OUTPUT_FILE=requests.gor goreplay

At the moment it is not possible to specify multiple services via ENV vars.

@buger buger requested a review from urbanishimwe December 20, 2020 19:31
Set(string) error
}

func MultiOptionDecoder(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported function MultiOptionDecoder should have comment or be unexported

@@ -30,6 +38,80 @@ func loggingMiddleware(next http.Handler) http.Handler {
})
}

type FlagSetter interface {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported type FlagSetter should have comment or be unexported

Set(string) error
}

func MultiOptionDecoder(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported function MultiOptionDecoder should have comment or be unexported

@@ -30,6 +38,80 @@ func loggingMiddleware(next http.Handler) http.Handler {
})
}

type FlagSetter interface {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported type FlagSetter should have comment or be unexported

Set(string) error
}

func MultiOptionDecoder(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported function MultiOptionDecoder should have comment or be unexported

@@ -30,6 +38,80 @@ func loggingMiddleware(next http.Handler) http.Handler {
})
}

type FlagSetter interface {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported type FlagSetter should have comment or be unexported


ModifierConfig HTTPModifierConfig
type AppSettings struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported type AppSettings should have comment or be unexported

@buger buger changed the title Configuration management Configuration management and multi-service support Dec 21, 2020
@buger
Copy link
Owner Author

buger commented Dec 21, 2020

@urbanishimwe any ideas why this test fails?

@buger buger force-pushed the feature/config-management branch from 4d4677b to d693032 Compare December 22, 2020 14:38
@xingren23
Copy link

i try to merge config-management to master, but found some problem

config settings
type ServiceSettings struct {
...
InputRAW MultiOption json:"input-raw" mapstructure:"input-raw"
...
}

then i run:
/private/var/folders/jl/7524zq312p59fxz3msgtsl7c0000gn/T/___go_build_github.com_buger_goreplay --input-raw :8000 --output-tcp :8002 #gosetup
2021/08/17 19:32:24 input-raw: error while parsing address: address [:8000]: missing port in address

the InputRaw Filed could not parse params correctly.

it should be parse to :8000 but [:8000]
when --input-raw :8000 --input-raw :8001 , InputRAW value is [:8000 8001] and :8001

how i could solve this problem ?

@xingren23
Copy link

i try to merge config-management to master, but found some problem

config settings
type ServiceSettings struct {
...
InputRAW MultiOption json:"input-raw" mapstructure:"input-raw"
...
}

then i run:
/private/var/folders/jl/7524zq312p59fxz3msgtsl7c0000gn/T/___go_build_github.com_buger_goreplay --input-raw :8000 --output-tcp :8002 #gosetup
2021/08/17 19:32:24 input-raw: error while parsing address: address [:8000]: missing port in address

the InputRaw Filed could not parse params correctly.

it should be parse to :8000 but [:8000]
when --input-raw :8000 --input-raw :8001 , InputRAW value is [:8000 8001] and :8001

how i could solve this problem ?

i has fixed
it is caused by switching the command parser library from flag to pflag
the solution is to use pflag to parse the multioption

@oncefalse
Copy link

This is a great feature, why isn't it incorporated into the Master
Is there anyone left to push the merger

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.

4 participants