Multi-tenant Changes for Precooking/Recooking Status.#187
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates Cassandra-backed “recooking status” access to support multi-tenant/sharded data, and adjusts test/schema setup to better match how change-events are written asynchronously.
Changes:
- Add
tenantId(andshard_id) to recooking-status read/write queries and expand theDatabaseClientinterface accordingly. - Update unit test logic for cache change events to be resilient when more than one change event exists.
- Add an
updatedtimestamp column to the unit-test Cassandra schema forchange_events.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tests/cached_simple_dao_test.go | Makes cache-change-event assertions more flexible for async/multi-event scenarios. |
| db/setup_teardown_db.go | Updates test table schema for change_events to include updated timestamp. |
| db/recooking_status_client.go | Adds tenant/shard-aware queries for recooking status and introduces a new details query. |
| db/database_client.go | Updates the DB interface signatures to include tenant context and adds a details method. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| stmt := fmt.Sprintf(`SELECT %s, %s FROM "%s" WHERE %s = ? AND %s = ? AND %s = ? AND %s = ? LIMIT 1`, XcrpStateColumnName, XcrpUpdatedTimeColumnName, c.xconfRecookingStatusTableName, TenantIdColumnName, XcrpShardIdColumnName, XcrpModuleNameColumnName, XcrpPartionIdColumnName) | ||
| query := c.Query(stmt, tenantId, shardId, moduleName, partitionId) |
| // need to wait since changed record is written async | ||
| time.Sleep(1 * time.Second) | ||
| time.Sleep(2 * time.Second) |
There was a problem hiding this comment.
Changed to older value.
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
pt-nguyen
left a comment
There was a problem hiding this comment.
Please review comments
| */ | ||
|
|
||
| stmt := fmt.Sprintf(`SELECT %s, %s FROM "%s" WHERE %s = ? AND %s = ? AND %s = ? AND %s = ? LIMIT 1`, XcrpStateColumnName, XcrpUpdatedTimeColumnName, c.xconfRecookingStatusTableName, TenantIdColumnName, XcrpShardIdColumnName, XcrpModuleNameColumnName, XcrpPartionIdColumnName) | ||
| query := c.Query(stmt, tenantId, shardId, moduleName, partitionId) |
There was a problem hiding this comment.
Please update xconf_recooking_status_table_name in config/sample_xconfwebconfig.conf to use the new table recooking_status
Please see comment from Copilot.
| stmt := fmt.Sprintf(`SELECT %s, %s FROM "%s" WHERE %s = ? AND %s = ? LIMIT 1`, XcrpStateColumnName, XcrpUpdatedTimeColumnName, c.xconfRecookingStatusTableName, XcrpModuleNameColumnName, XcrpPartionIdColumnName) | ||
| query := c.Query(stmt, moduleName, partitionId) | ||
| */ | ||
|
|
There was a problem hiding this comment.
Please see suggestion from copilot
|
|
||
| stmt := fmt.Sprintf(`SELECT %s, %s, %s, %s FROM "%s" WHERE %s = ? AND %s IN ?`, | ||
| XcrpAppNameColumnName, XcrpPartionIdColumnName, XcrpStateColumnName, XcrpUpdatedTimeColumnName, XcrpRecookingStatusTableName, TenantIdColumnName, XcrpShardIdColumnName) | ||
| query := c.Session.Query(stmt, tenantId, GetShardIds()) |
There was a problem hiding this comment.
For line 123, instead of calling GetShardIds(), we can just use predefined variable shardIds that is initialized in cassandra_client.go file
There was a problem hiding this comment.
Thanks @pt-nguyen , I have Addressed it.
No description provided.