Skip to content

Instantly share code, notes, and snippets.

View aspett's full-sized avatar

Andrew Pett aspett

View GitHub Profile
def start_link(_opts) do
Broadway.start_link(__MODULE__,
name: BroadwayPipeline,
producer: [
module: {Producer, []},
concurrency: 1,
rate_limiting: [allowed_messages: 11, interval: 1000] # 11/s is just over 950k / day
],
processors: [
default: [concurrency: 5]
defmodule Producer do
use GenStage
@behaviour Broadway.Producer
def init(_opts) do
{:producer, 0}
end
def handle_demand(demand, stored_demand) do
defmodule BlockingBuffer do
@moduledoc """
A process which holds a queue and blocks when the length of the queue
exceeds a predefined number (100)
"""
use GenServer
@max_buffer 100 # Tweak as required, or move into opts
defmodule BroadwayPipeline do
use Broadway
def start_link(_opts) do
Broadway.start_link(__MODULE__,
name: BroadwayPipeline,
producer: [
module: {Producer, []},
concurrency: 1,
],
@aspett
aspett / keybase.md
Last active January 30, 2017 08:27

Keybase proof

I hereby claim:

  • I am aspett on github.
  • I am aspett (https://keybase.io/aspett) on keybase.
  • I have a public key ASDylFnJDuhnLPupQgFxOzll1YTjOomS_Kdg6b6mbPvwkAo

To claim this, I am signing this object:

@aspett
aspett / gist:4c44623103cd550fe4c0
Created January 11, 2016 20:06
Karabiner config for tmux
<?xml version="1.0"?>
<root>
<item>
<name>TMUX Key Remappings</name>
<item>
<name>TMUX: Right Control to Ctrl+B</name>
<identifier>private.right_control_to_control_b</identifier>
<autogen>
--KeyToKey--
KeyCode::CONTROL_R,