Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9125709
example-journal-client.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
901 B
Subscribers
None
example-journal-client.py
View Options
import
pprint
def
process_objects
(
all_objects
):
"""Worker function handling incoming objects"""
for
(
object_type
,
objects
)
in
all_objects
.
items
():
for
object_
in
objects
:
print
(
f
"New {object_type} object:"
)
pprint
.
pprint
(
object_
)
print
()
def
main
():
from
swh.journal.client
import
get_journal_client
# Usually read from a config file:
config
=
{
"brokers"
:
[
"localhost:9092"
],
"group_id"
:
"my-consumer-group"
,
"auto_offset_reset"
:
"earliest"
,
}
# Initialize the client
client
=
get_journal_client
(
"kafka"
,
object_types
=
[
"revision"
,
"release"
],
privileged
=
True
,
**
config
)
try
:
# Run the client forever
client
.
process
(
process_objects
)
except
KeyboardInterrupt
:
print
(
"Called Ctrl-C, exiting."
)
exit
(
0
)
if
__name__
==
"__main__"
:
main
()
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Sat, Jun 21, 9:14 PM (4 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3237988
Attached To
rDJNL Journal infrastructure
Event Timeline
Log In to Comment