Skip to content

Commit 1802cda

Browse files
authored
Merge pull request #11 from ISISComputingGroup/add_status_reporting_interval
Add status reporting interval
2 parents 37f0cb4 + fc2b6e2 commit 1802cda

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

forwarder/parse_commandline_args.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,14 @@ def parse_args():
183183
type=int,
184184
default=1000,
185185
)
186+
parser.add_argument(
187+
"--status-interval",
188+
help="Period for status updates (units=milliseconds)",
189+
required=False,
190+
env_var="STATUS_INTERVAL",
191+
type=int,
192+
default=4000,
193+
)
186194
log_choice_to_enum = {
187195
"Trace": logging.DEBUG,
188196
"Debug": logging.DEBUG,

forwarder/scripts/run.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def create_status_reporter(
8181
service_id,
8282
version,
8383
logger,
84+
status_interval,
8485
):
8586
(
8687
broker,
@@ -107,6 +108,7 @@ def create_status_reporter(
107108
service_id,
108109
version,
109110
logger,
111+
status_interval,
110112
)
111113
return status_reporter
112114

@@ -249,6 +251,7 @@ def main():
249251
args.service_id,
250252
version,
251253
get_logger(),
254+
args.status_interval,
252255
)
253256
exit_stack.callback(status_reporter.stop)
254257
status_reporter.start()

forwarder/status_reporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(
2222
service_id: str,
2323
version: str,
2424
logger: Logger,
25-
interval_ms: int = 4000,
25+
interval_ms: int,
2626
):
2727
self._repeating_timer = RepeatTimer(
2828
milliseconds_to_seconds(interval_ms), self.report_status

forwarder_launch.bat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ set "EPICS_CA_ADDR_LIST=127.255.255.255 130.246.55.255"
1313
set "EPICS_CA_AUTO_ADDR_LIST=NO"
1414

1515
echo "starting forwarder"
16-
python %~dp0forwarder_launch.py --status-topic=%KAFKA_BROKER%/%INSTRUMENT%_forwarderStatus --config-topic=%KAFKA_BROKER%/%INSTRUMENT%_forwarderConfig --storage-topic=%KAFKA_BROKER%/%INSTRUMENT%_forwarderStorage --output-broker=%KAFKA_BROKER%
16+
python %~dp0forwarder_launch.py --status-topic=%KAFKA_BROKER%/%INSTRUMENT%_forwarderStatus --config-topic=%KAFKA_BROKER%/%INSTRUMENT%_forwarderConfig --storage-topic=%KAFKA_BROKER%/%INSTRUMENT%_forwarderStorage --output-broker=%KAFKA_BROKER% --status-interval=300000
17+
1718

tests/status_reporter_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_when_update_handlers_exist_their_channel_names_are_reported_in_status()
2424
}
2525

2626
fake_producer = FakeProducer()
27-
status_reporter = StatusReporter(update_handlers, fake_producer, "status_topic", "", "version", logger) # type: ignore
27+
status_reporter = StatusReporter(update_handlers, fake_producer, "status_topic", "", "version", logger, 4000) # type: ignore
2828
status_reporter.report_status()
2929

3030
if fake_producer.published_payloads:
@@ -43,7 +43,7 @@ def test_when_no_update_handlers_exist_no_streams_are_present_in_reported_status
4343
update_handlers: Dict = {}
4444

4545
fake_producer = FakeProducer()
46-
status_reporter = StatusReporter(update_handlers, fake_producer, "status_topic", "", "version", logger) # type: ignore
46+
status_reporter = StatusReporter(update_handlers, fake_producer, "status_topic", "", "version", logger, 4000) # type: ignore
4747
status_reporter.report_status()
4848

4949
if fake_producer.published_payloads:
@@ -59,7 +59,7 @@ def test_status_message_contains_service_id():
5959
update_handlers: Dict = {}
6060

6161
fake_producer = FakeProducer()
62-
status_reporter = StatusReporter(update_handlers, fake_producer, "status_topic", service_id, "version", logger) # type: ignore
62+
status_reporter = StatusReporter(update_handlers, fake_producer, "status_topic", service_id, "version", logger, 4000) # type: ignore
6363
status_reporter.report_status()
6464

6565
if fake_producer.published_payloads:

0 commit comments

Comments
 (0)