-
Notifications
You must be signed in to change notification settings - Fork 93
Abstract database calls from direct listener handlers #206
base: main
Are you sure you want to change the base?
Conversation
57e2736
to
2e2bde7
Compare
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.
Approved with minor corrections and a question.
examples/common/python/connectors/direct/tcs_listener/tcs_workorder_receipt_handler.py
Outdated
Show resolved
Hide resolved
if (self.kv_helper.get("wo-receipts", wo_id) is not None): | ||
self.kv_helper.remove("wo-receipts", wo_id) | ||
|
||
# TODO: uncomment after fixing lmbd error |
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.
Is this comment still needed?
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.
Need to check the intent with initial committer. lixiangmin01@baidu.com
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 guess this is not required any more. @Ram-srini ?
if update_to_receipt["updaterId"] != updater_id: | ||
raise JSONRPCDispatchException( | ||
JRPCErrorCodes.INVALID_PARAMETER_FORMAT_OR_VALUE, | ||
"Update index and updater id doesn't match" |
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.
s/match/match./
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.
Fixed.
else: | ||
raise JSONRPCDispatchException( | ||
JRPCErrorCodes.INVALID_PARAMETER_FORMAT_OR_VALUE, | ||
"There is no updates available to this receipt" |
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.
s/receipt/receipt./
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.
Fixed
2e2bde7
to
25cc026
Compare
@@ -0,0 +1,15 @@ | |||
# Copyright 2020 Intel Corporation |
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.
Please move db_helper to examples/common/python.
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.
This helper module is assisting on the connector components(direct & proxy). Hence I have made it a module common to only both the type of connectors.
logger = logging.getLogger(__name__) | ||
|
||
|
||
class WorkOrderLmdbHelper: |
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.
WorkOrderLmdbHelper -> WorkOrderKVHelper
work_order_lmdb_helper.py -> work_order_kv_helper.py
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.
For all the name changes - I have deliberately named them as lmdb helper as I expect similar layers for other kind of databases that would handle the low level database calls.
# --------------------------------------------------------------------------------------------- | ||
def submit_wo(self, wo_id, input_json_str): | ||
""" | ||
Function to submit a new work-order |
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.
Function to submit and store a new work-order to db
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.
Fixed
""" | ||
Function to perform init activity | ||
Parameters: | ||
- kv_helper is a object of lmdb database |
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.
kv_helper is a object of shared kv database
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.
Fixed
# --------------------------------------------------------------------------------------------- | ||
def get_wo_result(self, wo_id): | ||
""" | ||
Function to get work-order result from lmdb |
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.
Function to get work-order result from shared kv database
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.
Fixed
logger = logging.getLogger(__name__) | ||
|
||
|
||
class WorkerEncryptionKeyLmdbHelper: |
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.
WorkerEncryptionKeyLmdbHelper -> WorkerEncryptionKeyDbHelper
""" | ||
WorkerEncryptionKeyDBHelper helps listener or other client | ||
facing modules to interact with the kv storage for queries | ||
related to encryption key. It implements all low level db |
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 don't see any encryption key being passed as query parameter in below functions ?
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.
This is a place holder module where functions can be added later on. This module would also abstract any database helper calls from the module above.
logger = logging.getLogger(__name__) | ||
|
||
|
||
class WorkerRegistryLmdbHelper: |
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.
WorkerRegistryLmdbHelper -> WorkerRegistryDbHelper
logger = logging.getLogger(__name__) | ||
|
||
|
||
class WorkOrderReceiptLmdbHelper: |
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.
WorkOrderReceiptLmdbHelper -> WorkOrderReceiptDbHelper
@@ -1,4 +1,4 @@ | |||
# Copyright 2019 Intel Corporation | |||
# Copyright 2020 Intel Corporation |
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.
This file was created in 2019 I think. So no need to change the copyright
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.
Makes sense. Updated.
25cc026
to
094abae
Compare
|
||
def clear_a_processed_wo(self): | ||
""" | ||
Function that clears one processed work-order from |
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.
Update the comment that it will remove the least recently added entry from processed table.
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.
Done
@@ -0,0 +1,164 @@ | |||
# Copyright 2020 Intel Corporation |
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.
Where should we move this db helper modules? In common/python/database module?
094abae
to
f02efdd
Compare
f02efdd
to
40c2959
Compare
Abstract out calls using database/table names in handlers for direct mode listener. The segregated layer may contain some logic if it has to deal only with lower/database calls for it. Hence abstracting some deatils from the layer above. This thin layer can also be used in the Proxy mode of operations. Signed-off-by: Rajeev Ranjan <rajeev2.ranjan@intel.com>
40c2959
to
a372793
Compare
Abstract out calls using database/table names in handlers for direct
mode listener. The segregated layer may contain some logic if it has
to deal only with lower/database calls for it. Hence abstracting some
deatils from the layer above. This thin layer can also be used in the
Proxy mode of operations.
Signed-off-by: Rajeev Ranjan rajeev2.ranjan@intel.com