Skip to content

Instantly share code, notes, and snippets.

View mookid8000's full-sized avatar
💭
Pressing buttons.

Mogens Heller Grabe mookid8000

💭
Pressing buttons.
View GitHub Profile
Configure.With(...)
.Transport(t => t.UseRabbitMq(...) //< giver en RabbitMqOptions
.PrefetchCount(5))
@mookid8000
mookid8000 / gist:5036713
Last active December 14, 2015 05:39
RavenDB "transparent lazy load"
public class SomeDoc : Doc
{
public Ref<AnotherDoc> TheOtherDoc { get; set; }
}
public class AnotherDoc : Doc
{
public string Text { get; set; }
}
@mookid8000
mookid8000 / gist:5036740
Last active December 14, 2015 05:39
statically injectable aggregate root loader
public interface ILoadAggregateRoots
{
T Load<T>(string id) where T:Doc;
}
public static class Loader
{
static ILoadAggregateRoots currentLoader = new ThrowMustProvideLoaderException();
public static ILoadAggregateRoots Current
@mookid8000
mookid8000 / gist:5149813
Created March 13, 2013 06:37
Any reason why this yields NULL in `SomeIntegerColumn` in the database?
sqlReplicate('SomeTable', {
Id: documentId,
SomeIntegerColumn: 23
});
Configure.With(...)
.EnableWebCallbacks()
.(...)
// (...)
// just like that
adapter.Bus.Send(new SomeRequest {Message = "hello there!"},
(SomeReply reply) =>
{
Action<MyDomainAssembly.ISubscribeTo<MyDomainAssembly.IDomainEvent>, MyDomainAssembly.IDomainEvent>
dispatchSpecification = (s, e) => s.Handle(e);
Action<MyDomainAssembly.IDomainEvent> myDispatcher =
DomainEvents.Configure.With(someIocContainerAdapter)
.DefineSubscriberAs<MyDomainAssembly.ISubscribeTo<MyDomainAssembly.IDomainEvent>>(dispatchSpecification)
.RegisterSubscribersFromAssemblyContaining<MyDomainAssembly.SomeConcreteSubscriber>(Lifestyle.InstancePerCall)
.RegisterSubscribersFromAssemblyContaining<MyInfrastructureAssembly.AnotherConcreteSubscriber>(Lifestyle.InstancePerCall)
.CreateDispatcher();
@mookid8000
mookid8000 / gist:7536712
Created November 18, 2013 22:43
Service Azure blob with Web API
public async Task<HttpResponseMessage> Get()
{
var blobClient = GetBlobClientFromSomewhere();
var imagesContainer = blobClient.GetContainerReference("images");
var blobRef = await imagesContainer.GetBlobReferenceFromServerAsync(@"cute_cats_70MB.jpg");
var openRead = await blobRef.OpenReadAsync();
var response = new HttpResponseMessage(HttpStatusCode.OK)
@mookid8000
mookid8000 / gist:fec9386fddb609b2ab31
Created September 18, 2014 09:39
Rebus sends to nonexistent queue
try
{
var startableBus = Configure.With(new BuiltinContainerAdapter())
.Logging(l => l.None())
.Transport(t => t.UseMsmqInOneWayClientMode())
.CreateBus();
using (var bus = startableBus.Start())
{
bus.Advanced.Routing.Send("NO_CHANCE_THAT_THIS_QUEUE_EXISTS", "hello there!");
using System;
using System.Threading;
using System.Threading.Tasks;
using Rebus.Logging;
namespace Rebus.Threading
{
/// <summary>
/// <see cref="Task"/>-based background timer thingie, that will periodically call an async <see cref="Func&lt;Task&gt;"/>
/// </summary>
@mookid8000
mookid8000 / SubscriberCacheExtensions.cs
Created April 20, 2016 07:14
Subscriber caching extension for Rebus2
public static class SubscriberCacheExtensions
{
public static void EnableSubscriberCache(this OptionsConfigurer configurer)
{
configurer.Decorate<ISubscriptionStorage>(c =>
{
var subscriptionStorage = c.Get<ISubscriptionStorage>();
return new CachingSubscriptionStorage(subscriptionStorage);
});