Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Call UpdateService for SRV & A/AAAA records as well as TXT #239
Call UpdateService for SRV & A/AAAA records as well as TXT #239
Changes from all commits
43e1b24
d314896
f40649a
6a3deb7
4a1f7e5
2b258fd
064056b
cc78868
aa3e947
c1d5625
dc570c9
d8f3508
902548b
f3d6bf2
53cd650
700a183
d2cfb86
23aa41f
2c16b31
98bdbfd
a3ab378
a42ee2c
5d69f91
c2d4b0c
6831c2e
38c3ed9
23e4af1
4bb5539
dc653d1
d086b82
a6da721
592c0e1
982f75b
4b48dd9
56955ed
abc4773
73ae509
f142584
aad875d
7430ca0
9fe89c6
55a0026
4b2c476
4e6c84d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, two things here.
Regarding the logic, I had to write myself a little table to make sure I understand things correctly. I added some notes in two cases that I believe to be worth taking a second look at. The table:
Regarding the implementation details, I think
_handlers_to_call
could work better as anOrderedDict[str, ServiceStateChange]
instead ofList[Tuple[str,ServiceStateChange]]
. The code below could then look more or less like (keeping the logic intact, I let myself reverse the logic and remove the early return(s), as it it wouldn't really make sense in this case):This removes all that
count()
,remove()
andappend()
dance which is nice I think. Then the popping code would use OrderedDict.popitem() instead oflist.pop()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it, the code could just be an unconditional
self._handlers_to_call[name] = state_change
. :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ll have a bit more of a think about this one the coming week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your last suggestion won't work because then an update trumps an add. I've used a slightly amended version of your first suggestion and the code you had above didn't update removed if for example the list was empty.
Regarding your 2 queries about the truth table, yes there are some combinations that don't make sense and in a well written responded shouldn't happen. However I've taken the view that I need to make a decision on the precedence of the messages and my view is that Added always wins, so for example if we receive an add and remove message in the same batch, then add is the most likely meaning. I can hypothesise a reason this might occur if you have multiple res ponders and one goes offline. In this case Added + Removed still means there is a service there to respond. (note this is a contrived example as the messages would come in a different batch)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough – if it causes issues I expect it'll be reported and we'll sort it out then, having a concrete case to deal with.