Skip to content

Commit

Permalink
Tools:
Browse files Browse the repository at this point in the history
add force-stream option to Connect, LatencyTest, PerfTest
  • Loading branch information
kosyloa committed Dec 4, 2023
1 parent c80f232 commit e0abce2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Samples/Tools/Arguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ class Arguments {
return false
}()

public lazy var isForceStream: Bool = {
if let isForceStream = allParameters.firstIndex(of: "--force-stream") {
return true
}
return false
}()

public lazy var tape: String? = {
if let tapeIndex = allParameters.firstIndex(of: "-t") {
return allParameters[tapeIndex + 1]
Expand Down
5 changes: 4 additions & 1 deletion Samples/Tools/ConnectTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Connect
=======
Usage:
Connect <address> <types> <symbols> [-f <time>]
Connect <address> <types> <symbols> [-f <time>] [<options>]
Where:
address - The address to connect to retrieve data (remote host or local tape file).
Expand All @@ -37,6 +37,8 @@ Where:
2005-12-31 21:00:00.123+0400
2007-11-02Z
123456789 - value-in-milliseconds
--force-stream Enforces a streaming contract for subscription. The StreamFeed role is used instead of Feed.
"""

Expand Down Expand Up @@ -93,6 +95,7 @@ Where:
subscription.createSubscription(address: arguments[1],
symbols: arguments.parseSymbols(at: 3),
types: arguments.parseTypes(at: 2),
role: arguments.isForceStream ? .streamFeed : .feed,
listeners: listeners,
properties: arguments.properties,
time: arguments.time,
Expand Down
3 changes: 3 additions & 0 deletions Samples/Tools/LatencyTestTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class LatencyTestTool: ToolsCommand {
symbols (pos. 2) Comma-separated list of symbol names to get events for (e.g. "IBM, AAPL, MSFT").
Use "all" for wildcard subscription.
The "dxfeed.wildcard.enable" property must be set to true to enable wildcard subscription.
--force-stream Enforces a streaming contract for subscription. The StreamFeed role is used instead of Feed.
"""
var subscription = Subscription()
private lazy var arguments: Arguments = {
Expand All @@ -50,6 +52,7 @@ class LatencyTestTool: ToolsCommand {
subscription.createSubscription(address: address,
symbols: arguments.parseSymbols(at: 3),
types: types,
role: arguments.isForceStream ? .streamFeed : .feed,
listeners: [listener],
properties: arguments.properties,
time: nil)
Expand Down
4 changes: 3 additions & 1 deletion Samples/Tools/PerfTestTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ class PerfTestTool: ToolsCommand {
Connects to the specified address(es) and calculates performance counters (events per second, cpu usage, etc).
Usage:
path_to_app <address> <types> <symbols>
path_to_app <address> <types> <symbols> [<options>]
Where:
address (pos. 0) Required. The address(es) to connect to retrieve data (see "Help address").
For Token-Based Authorization, use the following format: "<address>:<port>[login=entitle:<token>]".
types (pos. 1) Required. Comma-separated list of dxfeed event types (e.g. Quote, TimeAndSale).
symbols (pos. 2) Required. Comma-separated list of symbol names to get events for (e.g. "IBM, AAPL, MSFT").
--force-stream Enforces a streaming contract for subscription. The StreamFeed role is used instead of Feed.
"""

private lazy var arguments: Arguments = {
Expand All @@ -46,6 +47,7 @@ class PerfTestTool: ToolsCommand {
subscription.createSubscription(address: address,
symbols: arguments.parseSymbols(at: 3),
types: arguments.parseTypes(at: 2),
role: arguments.isForceStream ? .streamFeed : .feed,
listeners: [listener],
properties: arguments.properties,
time: nil)
Expand Down
3 changes: 2 additions & 1 deletion Samples/Tools/SubscriptionUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Subscription {
func createSubscription<O>(address: String,
symbols: [Symbol],
types: [EventCode],
role: DXEndpoint.Role,
listeners: [O],
properties: [String: String],
time: String?,
Expand All @@ -27,7 +28,7 @@ Create subscription to \(address) for \(types): \
""")
endpoint = try? DXEndpoint
.builder()
.withRole(.feed)
.withRole(role)
.withProperties(properties)
.withName("SubscriptionEndpoint")
.build()
Expand Down

0 comments on commit e0abce2

Please sign in to comment.