You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tz...@apache.org on 2020/09/25 06:00:21 UTC

[flink-statefun] branch release-2.2 updated (3cea15d -> c9e257b)

This is an automated email from the ASF dual-hosted git repository.

tzulitai pushed a change to branch release-2.2
in repository https://gitbox.apache.org/repos/asf/flink-statefun.git.


    from 3cea15d  [hotfix] [legal] Update distribution jar NOTICE
     new fce1182  [FLINK-19399][doc][python] Document AsyncRequestReplyHandler
     new c9e257b  [hotfix][doc][py] Change Response -> Reply

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 docs/sdk/python.md | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)


[flink-statefun] 01/02: [FLINK-19399][doc][python] Document AsyncRequestReplyHandler

Posted by tz...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tzulitai pushed a commit to branch release-2.2
in repository https://gitbox.apache.org/repos/asf/flink-statefun.git

commit fce11822463893f6e8ff7dee99d46359b95a913a
Author: Igal Shilman <ig...@gmail.com>
AuthorDate: Thu Sep 24 16:53:04 2020 +0200

    [FLINK-19399][doc][python] Document AsyncRequestReplyHandler
    
    This closes #162.
---
 docs/sdk/python.md | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/docs/sdk/python.md b/docs/sdk/python.md
index ed74c30..7c00775 100644
--- a/docs/sdk/python.md
+++ b/docs/sdk/python.md
@@ -239,6 +239,36 @@ if __name__ == "__main__":
 	app.run()
 {% endhighlight %}
 
+
+### Serving Asynchronous Functions 
+
+The Python SDK ships with an additional handler, ``AsyncRequestReplyHandler``, that supports Python's awaitable functions (coroutines).
+This handler can be used with asynchronous Python frameworks, for example [aiohttp](https://docs.aiohttp.org/en/stable/).
+
+{% highlight python %}
+@functions.bind("example/hello")
+async def hello(context, message):
+    response = await compute_greeting(message)
+    context.reply(response)
+
+from aiohttp import web
+
+handler = AsyncRequestReplyHandler(functions)
+
+async def handle(request):
+    req = await request.read()
+    res = await handler(req)
+    return web.Response(body=res, content_type="application/octet-stream")
+
+app = web.Application()
+app.add_routes([web.post('/statefun', handle)])
+
+if __name__ == '__main__':
+    web.run_app(app, port=5000)
+
+{% endhighlight %}
+
+
 ## Context Reference
 
 The ``context`` object passed to each function has the following attributes / methods.


[flink-statefun] 02/02: [hotfix][doc][py] Change Response -> Reply

Posted by tz...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tzulitai pushed a commit to branch release-2.2
in repository https://gitbox.apache.org/repos/asf/flink-statefun.git

commit c9e257bfc7f74cfb97c0109bb14e387d17514d76
Author: Igal Shilman <ig...@gmail.com>
AuthorDate: Thu Sep 24 16:54:38 2020 +0200

    [hotfix][doc][py] Change Response -> Reply
---
 docs/sdk/python.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/sdk/python.md b/docs/sdk/python.md
index 7c00775..f334d74 100644
--- a/docs/sdk/python.md
+++ b/docs/sdk/python.md
@@ -224,7 +224,7 @@ handler RequestReplyHandler(functions)
 ### Serving Functions With Flask
 
 One popular Python web framework is [Flask](https://palletsprojects.com/p/flask/).
-It can be used to quickly and easily expose a ``RequestResponseHandler``.
+It can be used to quickly and easily expose a ``RequestReplyHandler``.
 
 {% highlight python %}
 @app.route('/statefun', methods=['POST'])