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

Adding support for global --latency #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

codeorganic
Copy link

closes issue #41

Please code review @mrak

@@ -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,
Copy link
Owner

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.

@mrak
Copy link
Owner

mrak commented Aug 6, 2015

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

@codeorganic
Copy link
Author

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.

@mrak
Copy link
Owner

mrak commented Aug 20, 2015

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 Object.assign(endpoint, defaults) (or more intelligent deep merge) for each configured endpoint while parsing through the data parameter

stubby --data data.yaml --defaults <<EOF
response:
  latency: 800
EOF
var stubby = new require('stubby').Stubby();

stubby.start({
  data: [...],
  defaults: {
    response: {
      latency: 800
    }
  }
});

@codeorganic
Copy link
Author

Your idea makes a lot of sense and better structured

@elishaterada
Copy link

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

@kreempuff
Copy link

Can this be re-reviewed? Functionality would be greatly appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants