@@ -25,47 +25,38 @@ case, you might want to use directly boto.
25
25
Code sample
26
26
~~~~~~~~~~~
27
27
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.
33
32
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 `_.
45
35
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
57
37
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)
63
59
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' )))
69
60
70
61
Application architecture
71
62
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -82,6 +73,11 @@ Application architecture
82
73
│ └── s3.py # Task that focuses on s3 files.
83
74
└── task_example.py # Your different tasks.
84
75
76
+ Trusted by
77
+ ~~~~~~~~~~
78
+
79
+ |The Orchard | |Sony Music | |DataArt |
80
+
85
81
Contributors
86
82
~~~~~~~~~~~~
87
83
@@ -93,6 +89,7 @@ Contributors
93
89
.. _xethorn : github.com/xethorn
94
90
.. _rantonmattei : github.com/rantonmattei
95
91
.. _someboredkiddo : github.com/someboredkiddo
92
+ .. _example : https://github.com/xethorn/garcon/tree/master/example/custom_decider
96
93
97
94
.. |BuildStatus | image :: https://github.com/xethorn/garcon/workflows/Build/badge.svg
98
95
:target: https://github.com/xethorn/garcon/actions?query=workflow%3ABuild+branch%3Amaster
@@ -102,3 +99,12 @@ Contributors
102
99
103
100
.. |CoverageStatus | image :: https://coveralls.io/repos/xethorn/garcon/badge.svg?branch=master
104
101
: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