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

Add middleware/erratic #471

Merged
merged 1 commit into from
Jan 6, 2017
Merged

Add middleware/erratic #471

merged 1 commit into from
Jan 6, 2017

Conversation

miekg
Copy link
Member

@miekg miekg commented Jan 5, 2017

This middleware allows playing with responses. Only one type is
implemented: it allows you to drop queries. I.e. withhold the response
from the client.

if e.amount > 0 {
queryNr := atomic.LoadUint64(&e.q)

if queryNr%e.amount == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Nice! Should this be so uniform though? For example by default it drops every-other-query. I guess that's OK, but I wonder if there should be some randomness. I suppose if you have multiple clients it will appear essentially random, so it's probably not worth making it more complicated.

@miekg
Copy link
Member Author

miekg commented Jan 5, 2017 via email

@codecov-io
Copy link

codecov-io commented Jan 5, 2017

Current coverage is 38.92% (diff: 73.77%)

Merging #471 into master will increase coverage by 0.41%

@@             master       #471   diff @@
==========================================
  Files           113        115     +2   
  Lines          5580       5641    +61   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           2149       2196    +47   
- Misses         3255       3267    +12   
- Partials        176        178     +2   

Powered by Codecov. Last update 9a5e0c6...82228df

This middleware allows playing with responses. Only one type is
implemented: it allows you to drop queries. I.e. withhold the response
from the client.
@miekg miekg merged commit 53ac25d into master Jan 6, 2017
@miekg miekg deleted the erratic branch February 1, 2017 11: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.

3 participants