-
W. Trevor King authored
There is a lot of error checking here, which is good, but it distracts from the core logic of Irker.handle. By pulling the parsing out into a private helper function, we isolate the code focused on parsing and error checking from the code focused on dispatching and connection management, making both easier to read. I've also changed the Target-validation logic. The old Target.valid returned True if the Target URL was valid, and False otherwise. The new Target.validate returns None, and raises an InvalidRequest exception with an error message describing exactly why the URL is invalid. We print these messages when dropping server URLs in Irker._parse_request, while the old Irker.handle code silently dropped invalid targets. We also continue processing other server URLs after an invalid Target, while the old Irker.handle code bailed out after the first invalid Target. Besides making the invalid URLs more obvious in the logs and increasing resiliency to invalid URLs, these changes allow us to pull the URL-to-Target conversion out of Irker.handle entirely, so it can focus more strongly on dispatch and connection management.
W. Trevor King authoredThere is a lot of error checking here, which is good, but it distracts from the core logic of Irker.handle. By pulling the parsing out into a private helper function, we isolate the code focused on parsing and error checking from the code focused on dispatching and connection management, making both easier to read. I've also changed the Target-validation logic. The old Target.valid returned True if the Target URL was valid, and False otherwise. The new Target.validate returns None, and raises an InvalidRequest exception with an error message describing exactly why the URL is invalid. We print these messages when dropping server URLs in Irker._parse_request, while the old Irker.handle code silently dropped invalid targets. We also continue processing other server URLs after an invalid Target, while the old Irker.handle code bailed out after the first invalid Target. Besides making the invalid URLs more obvious in the logs and increasing resiliency to invalid URLs, these changes allow us to pull the URL-to-Target conversion out of Irker.handle entirely, so it can focus more strongly on dispatch and connection management.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.