Skip to content

Instantly share code, notes, and snippets.

View rofr's full-sized avatar

Robert Friberg rofr

View GitHub Profile
public class Template
{
private static Logger _logger = LogManager.GetCurrentClassLogger();
public readonly string Body;
private HashSet<string> _keys;
public const string KeyExpression = @"{(?<key>[^}]+)}";
public bool RenderEmptyStringForMissingKeys { get; set; }
@rofr
rofr / gist:650705903b4cdeccd60a
Created November 24, 2014 16:40
Async OrigoDB writing to Filestream, 96K TPS
TplNetEngine`1
# commands: 40000
# commands per batch: 5120
time elapsed: 00:00:00.4124693
tps: 96976,9144030841
AkkaEngine`1
# commands: 40000
# commands per batch: 5120
time elapsed: 00:00:01.0080653
@rofr
rofr / gist:6e183800ab79ae7bb1eb
Created November 24, 2014 10:40
async origodb spike results
TplNetEngine`1
# commands: 20000
# commands per batch: 1280
time elapsed: 00:00:00.3238584
tps: 61755,3844519704
AkkaEngine`1
# commands: 20000
# commands per batch: 1280
time elapsed: 00:00:00.4505049
@rofr
rofr / Test.cs
Created November 5, 2014 13:27
Why does this test fail?
[Test]
public void ESConnectTest()
{
var endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1113);
var connection = EventStoreConnection.Create(endPoint);
bool connected = false;
connection.Connected += (sender, args) => connected = true;
connection.ConnectAsync().Wait();
Assert.IsTrue(connected);
}
@rofr
rofr / EventStoreWriter.cs
Created November 5, 2014 13:16
wtf did I screw up now?
public class EventStoreWriter : IJournalWriter
{
private readonly IEventStoreConnection _eventStore;
private readonly IFormatter _formatter;
public EventStoreWriter(IEventStoreConnection connection, IFormatter formatter = null)
{
_formatter = formatter ?? new BinaryFormatter();
_eventStore = connection;
}
@rofr
rofr / OrigoDisruptor.cs
Created November 4, 2014 16:47
Async OrigoDB spike using disruptor.net
using System;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
using Disruptor;
using Disruptor.Dsl;
using EventStore.ClientAPI;
namespace AckAck.Disruptive
@rofr
rofr / gist:4f784e57aed0e62e0668
Created November 4, 2014 16:38
Using WriteOnceBlock from TPL dataflow? There's got to be a better way!
public async Task<R> ExecuteAsync<R>(Command<M, R> command)
{
var completion = new WriteOnceBlock<object>(_ => _);
_commandQueue.PublishEvent((e, i) =>
{
e.Transaction = command;
e.Result = completion;
return e;
});
public class Journaler : IEventHandler<BufferEntry>
{
private BufferEntry[] _buffer = new BufferEntry[1024];
private int _current;
private IJournalWriter _journal;
public Journaler(IJournalWriter journal)
{
_journal = journal;
}
public class Dispatcher
{
private Kernel _kernel;
readonly BufferBlock<CommandContext[]> _commandQueue;
readonly BatchBlock<QueryContext> _queryQueue;
readonly ActionBlock<object> _executor;
readonly Timer _timer;
/// <summary>
/// Maximum latency for queries
@rofr
rofr / JsonX
Created October 21, 2014 09:23
XmlJ, the new json format from IBM to represent XML as json
{ "element" : "object",
"namespace" : "json",
"childNodes" : [
{
"type" : "element"
"name": "string",
"namespace" : "json",
"attributes" : [
{