$ echo -n "trolling" | gearman -p 4731 -f test
trolling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net/http" | |
"net/http/httptest" | |
"net/http/httputil" | |
"net/url" | |
) | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) |
$ 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var DM, Document, PM, Property, Schema, assert, async, docs, mongoose; | |
mongoose = require('mongoose'); | |
Schema = mongoose.Schema; | |
async = require('async'); | |
assert = require('assert'); |