-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb277c6
commit 1ed1202
Showing
14 changed files
with
361 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
31 changes: 31 additions & 0 deletions
31
src/nasdaq_protocols/common/message/templates/itch_tail.mustache
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import asyncio | ||
import click | ||
|
||
from nasdaq_protocols.common import utils | ||
from nasdaq_protocols.itch import tools | ||
|
||
import {{package}} as app | ||
|
||
|
||
@click.command() | ||
@click.option('-h', '--host', required=True) | ||
@click.option('-p', '--port', required=True) | ||
@click.option('-U', '--user', required=True) | ||
@click.option('-P', '--password', required=True) | ||
@click.option('-S', '--session', default='', show_default=True) | ||
@click.option('-s', '--sequence', default=1, show_default=True) | ||
@click.option('-b', '--client-heartbeat-interval', default=1, show_default=True) | ||
@click.option('-B', '--server-heartbeat-interval', default=1, show_default=True) | ||
@click.option('-v', '--verbose', count=True) | ||
def {{app}}_tail(host, port, user, password, session, sequence, | ||
client_heartbeat_interval, server_heartbeat_interval, | ||
verbose): | ||
""" Simple command that tails itch messages""" | ||
utils.enable_logging_tools(verbose) | ||
asyncio.run( | ||
tools.tail_itch( | ||
(host, port), user, password, session, sequence, | ||
app.connect_async, | ||
client_heartbeat_interval, server_heartbeat_interval | ||
) | ||
) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import asyncio | ||
from itertools import count | ||
|
||
|
||
async def tail_itch(remote, | ||
user, | ||
passwd, | ||
session, | ||
sequence, | ||
itch_connector, | ||
client_heartbeat_interval, | ||
server_heartbeat_interval): | ||
closed = asyncio.Event() | ||
sequence_counter = count(1) | ||
|
||
async def on_close(): | ||
print('connection closed.') | ||
closed.set() | ||
|
||
async def on_msg(msg): | ||
print(next(sequence_counter), msg) | ||
print() | ||
|
||
itch_session = None | ||
try: | ||
itch_session = await itch_connector( | ||
remote, user, passwd, session, sequence, | ||
on_msg_coro=on_msg, | ||
on_close_coro=on_close, | ||
client_heartbeat_interval=client_heartbeat_interval, | ||
server_heartbeat_interval=server_heartbeat_interval | ||
) | ||
print('connected') | ||
await closed.wait() | ||
except asyncio.CancelledError: | ||
if itch_session is not None: | ||
await itch_session.close() | ||
except ConnectionRefusedError as exc: | ||
print(exc) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.