Merge workers into API

This commit is contained in:
2025-08-16 04:55:33 +07:00
parent 9841219e8b
commit d2975be0f5
22 changed files with 340 additions and 346 deletions

View File

@@ -97,11 +97,11 @@ public class LiveTradingBotGrain : Grain, ILiveTradingBotGrain, IRemindable
if (botStatus == BotStatus.Running && _tradingBot == null)
{
// Now, we can proceed with resuming the bot.
await ResumeBotInternalAsync();
await ResumeBotInternalAsync(botStatus);
}
}
private async Task ResumeBotInternalAsync()
private async Task ResumeBotInternalAsync(BotStatus previousStatus)
{
// Idempotency check
if (_tradingBot != null)
@@ -113,7 +113,7 @@ public class LiveTradingBotGrain : Grain, ILiveTradingBotGrain, IRemindable
{
// Create and initialize trading bot instance
_tradingBot = CreateTradingBotInstance(_state.State.Config);
await _tradingBot.Start();
await _tradingBot.Start(previousStatus);
// Set startup time when bot actually starts running
_state.State.StartupTime = DateTime.UtcNow;
@@ -155,7 +155,7 @@ public class LiveTradingBotGrain : Grain, ILiveTradingBotGrain, IRemindable
try
{
// Resume the bot - this handles registry status update internally
await ResumeBotInternalAsync();
await ResumeBotInternalAsync(status);
_logger.LogInformation("LiveTradingBotGrain {GrainId} started successfully", this.GetPrimaryKey());
}
catch (Exception ex)