New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataStore の wait メソッドが変更されたデータを返す実装 #77
DataStore の wait メソッドが変更されたデータを返す実装 #77
Conversation
Signed-off-by: MtkN1 <51289448+MtkN1@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
内容確認しました。
waitメソッドのeventを利用してinsert/update/deleteから取得できるようにするロジックはとても巧妙ですね!
しかし以下(FTXDataStore
)のように ** forループでinsertメソッドを呼ぶパターン ** があるため元の実装のままだとループの最後の1アイテムしか取得できません。
https://github.com/MtkN1/pybotters/blob/2f8504fa798ebddacda9ae13edafa56816bffeea/pybotters/models/ftx.py#L109-L115
これを解決したコードを直接コミットさせて頂きました。
実環境のテストコード async def main():
async with pybotters.Client() as client:
store = pybotters.FTXDataStore()
ws = await client.ws_connect(
'wss://ftx.com/ws/',
send_json={'op': 'subscribe', 'channel': 'trades', 'market': 'BTC-PERP'},
hdlr_json=store.onmessage
)
while True:
ret = await store.trades.wait()
print(ret) |
実装自体はこれで問題ないのですが、設計上懸念をしています。
果たしてこの仕様でいいのか/むしろそうあるべきなのか悩ましいです。 |
こちらマージが遅くなって申し訳ないです。 |
✨v0.6.0リリース ## Issues ✅ 対応取引所の追加(Phemex、Coincheck) #52 ✅ GMO コインの DataStore を実装する #60 ✅ リリース表記をPreview版にする #73 ✅ FTXDataStore の orders チャネルにおける close されたオーダーの取り扱いについて #75 ✅ DataStoreInterfaceのクラス名を変更する #79 ## Pull requests ✅ GMO コイン用の DataStore を一部実装する #74 ✅ DataStore のレコード削除メソッドのサンプル実装 #76 ✅ DataStore の wait メソッドが変更されたデータを返す実装 #77 ✅ Sphinxのドキュメントを追加 #78
#75 の storewait() が変更されたデータを返す場合の簡単な実装です。
以下のメソッドの引数 data に渡された値を store.wait() が返します。
実際に変更されたデータが返されるわけではないことに注意してください。
get や find のようなクエリによる絞り込み機能は実装していません。