| 361 | } |
| 362 | |
| 363 | func (i *imlStrategyModule) initGateway(ctx context.Context, clusterId string, clientDriver gateway.IClientDriver) error { |
| 364 | commits, err := i.strategyService.ListLatestStrategyCommit(ctx, strategy_dto.ScopeGlobal, "") |
| 365 | if err != nil { |
| 366 | return err |
| 367 | } |
| 368 | publishStrategies := make([]*eosc.Base[gateway.StrategyRelease], 0, len(commits)) |
| 369 | for _, c := range commits { |
| 370 | l := c.Data |
| 371 | if l.IsDelete { |
| 372 | err = i.strategyService.Delete(ctx, l.Id) |
| 373 | if err != nil { |
| 374 | return err |
| 375 | } |
| 376 | } |
| 377 | d, has := strategy_driver.GetDriver(l.Driver) |
| 378 | if !has { |
| 379 | continue |
| 380 | } |
| 381 | publishStrategies = append(publishStrategies, d.ToRelease(strategy_dto.ToStrategy(&strategy.Strategy{ |
| 382 | Id: l.Id, |
| 383 | Name: l.Name, |
| 384 | Priority: l.Priority, |
| 385 | Filters: l.Filters, |
| 386 | Config: l.Config, |
| 387 | Driver: l.Driver, |
| 388 | IsStop: l.IsStop, |
| 389 | IsDelete: l.IsDelete, |
| 390 | }), nil, 5000)) |
| 391 | } |
| 392 | |
| 393 | return clientDriver.Strategy().Online(ctx, publishStrategies...) |
| 394 | } |