Skip to content

Instantly share code, notes, and snippets.

View jrydberg's full-sized avatar

Johan Rydberg jrydberg

View GitHub Profile
from twisted.internet import task
from twisted.trial import unittest
class Bully(object):
state = 'unknown'
callID = None
def __init__(self, clock, node_id, transport, service):
self.clock = clock
@jrydberg
jrydberg / pack-ukijs.py
Created April 21, 2011 17:06
Hack to pack commonjs-modules for ukijs into a single file
# Copyright (C) 2011 Johan Rydberg <johan.rydberg@gmail.com>
# Released under the Apache 2.0 license.
"""Simple hack to pack together a ukijs application into a single file."""
import re
import os
import cssutils
import base64
import sys
@jrydberg
jrydberg / defer.coffee
Created May 3, 2011 18:52
Twisted-style Deferreds in CoffeeScript
exports.AlreadyCalledError = class AlreadyCalledError
exports.Failure = class Failure
constructor: (@error) ->
check: (errorType) ->
if @error instanceof errorType
@error
else
null
@jrydberg
jrydberg / kafka.spec
Created March 16, 2012 21:26
RPM .spec for Apache Kafka
%define _noarch_libdir /usr/lib
%define rel_ver 0.7.0
Summary: A high-throughput distributed messaging system.
Name: kafka
Version: %{rel_ver}
Release: 1
License: Apache License v2.0
Group: Applications/Databases
@jrydberg
jrydberg / example.py
Created April 6, 2012 11:34
watchdog for gevent greenlets
# Small snippet that shows how to put a watchdog around a greenlet.
# When the watchdog is triggered, a stacktrace of the greenlet is
# printed.
import gevent
import traceback
import sys
def a(a=10):
@jrydberg
jrydberg / clock.py
Created April 18, 2012 08:50
clock abstraction for gevent
# Copyright 2012 Johan Rydberg.
# Copyright 2001-2008 Twisted Matrix Laboratories.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@jrydberg
jrydberg / seq.py
Created November 13, 2012 07:05
Functional-programming style sequences.
"""Functional-programming style sequences."""
import itertools
import functools
import operator as op
class Blank(object):
def __init__(self, pos=None):
self.pos = pos
@jrydberg
jrydberg / supervisor.py
Created November 14, 2012 17:28
simple gevent supervisor
class UnhandledExceptionError(Exception):
"""The exception could not be handled by the supervisor."""
class SupervisorKilledError(Exception):
"""The supervisor was killed."""
class SupervisorAbortedError(Exception):
"""The supervisor gave up after maximum number of failures."""
@jrydberg
jrydberg / README.md
Last active March 18, 2017 14:51
Scalable Monitoring using Riemann

Riemann is a quite simple but powerful monitoring system. In its core it is an event processing framework allowing a user to handle an incoming event stream. Events are small objects that originate from a host, that has a service and metric value associated with it. Events may also have tags and a free text description. This simple data structure enables an application transmit both exception tracebacks and application metric data using the same mechanism.

Riemann has a few problems though. First, it is a single-machine application, only allowing vertical scaling. Secondly, there's no redundancy or availability solution. In this post we'll try to address the first issue.

@jrydberg
jrydberg / gist:5527599
Created May 6, 2013 19:42
Introducing Gilliam

This is a short introduction post about Gilliam, a platform for micro services architecture systems.

Gilliam draws a lot of inspiration from Heroku. The idea is that Gilliam should be to your service ecosystem what Heroku is to your web apps.