@@ -50,8 +50,8 @@ unmigrated application. You have to make sure that the `django rest hooks
5050Make sure you have added :code: `rest_hooks_delivery ` to the list of
5151:code: `INSTALLED_APPS ` before :code: `django.contrib.admin ` and that you have
5252set :code: `HOOK_DELIVERER ` to one of the available deliverers. Currently
53- :code: `rest_hooks_delivery.deliverers.batch ` and
54- :code: `rest_hooks_delivery.deliverers.retry ` are available.
53+ :code: `rest_hooks_delivery.deliverers.retry ` and
54+ :code: `rest_hooks_delivery.deliverers.batch ` are available.
5555
5656To use the retry deliverer:
5757
@@ -83,20 +83,45 @@ explained in the rest of this section assumes this. The deliverer has 2 modes.
8383
8484size
8585`````
86+ .. code-block :: python
87+
88+ HOOK_DELIVERER_SETTINGS = {
89+ ...
90+ ' size' : 3 , # Number of hook events per target URL
91+ ...
92+ }
93+
8694 In size mode the deliverer will check the :code: `size ` setting and batch the
8795hooks whenever they reach the specified size.
8896
8997time
9098`````
99+ .. code-block :: python
100+
101+ HOOK_DELIVERER_SETTINGS = {
102+ ...
103+ ' time' : 60 , # Time to delay batching hook events for target URL(seconds)
104+ ...
105+ }
106+
91107 In time mode the deliverer will trigger a delayed batching of hooks. It will
92108read the time to delay from the :code: `time ` setting. This delayed batching
93109is triggered when the first hook for a target URL is sent to the deliverer.
94110
95111mixed
96112``````
113+ .. code-block :: python
114+
115+ HOOK_DELIVERER_SETTINGS = {
116+ ...
117+ ' time' : 60 ,
118+ ' size' : 5 ,
119+ ...
120+ }
121+
97122 The time and size modes can be mixed. The deliverer will batch by whichever
98- event comes first. To use this mode, list both the size and time modes in
99- the :code: ` batch_by ` setting. See below for example .
123+ event occurs first. To use this mode, provide both the time and size settings.
124+ The order of the settings in the configuration dictionary does not matter .
100125
101126
102127Note: It is important to use caution when choosing the configuration values
@@ -105,25 +130,35 @@ for the deliverer as this can lead to resource misuse when not done properly.
105130If this deliverer is selected, do not forget to start a celery worker for your
106131project.
107132
108- retry
109- ``````
110- This deliverer can also retry failed deliveries. When retry is True the
111- deliverer will retry failed deliveries every :code: `time ` seconds until either
112- successful or :code: `retries ` retries have failed, at which point it will give
113- up. When the deliverer gives up it will discard all failed hooks for the
114- current target URL.
115-
116- Don't forget to start a celery worker for your project:
117-
118133.. code-block :: bash
119-
120- celery -A proj worker -l info
134+
135+ celery -A proj worker -l info
121136
122137 where proj is the name of your project.
123138
124139Check the `Celery <http://www.celeryproject.org >`_ website for a detailed
125140example.
126141
142+ retry
143+ ``````
144+ .. code-block :: python
145+
146+ HOOK_DELIVERER_SETTINGS = {
147+ ...
148+ ' retry' : {
149+ ' retries' : 2 , # Number of times to retry failed deliveries
150+ ' retry_interval' : 5 , # Time to delay between retries(seconds)
151+ }
152+ ...
153+ }
154+
155+ This deliverer can also retry failed deliveries. When the :code: `retry ` setting
156+ is provided the deliverer will retry failed deliveries every
157+ :code: `retry_interval ` seconds until either successful or :code: `retries `
158+ retries have failed, at which point it will give up. When the deliverer gives
159+ up it will discard all failed hooks for the current target URL. If this setting
160+ is not provided the deliverer will discard failed deliveries.
161+
127162Example
128163________
129164
@@ -142,11 +177,11 @@ ________
142177 HOOK_DELIVERER = ' rest_hooks_delivery.deliverers.batch'
143178
144179 HOOK_DELIVERER_SETTINGS = {
145- ' batch_by ' : [ ' time ' , ' size ' ], # List of batching modes
146- # can be [ 'time'], ['size'] or ['size', 'time']
147- ' size ' : 3 , # Number of hook events/target url to batch
148- ' time ' : 60 , # time to delay batching for target URL(in seconds)
149- ' retry ' : True , # Retry failed hook deliveries(True) or discard(False)
150- # Compulsory if retry is True
151- ' retries ' : 2 , # Number of times to retry failed deliveries
180+ ' size ' : 3 ,
181+ ' time' : 60 ,
182+ # You can comment out the mode you do not need above
183+ ' retry ' : {
184+ ' retries ' : 2 ,
185+ ' retry_interval ' : 5 ,
186+ }
152187 }
0 commit comments