Skip to content

Commit c0bdb55

Browse files
authored
Merge pull request #13 from iterorganization/feature/cli-timeout
Add --timeout CLI option to kafka-to-imasentry
2 parents 51069ef + 2ab28eb commit c0bdb55

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/imas_streams/cli.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,14 @@ def main() -> None:
3131
@click.option(
3232
"--overwrite", is_flag=True, help="Overwrite any existing IMAS Data Entry."
3333
)
34+
@click.option("--timeout", "-t", default=5.0, help="Timeout for receiving next message")
3435
def kafka_to_imasentry(
35-
kafka_host: str, kafka_topic: str, imas_uri: str, batch_size: int, overwrite: bool
36+
kafka_host: str,
37+
kafka_topic: str,
38+
imas_uri: str,
39+
batch_size: int,
40+
overwrite: bool,
41+
timeout: float,
3642
):
3743
"""Consume streaming IMAS data from Kafka and store data in an IMAS Data Entry.
3844
@@ -59,6 +65,6 @@ def kafka_to_imasentry(
5965

6066
mode = "w" if overwrite else "x"
6167
with imas.DBEntry(imas_uri, mode) as entry:
62-
for result in consumer.stream():
68+
for result in consumer.stream(timeout=timeout):
6369
if result is not None:
6470
entry.put_slice(result)

0 commit comments

Comments
 (0)