Skip to content

Multi-tenant Changes for Precooking/Recooking Status.#187

Open
gravi21 wants to merge 1 commit into
develop-multi-tenantfrom
gopi_develop-multi-tenant
Open

Multi-tenant Changes for Precooking/Recooking Status.#187
gravi21 wants to merge 1 commit into
develop-multi-tenantfrom
gopi_develop-multi-tenant

Conversation

@gravi21

@gravi21 gravi21 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (and shard_id) to recooking-status read/write queries and expand the DatabaseClient interface accordingly.
  • Update unit test logic for cache change events to be resilient when more than one change event exists.
  • Add an updated timestamp column to the unit-test Cassandra schema for change_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.

Comment thread db/recooking_status_client.go
Comment thread db/recooking_status_client.go
Comment on lines +45 to +46
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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed.

Comment on lines 371 to +372
// need to wait since changed record is written async
time.Sleep(1 * time.Second)
time.Sleep(2 * time.Second)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to older value.

@github-advanced-security

Copy link
Copy Markdown

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:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@pt-nguyen pt-nguyen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update xconf_recooking_status_table_name in config/sample_xconfwebconfig.conf to use the new table recooking_status

Please see comment from Copilot.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed.

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)
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see suggestion from copilot

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed.


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())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For line 123, instead of calling GetShardIds(), we can just use predefined variable shardIds that is initialized in cassandra_client.go file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pt-nguyen , I have Addressed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants