Skip to content

Instantly share code, notes, and snippets.

@AlexCuse
Created June 5, 2011 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexCuse/1008510 to your computer and use it in GitHub Desktop.
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.
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