Skip to content
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

Unsafe & Async Helper Proof of Concept #516

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bdanklin
Copy link
Contributor

This shows a proof of concept for auto generating bang functions. A similar method can be applied to trivially generate async functions using Task.

@async
@unsafe
def create_reaction(arg1, arg2, arg3) do

results in the following function definitions

def create_reaction(arg1, arg2, arg3), do: ...
def create_reaction!(arg1, arg2, arg3), do: ...
def create_reaction_async(arg1, arg2, arg3), do: ...

image

This can also be applied to async functions. eg take the function
edit_message. adding @unsafe and @async attributes to the function
can handle generating edit_message! and edit_message_async respectively.

This only contains the code for the banged versions however should
the implementaion be approved the async code is trivial.

This also allows all the manual bang functions to be remove from the api
module. (Approx 70)
@jchristgit
Copy link
Collaborator

With async I think we need to go the reverse route.

The default needs to be _async and the sync functions then call that and await on the response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants