Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[update] modify the RefreshAgents interface to use batch operations; #922

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zfchai
Copy link
Contributor

@zfchai zfchai commented Mar 7, 2025

  • Add batch method
  1. BulkInsertAgentsAsync
  2. BulkInsertUserAgentsAsync
  3. DeleteAgentsAsync
  4. DeleteAgentsAsync(List agentIds)
  5. BulkInsertAgentTasksAsync
  • Update method
  1. RefreshAgents

@Oceania2018 Oceania2018 requested a review from iceljc March 8, 2025 00:51
}
catch (Exception ex)
{
_logger.LogError($"Failed to migrate agent in file directory: {dir}\r\nError: {ex.Message}");
}
}

if (!refreshedAgents.IsNullOrEmpty())
if (agents.Count > 0)
Copy link
Member

Choose a reason for hiding this comment

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

Please ensure that when performing batch operations, the data operations are carried out within a single transaction in MongoDB to prevent other agents from failing to insert when one agent insertion encounters an exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • IsNullOrEmpty is a built-in extension method.
  • Okay, batch operations can adjust transaction support.

Copy link
Contributor Author

@zfchai zfchai Mar 12, 2025

Choose a reason for hiding this comment

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

The IBotSharpRepository currently does not provide transaction session objects.
If you consider multiple database support, this session object may not be compatible.

@Oceania2018
Copy link
Member

Thanks for you contribution!
For this change in batch operations, we intentionally made it so that each agent is deleted and inserted on individually to reduce the impact on the production system. If batch operations must be used, please ensure the transactional integrity of the database operations.

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.

2 participants