Skip to content

Commit 9360f62

Browse files
authored
python: fix proto + failfast on controle plane conn error
* wip * python: fixed dragonsmouth intg tet * remove bkp * 30: dragonsmouth adapter session as async contextmanager * python: CHANGELOG for v0.2.0 * 31: AsyncGenerator for dragonsmouth source * black formatter * put back typescript-sdk/package.json * readme * rename some stuff * protobuf v6: update bindings * changelog * added missing shutdown * python: updated README * python: added yaml config parsing test + refactor * python: black fmt
1 parent feabff8 commit 9360f62

25 files changed

+1005
-690
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
**Note:** Version 0 of Semantic Versioning is handled differently from version 1 and above.
9+
The minor version will be incremented upon a breaking change and the patch version will be incremented for features.
10+
11+
## [Unreleased]
12+
13+
### Features
14+
15+
### Fixes
16+
17+
### Breaking
18+
19+
## [0.2.0]
20+
21+
### Features
22+
23+
- `yellowstone_fumarole_client.DragonsmouthAdapterSession` implements async contextmanager [#30](https://github.com/rpcpool/yellowstone-fumarole/issues/30)
24+
- Supports for gzip compression in gRPC response [#21](https://github.com/rpcpool/yellowstone-fumarole/issues/21)
25+
- Exposes low-level metrics about fumarole session [#32](https://github.com/rpcpool/yellowstone-fumarole/issues/32)
26+
27+
### Fixes
28+
29+
- Added missing `asyncio.Queue.shutdown` calls to all queue managed by `yellowstone_fumarole_client.runtime.aio` module.
30+
- Fixed protobuf definition [#28][https://github.com/rpcpool/yellowstone-fumarole/issues/28]
31+
32+
### Breaking
33+
34+
- `yellowstone_fumarole_client.DragonsmouthAdapterSession.source` returns `AsyncGenerator` instead of `asyncio.Queue`. [#31](https://github.com/rpcpool/yellowstone-fumarole/issues/31)
35+
- Migrated `protobuf` from `^5` to `^6.32.0`
36+
37+
## [0.1.0]
38+
39+
Initial release

python/yellowstone-fumarole-client/README.md

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,33 +62,42 @@ async def dragonsmouth_like_session(fumarole_config):
6262
session = await client.dragonsmouth_subscribe(
6363
consumer_group_name="test",
6464
request=SubscribeRequest(
65-
# accounts={"fumarole": SubscribeRequestFilterAccounts()},
65+
accounts={"fumarole": SubscribeRequestFilterAccounts()},
6666
transactions={"fumarole": SubscribeRequestFilterTransactions()},
6767
blocks_meta={"fumarole": SubscribeRequestFilterBlocksMeta()},
6868
entry={"fumarole": SubscribeRequestFilterEntry()},
6969
slots={"fumarole": SubscribeRequestFilterSlots()},
7070
),
7171
)
72-
dragonsmouth_source = session.source
73-
handle = session.fumarole_handle
74-
block_map = defaultdict(BlockConstruction)
75-
while True:
76-
tasks = [asyncio.create_task(dragonsmouth_source.get()), handle]
77-
done, pending = await asyncio.wait(tasks, return_when=asyncio.FIRST_COMPLETED)
78-
for t in done:
79-
if tasks[0] == t:
80-
result: SubscribeUpdate = t.result()
81-
if result.HasField("block_meta"):
82-
block_meta: SubscribeUpdateBlockMeta = result.block_meta
83-
elif result.HasField("transaction"):
84-
tx: SubscribeUpdateTransaction = result.transaction
85-
elif result.HasField("account"):
86-
account: SubscribeUpdateAccount = result.account
87-
elif result.HasField("entry"):
88-
entry: SubscribeUpdateEntry = result.entry
89-
elif result.HasField("slot"):
90-
result: SubscribeUpdateSlot = result.slot
91-
else:
92-
result = t.result()
93-
raise RuntimeError("failed to get dragonsmouth source: %s" % result)
94-
```
72+
async with session:
73+
dragonsmouth_like_source = session.source
74+
# result: SubscribeUpdate
75+
async for result in dragonsmouth_like_source:
76+
if result.HasField("block_meta"):
77+
block_meta: SubscribeUpdateBlockMeta = result.block_meta
78+
elif result.HasField("transaction"):
79+
tx: SubscribeUpdateTransaction = result.transaction
80+
elif result.HasField("account"):
81+
account: SubscribeUpdateAccount = result.account
82+
elif result.HasField("entry"):
83+
entry: SubscribeUpdateEntry = result.entry
84+
elif result.HasField("slot"):
85+
result: SubscribeUpdateSlot = result.slot
86+
87+
# OUTSIDE THE SCOPE, YOU SHOULD NEVER USE `session` again.
88+
```
89+
90+
91+
At any point you can get a rough estimate if you are progression through the slot using `DragonsmouthAdapterSession.stats()` call:
92+
93+
```python
94+
95+
async with session:
96+
stats: FumaroleSubscribeStats = session.stats()
97+
print(f"{stats.log_committed_offset}, {stats.log_committable_offset}, {stats.max_slot_seen}")
98+
```
99+
100+
`log_committed_offset` : what have been ACK so for to fumarole remote service.
101+
`log_committable_offset` : what can be ACK to next commit call.
102+
`max_slot_seen` : maximum slot seen in the inner fumarole client state -- not yet processed by your code.
103+

0 commit comments

Comments
 (0)