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

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

commit e82c2a0c40d5c00c758ad164bc1441ddb4c8567c
Author: Tzu-Li (Gordon) Tai <[email protected]>
AuthorDate: Thu Nov 26 16:35:33 2020 +0800

    [FLINK-20268] [python, docs] Update Python SDK README.md
    
    This closes #179.
---
 statefun-python-sdk/README.md | 46 ++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/statefun-python-sdk/README.md b/statefun-python-sdk/README.md
index a39294b..daae600 100755
--- a/statefun-python-sdk/README.md
+++ b/statefun-python-sdk/README.md
@@ -40,7 +40,7 @@ The JVM-based Stateful Functions implementation has a 
`RequestReply` extension (
 #### Define and Declare a Function
 
 ```
-from statefun import StatefulFunctions
+from statefun import StatefulFunctions, StateSpec
 
 functions = StatefulFunctions()
 
@@ -49,7 +49,29 @@ def greet(context, message: LoginEvent):
     print("Hey " + message.user_name)
 ```
 
-This code declares a function with a `FunctionType("demo", "greeter")` and 
binds the greet Python instance to it.
+This code declares a function with of type `FunctionType("demo", "greeter")` 
and binds it to the instance.
+
+#### Registering and accessing persisted state
+
+You can register persistent state that will be managed by the Stateful 
Functions workers
+for state consistency and fault-tolerance. The state values could be absent 
(`None` or a `google.protobuf.Any`) and
+they can be generally obtained via the context parameter:
+
+```
+from statefun import StatefulFunctions, StateSpec
+
+functions = StatefulFunctions()
+
[email protected](
+    typename="demo/greeter",
+    states=[StateSpec('session')])
+def greet(context, message: LoginEvent):
+    session = context['session']
+    if not session:
+       session = start_session(message)
+       context['session'] = session
+    ...
+```
 
 #### Expose with a Request Reply Handler
 
@@ -90,26 +112,6 @@ functions:
       type: demo/greeter
     spec:
       endpoint: http://<end point url>/statefun
-      states:
-        - foo
-        - bar
-        - baz
-```
-
-#### Eager State Registration
-
-The request reply protocol requires that the state names would be registered 
in the module YAML file
-under the `states` section (see the example above). The state values could be 
absent (`None` or a `google.protobuf.Any`) and they can be generally obtained 
via the context parameter:
-
-```
[email protected]("demo/greeter")
-def greet(context, message: LoginEvent):
-    session = context['session']
-    if not session:
-       session = start_session(message)
-       context['session'] = session
-    ...
-
 ```
 
 ### Testing

Reply via email to