-
Notifications
You must be signed in to change notification settings - Fork 62
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
Adding support for global --latency #42
base: master
Are you sure you want to change the base?
Conversation
@@ -127,7 +128,7 @@ function purifyResponse(me, incoming) { | |||
outgoing.push(pruneUndefined({ | |||
headers: purifyHeaders(response.headers), | |||
status: parseInt(response.status) || 200, | |||
latency: parseInt(response.latency) || undefined, | |||
latency: parseInt(response.latency || cli.getArgs().latency) || undefined, |
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.
We'll need to do a bit more than this for cases where new Stubby().start(options)
is used, as it is not always started from a command-line invocation.
I've also been thinking about some sort of "template" request/response that can fill in the defaults for all missing values in configured endpoints. This would be identified in some fashion in the supplied yaml file - request: ...
response: ...
...
defaults:
request: ...
response: ... |
Good idea having it templated and built into stubby4node. However, it would then make the YAML files not portable to other stubby systems. Currently, we have a this but it is just a simple script that replaces varaibles and seperate from stubby4node. |
Having the defaults passed as a separate argument would preserve the array structure in the data file and be backward-compatible from the API standpoint. Everything within the defaults would be a simple stubby --data data.yaml --defaults <<EOF
response:
latency: 800
EOF var stubby = new require('stubby').Stubby();
stubby.start({
data: [...],
defaults: {
response: {
latency: 800
}
}
}); |
Your idea makes a lot of sense and better structured |
@mrak this sounds like a really good idea. This will help with DRY especially in header which typically looks identical across all calls (e.g. authentication token). |
Can this be re-reviewed? Functionality would be greatly appreciated |
closes issue #41
Please code review @mrak