This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace BrewTelligence.Search.IndexingService | |
#light | |
open System.Threading | |
open System.Configuration | |
open RabbitMQ.Client | |
open RabbitMQ.Client.MessagePatterns | |
//TODO: single connection / channel for lifetime? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//I think this is more or less how it'd work | |
public IEnumerable<T> Stuffs () { | |
bool noAck = false; | |
using (var connection = connectionFactory.CreateConnection ()) | |
using (var channel = SetupChannel (connection)) { | |
var sub = new Subscription (channel, queueName, noAck); | |
while (true) { | |
var result = sub.Next (); | |
if (result != null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let Run<'T when 'T: not struct and 'T:null and 'T:equality> (errorCallback, ct:CancellationToken, finished:ManualResetEvent) = | |
let p = QueueProvider<'T>.Create() | |
try | |
while not (ct.IsCancellationRequested) do | |
match p.Dequeue() with | |
| null -> Thread.Sleep 1000 | |
| _ as obj -> | |
try | |
write obj | |
with | ex -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Service = //snip | |
member this.Run() = | |
let mutable retryCount = 0 | |
while retryCount < 10 do | |
//what to do on mono? Maybe setting up local log better | |
let errorCallback = | |
function(ex:System.Exception) -> this.EventLog.WriteEntry("error in BrewTelligence Indexing Service:\n\n" + ex.Message + "\n\n" + ex.StackTrace) | |
try |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Program | |
#light | |
open System.Threading | |
open StructureMap | |
open BrewTelligence.Domain | |
open BrewTelligence.Search.Indexing | |
open BrewTelligence.ApplicationServices | |
open BrewTelligence.ApplicationServices.Messaging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#light | |
open System | |
module Seq = | |
let merge (s1:seq<option<'a>>) (s2:seq<option<'a>>) = | |
let rec innerMerge s1 s2 = | |
seq { | |
match s1, s2 with | |
| LazyList.Cons(h1, t1), LazyList.Cons(h2, t2) -> | |
yield h1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Seq | |
#light | |
let merge (s1:seq<'a>) (s2:seq<'a>) = | |
let rec innerMerge s1 s2 = | |
seq { | |
match s1, s2 with | |
| LazyList.Cons(h1, t1), LazyList.Cons(h2, t2) -> | |
yield h1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Seq | |
#light | |
let rec merge s1 s2 = | |
seq { | |
yield s1 |> Seq.head | |
yield s2 |> Seq.head | |
yield! merge s1 s2 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ObjectFactory.Initialize(fun x -> x.AddRegistry (new SearchRegistry())) | |
let write<'T> item = | |
ObjectFactory.GetAllInstances<Indexer<'T>>() | |
|> Seq.iter (fun idxr -> idxr.Index item) | |
let itemsToIndex<'T when 'T:null and 'T:not struct and 'T:equality> = | |
let p = QueueProvider<'T>.Create() | |
seq { | |
while true do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Program | |
#light | |
open System.Threading | |
open StructureMap | |
open BrewTelligence.Domain | |
open BrewTelligence.Search.Indexing | |
open BrewTelligence.ApplicationServices | |
open BrewTelligence.ApplicationServices.Messaging |