Skip to content

Commit 4dd4ff6

Browse files
authored
Add documentation changes for file watch source. (#23)
1 parent 88f9ba5 commit 4dd4ff6

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

docs/connectors.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,32 @@ source_config = dict(kind='file-watch-source',
198198
events='DELETE,CREATE')
199199
```
200200

201-
The event format for this source is:
201+
The returned result is a JSON message with the following structure:
202+
202203
```
203-
<event_type>:file=<filename>
204+
{"filename": <filename_value>, "event_type": <event_type>}
204205
```
206+
where event_type is one of `DELETE`, `CREATE` or `MODIFY`
205207

206208
For example, when the file `test.txt` is deleted from the watched folder the event returned is:
207209
```
208-
DELETE:file=/absolute/path/to/test.txt
210+
{
211+
"filename": "/absolute/path/to/test.txt",
212+
"event_type": "DELETE"
213+
}
209214
```
210215

216+
Convert the event to JSON when handling the event:
217+
218+
```
219+
import json
220+
json_event = json.loads(event)
221+
```
222+
and then access its field like so:
223+
```
224+
json_event['filename']
225+
json_event['event_type']
226+
```
211227

212228
## Sinks
213229

0 commit comments

Comments
 (0)