Skip to content

Instantly share code, notes, and snippets.

View vjache's full-sized avatar

Vyacheslav Vorobyov vjache

View GitHub Profile
@vjache
vjache / FlumeAppendBatch
Created March 30, 2015 11:24
Batch append to Flume via Avro API.
appendBatch(SomeDir, Events) ->
ProtoFile = filename:join(SomeDir, "flume.avpr"),
{ok, P} = eavro_rpc_fsm:start_link(Host, Port, ProtoFile),
AvroEvents = encode_events_to_eavro_api_events(Events),
{ok, Result} = eavro_rpc_fsm:call(Conn, appendBatch, _Args = [ AvroEvents ]).
encode_events_to_eavro_api_events(Events) ->
[
[ [ {<<"timestamp">>,
@vjache
vjache / SRB
Last active August 29, 2015 14:07
Deadly simple Shared Ring Buffer in Erlang.
%% Shared Ring Buffer
-module(srb).
-export([new/2, push/2, pop/2, pop/1]).
-compile(export_all).
-record(counters,
{ clock :: non_neg_integer(),
max_size :: non_neg_integer() }).