Skip to content

Commit 7b710ba

Browse files
authored
Merge pull request #9 from ISISComputingGroup/forwarder_launch
add forwarder_launch
2 parents 17998ed + 139bffe commit 7b710ba

File tree

8 files changed

+53
-196
lines changed

8 files changed

+53
-196
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ target/
8181
profile_default/
8282
ipython_config.py
8383

84-
# pyenv
85-
.python-version
86-
8784
# pipenv
8885
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
8986
# However, in case of collaboration, if having platform-specific dependencies or dependencies

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

forwarder/configuration_store.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Dict
33
from unittest import mock
44

5-
from confluent_kafka import TopicPartition
5+
from confluent_kafka import TopicPartition, KafkaException, KafkaError
66
from streaming_data_types.fbschemas.forwarder_config_update_fc00.UpdateType import (
77
UpdateType,
88
)
@@ -49,7 +49,20 @@ def save_configuration(self, update_handlers: Dict):
4949
def retrieve_configuration(self):
5050
"""Retrieve last valid configuration buffer."""
5151
topic = TopicPartition(self._topic, partition=0)
52-
low_offset, high_offset = self._consumer.get_watermark_offsets(topic)
52+
try:
53+
low_offset, high_offset = self._consumer.get_watermark_offsets(topic)
54+
except KafkaException as e:
55+
kafka_error = e.args[0]
56+
57+
if kafka_error == KafkaError._UNKNOWN_PARTITION:
58+
# Topic doesn't exist yet - create it (assuming auto-create is enabled)
59+
message = serialise_fc00(UpdateType.REMOVEALL, [])
60+
self._producer.produce(self._topic, bytes(message), int(time.time() * 1000))
61+
self._producer.flush()
62+
low_offset, high_offset = self._consumer.get_watermark_offsets(topic)
63+
else:
64+
raise
65+
5366
# Set offset to current_offset to start retrieving from last message
5467
current_offset = high_offset - 1
5568
topic.offset = current_offset

forwarder/kafka/kafka_producer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def _poll_loop(self):
3333
except BaseException as e:
3434
self.logger.exception(e)
3535

36+
def flush(self):
37+
self._producer.flush()
38+
3639
def close(self):
3740
self._cancelled = True
3841
self._poll_thread.join()

forwarder/scripts/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def main():
194194
f"Forwarder version '{version}' started, service Id: {args.service_id}"
195195
)
196196
# EPICS
197-
ca_ctx = CaContext()
197+
ca_ctx = CaContext(client_name="forwarder")
198198
pva_ctx = PvaContext("pva", nt=False)
199199
# Using dictionary with Channel as key to ensure we avoid having multiple
200200
# handlers active for identical configurations: serialising updates from

forwarder_launch.bat

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
call C:\Instrument\Apps\EPICS\isis\forwarder\master\.venv\scripts\activate
2+
3+
set "EPICS_CA_ADDR_LIST=127.255.255.255 130.246.55.255"
4+
set "EPICS_CA_AUTO_ADDR_LIST=NO"
5+
6+
if "%INSTRUMENT%" == "HIFI" (
7+
set "BROKER=130.246.55.29:9092"
8+
) else (
9+
set "BROKER=livedata.isis.cclrc.ac.uk:31092"
10+
)
11+
12+
echo "starting forwarder"
13+
python C:\Instrument\Apps\EPICS\isis\forwarder\master\forwarder_launch.py --status-topic=%BROKER%/%INSTRUMENT%_forwarderStatus --config-topic=%BROKER%/%INSTRUMENT%_forwarderConfig --storage-topic=%BROKER%/%INSTRUMENT%_forwarderStorage --output-broker=%BROKER%

requirements-dev.txt

Lines changed: 0 additions & 165 deletions
This file was deleted.
Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,44 @@
1-
#
2-
# This file is autogenerated by pip-compile with Python 3.8
3-
# by the following command:
4-
#
5-
# pip-compile --output-file=requirements.txt pyproject.toml
6-
#
7-
caproto==1.1.1
1+
# This file was autogenerated by uv via the following command:
2+
# uv pip compile pyproject.toml -o requirements-frozen.txt
3+
caproto==1.2.0
84
# via forwarder (pyproject.toml)
9-
configargparse==1.7
5+
configargparse==1.7.1
106
# via forwarder (pyproject.toml)
11-
confluent-kafka==2.3.0
7+
confluent-kafka==2.11.0
128
# via forwarder (pyproject.toml)
13-
epicscorelibs==7.0.7.99.0.2
9+
epicscorelibs==7.0.7.99.1.2
1410
# via
1511
# p4p
1612
# pvxslibs
17-
ess-streaming-data-types==0.26.1
13+
ess-streaming-data-types==0.27.0
1814
# via forwarder (pyproject.toml)
19-
flatbuffers==23.5.26
15+
flatbuffers==25.2.10
2016
# via ess-streaming-data-types
2117
graphyte==1.7.1
2218
# via forwarder (pyproject.toml)
23-
graypy==2.1.0
24-
# via forwarder (pyproject.toml)
25-
nose2==0.14.1
19+
nose2==0.15.1
2620
# via p4p
27-
numpy==1.24.4
21+
numpy==1.26.4
2822
# via
23+
# forwarder (pyproject.toml)
2924
# epicscorelibs
3025
# ess-streaming-data-types
31-
# forwarder (pyproject.toml)
3226
# p4p
33-
p4p==4.1.11
27+
p4p==4.2.1
3428
# via forwarder (pyproject.toml)
3529
ply==3.11
3630
# via p4p
37-
prometheus-client==0.20.0
31+
prometheus-client==0.22.1
3832
# via forwarder (pyproject.toml)
39-
pvxslibs==1.2.4
33+
pvxslibs==1.4.0
4034
# via p4p
41-
setuptools-dso==2.10
35+
setuptools==80.9.0
36+
# via
37+
# epicscorelibs
38+
# setuptools-dso
39+
setuptools-dso==2.12.2
4240
# via
4341
# epicscorelibs
4442
# pvxslibs
45-
tomli==2.0.1
43+
tomli==2.2.1
4644
# via forwarder (pyproject.toml)
47-
48-
# The following packages are considered to be unsafe in a requirements file:
49-
# setuptools

0 commit comments

Comments
 (0)