forked from faust-streaming/faust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.py
42 lines (36 loc) · 842 Bytes
/
helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from time import time
from faust.events import Event
from faust.types.tuples import Message
__all__ = ["message", "new_event"]
def message(
key=None,
value=None,
*,
topic="topic",
partition=0,
timestamp=None,
headers=None,
offset=1,
checksum=None,
generation_id=0,
):
return Message(
key=key,
value=value,
topic=topic,
partition=partition,
offset=offset,
timestamp=timestamp or time(),
timestamp_type=1 if timestamp else 0,
headers=headers,
checksum=checksum,
generation_id=generation_id,
)
def new_event(app, key=None, value=None, *, headers=None, **kwargs):
return Event(
app,
key,
value,
headers,
message(key=key, value=value, headers=headers, **kwargs),
)