joshuadavidthomas / django-github-app

A Django toolkit for GitHub Apps with batteries included
MIT License
6 stars 0 forks source link

Add ability to use in sync Django applications #14

Open joshuadavidthomas opened 2 hours ago

joshuadavidthomas commented 2 hours ago

Since gidgethub is async-first, this library has started out with only the ability to use in an async context. However, I would wager the vast, vast majority of Django projects out there are not async. django-github-app should support both sync and async contexts for this reason.

There are already some stubbed out classes that I created to make a note of where the sync code will need to go:

As well, the built-in events contained in django_github_app.events will need to be adjusted to provide sync handlers as well. I'm a little unsure about the best way to handle that..

All of the models already have sync and async methods, so there should need to be anything adjusted there to support sync.

TODO

joshuadavidthomas commented 2 hours ago

I suppose for the events, the django_github_app.routing.GitHubRouter could be adjusted to route to sync or async based on.. something. Right now it is basically a loose wrapper around gidgethub.routing.Router so this needs to be more thought through, as that router expects async callbacks.

Maybe doing away with the wrapper and fleshing out the library's GitHubRouter to handle all the event routing itself is the way to go.

Still not sure how to route between sync and async for internal webhook events in a relatively seamless way for users of the library.