Skip to content

Commit c1950a9

Browse files
committed
for #1346 ...move queue settings higher in config file when converting
1 parent 9b2ff58 commit c1950a9

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

sarracenia/sr.py

+20-6
Original file line numberDiff line numberDiff line change
@@ -2803,19 +2803,24 @@ def convert1(self,cfg):
28032803
v3_cfg.write('#topicCopy on\n')
28042804

28052805
if component in [ 'sarra', 'sender', 'subscribe' ]:
2806-
v3_cfg.write('#v2 sftp handling is always absolute, sr3 is relative. might need this, remove when all sr3:\n')
2806+
v3_cfg.write(' \n#\n#v2 sftp handling is always absolute, sr3 is relative. might need this, remove when all sr3:\n')
28072807
v3_cfg.write('#flowcb accept.sftp_absolute\n')
28082808

28092809
queueName=None
28102810

28112811
#1st prep pass (for cases when re-ordering needed.)
2812+
already_moved=False
2813+
verbs_to_move = [ 'auto_delete', 'durable', 'expire', 'message_ttl', 'prefetch', \
2814+
'qos', 'queueBind', 'exchangeDeclare' ]
2815+
2816+
28122817
with open(v2_config_path, 'r') as v2_cfg:
2813-
for line in v2_cfg.readlines():
2814-
if len(line.strip()) < 1:
2818+
for input_line in v2_cfg.readlines():
2819+
if len(input_line.strip()) < 1:
28152820
continue
2816-
if line[0].startswith('#'):
2821+
if input_line[0].startswith('#'):
28172822
continue
2818-
line = line.strip().split()
2823+
line = input_line.strip().split()
28192824
k = line[0]
28202825
if k in synonyms:
28212826
k = synonyms[k]
@@ -2825,9 +2830,15 @@ def convert1(self,cfg):
28252830
inflight_seen=True
28262831
if k in [ 'queueName' ]:
28272832
queueName=line[1]
2833+
if k in verbs_to_move:
2834+
if not already_moved:
2835+
v3_cfg.write(f" \n#\n#Move formerly global options ({','.join(verbs_to_move)} to start of config file.\n")
2836+
alread_moved=True
2837+
v3_cfg.write(input_line+"\n")
2838+
28282839

28292840
if not inflight_seen and post_broker_seen and component in [ 'sarra', 'sender', 'subscribe' ]:
2830-
v3_cfg.write('#sr3 inflight defaults to None, v2 defaulted to .tmp when post_broker set.\n')
2841+
v3_cfg.write(' \n#\n#sr3 inflight defaults to None, v2 defaulted to .tmp when post_broker set.\n')
28312842
v3_cfg.write('inflight .tmp\n')
28322843

28332844
#2nd re-write pass.
@@ -2842,6 +2853,9 @@ def convert1(self,cfg):
28422853
continue
28432854
line = line.strip().split()
28442855
k = line[0]
2856+
2857+
if k in verbs_to_move: # moved to start of file.
2858+
continue
28452859
if k in synonyms:
28462860
k = synonyms[k]
28472861

0 commit comments

Comments
 (0)