$ node server.js
output in terminal shows that req.foo
is no longer sitting in the heap:
got request with a foo of length 10000000
hello world
got request with a foo of length 0
var DM, Document, PM, Property, Schema, assert, async, docs, mongoose; | |
mongoose = require('mongoose'); | |
Schema = mongoose.Schema; | |
async = require('async'); | |
assert = require('assert'); |
$ node server.js
output in terminal shows that req.foo
is no longer sitting in the heap:
got request with a foo of length 10000000
hello world
got request with a foo of length 0
// batchChannel takes in a channel and outputs them grouped into batches. The batch will be sent when | |
// either there are enough to complete the batchSize or the flushInterval has elapsed. | |
func batchChannel(in chan interface{}, out chan interface{}, batchSize int, flushInterval time.Duration) { | |
tickChan := time.Tick(flushInterval) | |
buffer := make([]interface{}, 0) | |
for { | |
select { | |
case el := <-in: | |
buffer = append(buffer, el) |
$ echo -n "trolling" | gearman -p 4731 -f test
trolling
package main | |
import ( | |
"net/http" | |
"net/http/httptest" | |
"net/http/httputil" | |
"net/url" | |
) | |
func main() { |
/* | |
Welcome to April's Go Problem of the Month! | |
This month's challenge will take you through simulations of slowly degrading services (inspired by a | |
well-known identity provider whose name rhymes with "Oogle"). | |
Our services return a number, and our challenge is to fetch 500 numbers from the service and sum the | |
results as quickly as possible. | |
You'll fill out implementations of the three functions, handling increasingly degraded services as |