-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.fs
More file actions
40 lines (34 loc) · 1.41 KB
/
Program.fs
File metadata and controls
40 lines (34 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
open System
open System.Threading.Tasks
open CommandLine
open DxFeed.Core.IO.Connectors
open DxFeed.Core.Parser
open DxFeed.Core.Parser.Messages
type Options =
{ [<Option('a',
"address",
Required = true,
HelpText = "Address to connect for data.\n"
+ "Supported <hostname:port> format, or path to local file.\n"
+ "Can contains prefix file: or tcp: to specify connector.")>]
address: string }
module MessagePrinter =
let OnError (ex: Exception) = printfn $"{ex.Message}"
let OnHeartbeat (message: HeartbeatMessage) = printfn $"{message}"
let OnDescribeRecord (message: RecordDescription) = printfn $"{message}"
[<EntryPoint>]
let main argv =
match Parser.Default.ParseArguments<Options>(argv) with
| :? Parsed<Options> as parsed ->
let connector =
ConnectorFactory.CreateConnector(parsed.Value.address)
let parser = QtpBinaryParser()
parser.add_OnError MessagePrinter.OnError
parser.add_OnHeartbeat MessagePrinter.OnHeartbeat
parser.add_OnDescribeRecord MessagePrinter.OnDescribeRecord
Task.WhenAll(parser.DoParseAsync(connector.Reader), connector.DoReceiveAsync())
|> Async.AwaitTask
|> Async.RunSynchronously
| :? NotParsed<Options> as notParsed -> printfn $"{notParsed.Errors}"
| _ -> failwith "Something went wrong"
0