-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
asyncio API and discord mirror (seeking feedback) #740
base: main
Are you sure you want to change the base?
Conversation
It supports basic text mirroring between Discord guilds and Zulip streams (within a single Zulip realm). On both the Discord and Zulip sides, it can either send as a single bot with limited special permissions, or with special permissions (webhooks and can_forge_sender respectively), it can more naturally mirror them. There is currently no special support for threads, media, embeds, reactions, etc..
@andersk would you be up for doing the review on this? |
Not sure if I’ll have time for anything like a full review soon, but some quick thoughts:
|
Otherwise, if somebody else (eg, test vs prod, or a previous operator) has a hook called zulip_mirror, we try to use that hook, fail, and don't send the message.
I would be interested in an async version of the client to improve overall performance in an async server environment. Have you thought about generating both sync and async clients based on the OpenAPI specification? Although I don't have experience with doing so, I have heard it recommended as a best practice. |
This PR adds support for an asyncio Zulip API (#483) and a discord mirroring script using it. It's definitely not ready to merge, but I think it'd be useful to have somebody look it over and provide some more feedback before I get it mergeable. The async client is mostly a pretty direct port of the original client, though obviously some of the lower-level functions had more changes.
Some things I'd like guidance on / places that seem suboptimal that maybe there's a better solution for:
call_on_each_event
,RandomExponentialBackoff
) in separate commits, and then various later commits cleaning up lint errors. What degree of commit splitting seems useful? Presumably the lint fixup commits should be merged to be earlier, but is it useful to leave any of the early commits separate, or should I just have one "add an async API" commit?async def call_endpoint(...) -> Awaitable[Dict[str, Any]]:
correct? TheAwaitable
feels sorta unwieldy and feels a little like it should be inferable from theasync
, but maybe that's the right thing?mypy
doesn't like async RandomExponentialBackoff becausefail
changes from a function returningNone
, to a coroutine returningNone
. It seems to work, and seems a pity to duplicateCountingBackoff
, but I'm not sure there's a good way to appease the type-checker (or if there's a subtle error).async
beforedef
, andawait
afterreturn
". It's conceivable there's a good way to automate this? I didn't bother to, but I also didn't bother converting all the methods...do_api_query
, which has a lot of error handling code. I tried to update it appropriately, but haven't tested all the ways things could fail. It's possible it makes more sense to delete a bunch of the error handling, and re-add it as people discover issues, rather than have untested error handling that I don't especially understand? Dunno.