Skip to content

Commit 6eae7e6

Browse files
authored
Merge pull request xethorn#104 from xethorn/xethorn/21-may-update-readme
Update example in README
2 parents 280c119 + 5bd4b3b commit 6eae7e6

File tree

1 file changed

+43
-37
lines changed

1 file changed

+43
-37
lines changed

README.rst

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,38 @@ case, you might want to use directly boto.
2525
Code sample
2626
~~~~~~~~~~~
2727

28-
The code sample shows a workflow that has 4 activities. It starts with
29-
activity\_1, which after being completed schedule activity\_2 and
30-
activity\_3 to be ran in parallel. The workflow ends after the
31-
completion of activity\_4 which requires activity\_2 and activity\_3 to
32-
be completed.
28+
The code sample shows a workflow where a user enters a coffee shop, orders
29+
a coffee and a chocolate chip cookie. All ordered items are prepared and
30+
completed, the user pays the order, receives the ordered items, then leave
31+
the shop.
3332

34-
.. code:: python
35-
36-
import boto3
37-
from garcon import activity
38-
from garcon import runner
39-
40-
client = boto3.client('swf', region_name='us-east-1')
41-
42-
domain = 'dev'
43-
name = 'workflow_sample'
44-
create = activity.create(client, domain, name)
33+
The code below represents the workflow decider. For the full code sample,
34+
see the `example`_.
4535

46-
test_activity_1 = create(
47-
name='activity_1',
48-
run=runner.Sync(
49-
lambda activity, context: print('activity_1')))
50-
51-
test_activity_2 = create(
52-
name='activity_2',
53-
requires=[test_activity_1],
54-
run=runner.Async(
55-
lambda activity, context: print('activity_2_task_1'),
56-
lambda activity, context: print('activity_2_task_2')))
36+
.. code:: python
5737
58-
test_activity_3 = create(
59-
name='activity_3',
60-
requires=[test_activity_1],
61-
run=runner.Sync(
62-
lambda activity, context: print('activity_3')))
38+
enter = schedule('enter', self.create_enter_coffee_activity)
39+
enter.wait()
40+
41+
total = 0
42+
for item in ['coffee', 'chocolate_chip_cookie']:
43+
activity_name = 'order_{item}'.format(item=item)
44+
activity = schedule(activity_name,
45+
self.create_order_activity,
46+
input={'item': item})
47+
total += activity.result.get('price')
48+
49+
pay_activity = schedule(
50+
'pay', self.create_payment_activity,
51+
input={'total': total})
52+
53+
get_order = schedule('get_order', self.create_get_order_activity)
54+
55+
# Waiting for paying and getting the order to complete before
56+
# we let the user leave the coffee shop.
57+
pay_activity.wait(), get_order.wait()
58+
schedule('leave_coffee_shop', self.create_leave_coffee_shop)
6359
64-
test_activity_4 = create(
65-
name='activity_4',
66-
requires=[test_activity_3, test_activity_2],
67-
run=runner.Sync(
68-
lambda activity, context: print('activity_4')))
6960
7061
Application architecture
7162
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -82,6 +73,11 @@ Application architecture
8273
│ └── s3.py # Task that focuses on s3 files.
8374
└── task_example.py # Your different tasks.
8475

76+
Trusted by
77+
~~~~~~~~~~
78+
79+
|The Orchard| |Sony Music| |DataArt|
80+
8581
Contributors
8682
~~~~~~~~~~~~
8783

@@ -93,6 +89,7 @@ Contributors
9389
.. _xethorn: github.com/xethorn
9490
.. _rantonmattei: github.com/rantonmattei
9591
.. _someboredkiddo: github.com/someboredkiddo
92+
.. _example: https://github.com/xethorn/garcon/tree/master/example/custom_decider
9693

9794
.. |BuildStatus| image:: https://github.com/xethorn/garcon/workflows/Build/badge.svg
9895
:target: https://github.com/xethorn/garcon/actions?query=workflow%3ABuild+branch%3Amaster
@@ -102,3 +99,12 @@ Contributors
10299

103100
.. |CoverageStatus| image:: https://coveralls.io/repos/xethorn/garcon/badge.svg?branch=master
104101
:target: https://coveralls.io/r/xethorn/garcon?branch=master
102+
103+
.. |The Orchard| image:: https://media-exp1.licdn.com/dms/image/C4E0BAQGi7o5g9l4JWg/company-logo_200_200/0/1519855981606?e=2159024400&v=beta&t=WBe-gOK2b30vUTGKbA025i9NFVDyOrS4Fotx9fMEZWo
104+
:target: https://theorchard.com
105+
106+
.. |Sony Music| image:: https://media-exp1.licdn.com/dms/image/C4D0BAQE9rvU-3ig-jg/company-logo_200_200/0/1604099587507?e=2159024400&v=beta&t=eAAubphf_fI-5GEb0ak1QnmtRHmc8466Qj4sGrCsWYc
107+
:target: https://www.sonymusic.com/
108+
109+
.. |DataArt| image:: https://media-exp1.licdn.com/dms/image/C4E0BAQGRi6OIlNQG8Q/company-logo_200_200/0/1519856519357?e=2159024400&v=beta&t=oi6HQpzoeTKA082s-8Ft75vGTvAkEp4VHRyMLeOHXoo
110+
:target: https://www.dataart.com/

0 commit comments

Comments
 (0)