Skip to content

Instantly share code, notes, and snippets.

View MikeGoldsmith's full-sized avatar

Mike Goldsmith MikeGoldsmith

View GitHub Profile
public class MyServerResolver : IServerResolver
{
private readonly string _serviceName;
private readonly Resolver _resolver;
public DnsResolver()
{
// values could be loaded from config
_resolver = new Resolver
{
_cbnodes._tcp.example.com. 0 IN SRV 20 0 8091 node2.example.com.
_cbnodes._tcp.example.com. 0 IN SRV 10 0 8091 node1.example.com.
_cbnodes._tcp.example.com. 0 IN SRV 30 0 8091 node3.example.com.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="couchbase" type="Couchbase.Configuration.Client.Providers.CouchbaseClientSection, Couchbase.NetClient" />
</configSections>
<couchbase>
<serverResolver type=""/>
</couchbase>
// other configuration omitted for brevity
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="couchbase" type="Couchbase.Configuration.Client.Providers.CouchbaseClientSection, Couchbase.NetClient" />
</configSections>
<couchbase>
<servers>
<add uri="http://node1.example.com:8091/"/>
<add uri="http://node2.example.com:8091/"/>
</servers>

Keybase proof

I hereby claim:

  • I am mikegoldsmith on github.
  • I am mgoldsmith (https://keybase.io/mgoldsmith) on keybase.
  • I have a public key whose fingerprint is 1865 0AD4 AB3E 8B5F A065 EF14 819B 2121 230F 8A43

To claim this, I am signing this object:

public class Workflow
{
public IEnumerable<INode> Nodes {get;set;}
// other properties
}
public interface INode
{
Guid Id {get;}
}
@MikeGoldsmith
MikeGoldsmith / gist:2e07b64cf25ffd259ec6
Last active August 29, 2015 14:13
Interface (de)serialization when using MassTransit
using System;
using System.Collections.Generic;
using System.Linq;
using MassTransit;
using MassTransit.Serialization;
using Newtonsoft.Json;
namespace MT_Interface_Typing
{
class Program
var view = _client.GetView("scheduling", "jobs_by_status_scheduledFor")
.StartKey(new object[] {JobStatus.Queued.ToString()})
.EndKey(new object[] {JobStatus.Queued.ToString(), DateTime.UtcNow.ToString("O")})
.GetPagedView(maxJobs);
while (jobs.Count < maxJobs && view.MoveNext())
{
foreach (var row in view)
{
CasResult<object> casResult;
@MikeGoldsmith
MikeGoldsmith / MT_Quartz
Last active August 29, 2015 14:05
MassTransit & Quartz.net
using System;
using Magnum.Extensions;
using MassTransit;
using MassTransit.QuartzIntegration;
using MassTransit.Scheduling;
using Quartz.Impl;
class Program
{
static void Main()
public interface IQuery<TResult>
{
}
public interface IQueryHandler<in TQuery, TResult>
where TQuery : IQuery<TResult>
{
Task<TResult> Handle(TQuery query);
}
public class ServiceBusQueryHandler<TQuery, TResult> : IQueryHandler<TQuery, TResult>
where TQuery : class, IQuery<TResult>