Created
January 14, 2013 21:20
-
-
Save michael-newton-15below/4533619 to your computer and use it in GitHub Desktop.
Error handler builder usage
This file contains hidden or 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
open EasyNetQ | |
type IService = | |
abstract member Start : unit -> unit | |
type Service (log : ILog, bus : IBus, indexer : IIndex, audit : IErrorHandlerBuilder) = | |
member this.Start () = | |
bus.Subscribe<PasngrEmail>("Archive", | |
fun (email : PasngrEmail) -> | |
audit { | |
log.Debug <| sprintf "Email message %s from recipient %d received for archiving." email.MailUid email.Id | |
let! mail = Some email | |
return indexer.Add email } |> ignore) | |
bus.Respond<RetrieveEmailContentRequest, RetrieveEmailContentResponse>(fun request -> | |
let mimeData = audit { | |
log.Debug <| sprintf "Request for content of email %A received." request | |
let! req = Some request | |
return indexer.Retrieve(req) | |
} | |
match mimeData with | |
| Some content -> { Content = content } | |
| None -> { Content = "No email found" }) | |
interface IService with | |
member x.Start () = x.Start () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment