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
import nsq | |
def task1(message): | |
print message | |
return True | |
def task2(message): | |
print message | |
return True |
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
import nsq | |
buf = [] | |
def process_message(message): | |
global buf | |
message.enable_async() | |
buf.append(message) | |
if len(buf) >= 3: | |
for msg in buf: |
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
const ( | |
ModeAll = iota | |
ModeRoundRobin | |
) | |
type Publisher interface { | |
Publish(string, []byte) error | |
} | |
type PublishHandler struct { |
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
function j { | |
local project=$1 | |
cd `find ~/dev/src -type d -mindepth 3 -maxdepth 3 -name $project` | |
} |
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
{ | |
"status_code": 200, | |
"status_txt": "OK", | |
"data": { | |
"channels": ["archive", "science", "metrics"], | |
"producers": [ | |
{ | |
"broadcast_address": "clicksapi01.routable.domain.net", | |
"hostname": "clicksapi01.domain.net", | |
"tcp_port": 4150, |
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
{ | |
"short_id": "app01", | |
"long_id": "app01.bitly.net", | |
"heartbeat_interval": 30000, | |
"feature_negotiation": true | |
} |
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
{ | |
"max_rdy_count": 2500, | |
"version": "0.2.20-alpha" | |
} |
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
def send_ready(reader, conn, count): | |
if (reader.total_ready_count + count) > reader.max_in_flight: | |
return | |
conn.send_ready(count) | |
conn.rdy_count = count | |
reader.total_ready_count += count |
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
def is_starved(conns): | |
for c in conns: | |
# the constant 0.85 is designed to *anticipate* starvation rather than wait for it | |
if c.in_flight > 0 and c.in_flight >= (c.last_ready * 0.85): | |
return True | |
return False |
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
import functools | |
import sys | |
import logging | |
def exit_on_exception(method): | |
@functools.wraps(method) | |
def wrapped(*args, **kwargs): | |
try: | |
return method(*args, **kwargs) |
OlderNewer