Created
June 5, 2011 00:02
-
-
Save AlexCuse/1008510 to your computer and use it in GitHub Desktop.
Seq.concat wasn't working right (was only checking the recipe queue). Async wasn't working either but this seems to do ok.
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 | |
ObjectFactory.Initialize(fun x -> x.AddRegistry (new SearchRegistry())) | |
let write<'T when 'T:null and 'T:equality> item = | |
if not (item = null) then | |
ObjectFactory.GetAllInstances<Indexer<'T>>() | |
|> Seq.iter (fun idxr -> idxr.Index item) | |
let itemsToIndex<'T when 'T:null and 'T:not struct> = | |
let p = QueueProvider<'T>.Create() | |
seq { | |
while true do | |
yield p.Dequeue() | |
} | |
try | |
itemsToIndex<Recipe> | |
|> Seq.zip itemsToIndex<Malt> | |
|> Seq.zip itemsToIndex<Hop> | |
|> Seq.zip itemsToIndex<Addition> | |
|> Seq.zip itemsToIndex<Yeast> | |
|> Seq.iter (fun (recipe, (malt, (hop, (addition, yeast)))) -> | |
write recipe | |
write malt | |
write hop | |
write addition | |
write yeast) | |
finally | |
SearchRegistry.DeRegister() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment