Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// A raw message.
- type Message = byte[]
- /// A domain-specific input type.
- type Input =
- | MerchantSkuImported
- | MerchantSkuRemoved
- /// A domain-specific output type.
- type Output =
- | SkuUpdated
- /// Decodes an input or returns an error.
- let decodeInput : Message -> Result<Input, string> = undef
- /// Encodes the output.
- let encodeOutput : Output -> Message = undef
- /// Runs the core logic of the service.
- let handle : Input -> Async<Output> = undef
- /// Given a host name, returns a stream of input messages.
- let inputStream : string -> AsyncSeq<Message> = undef
- /// Given a host name, publishes an output message.
- let publish : string -> Message -> Async<unit> = undef
- /// Creates a message handler given a decoder, business logic handler and a decoder.
- let handler :
- (Message -> Result<Input, string>) ->
- (Input -> Async<Output>) ->
- (Output -> Async<unit>) ->
- Message -> Async<unit> = undef
- /// Configuration for the service.
- type Args = {
- input_host : string
- output_host : string
- }
- /// Runs the service.
- let run (args:Args) = async {
- let inputStream = inputStream args.input_host
- let publish = publish args.output_host
- let handle = handler decodeInput handle (encodeOutput >> publish)
- do! inputStream |> AsyncSeq.iterAsync handle }
Add Comment
Please, Sign In to add comment