During a query execution we currently verify whether we have that query supported in our dispatch table. Since it's an error not to have it anyway, we move this verification to the class creation, erroring out early if such a problem exists.
Signed-off-by: Guido Trotter <ultrot...@google.com> --- lib/confd/server.py | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/confd/server.py b/lib/confd/server.py index 3d1a2ee..efea38d 100644 --- a/lib/confd/server.py +++ b/lib/confd/server.py @@ -57,6 +57,9 @@ class ConfdProcessor(object): """ self.reader = reader self.hmac_key = utils.ReadFile(constants.HMAC_CLUSTER_KEY) + assert \ + not constants.CONFD_REQS.symmetric_difference(self.DISPATCH_TABLE), \ + "DISPATCH_TABLE is unaligned with CONFD_REQS" def ExecQuery(self, payload_in, ip, port): """Process a single UDP request from a client. @@ -131,10 +134,6 @@ class ConfdProcessor(object): msg = "missing requested salt" raise errors.ConfdRequestError(msg) - if request.type not in self.DISPATCH_TABLE: - msg = "Valid request %d not in DISPATCH_TABLE" % request.type - raise errors.ProgrammerError(msg) - query_object = self.DISPATCH_TABLE[request.type](self.reader) status, answer = query_object.Exec(request.query) reply = objects.ConfdReply( -- 1.5.6.5