(ctx context.Context, driver string, scope string, target string)
| 313 | } |
| 314 | |
| 315 | func (i *imlStrategyModule) Publish(ctx context.Context, driver string, scope string, target string) error { |
| 316 | d, has := strategy_driver.GetDriver(driver) |
| 317 | if !has { |
| 318 | return fmt.Errorf("driver not found: %s", driver) |
| 319 | } |
| 320 | list, err := i.strategyService.AllByDriver(ctx, driver, strategy_dto.ToScope(scope).Int(), target) |
| 321 | if err != nil { |
| 322 | return err |
| 323 | } |
| 324 | |
| 325 | return i.transaction.Transaction(ctx, func(txCtx context.Context) error { |
| 326 | publishStrategies := make([]*eosc.Base[gateway.StrategyRelease], 0, len(list)) |
| 327 | for _, l := range list { |
| 328 | if l.IsDelete { |
| 329 | err = i.strategyService.Delete(ctx, l.Id) |
| 330 | if err != nil { |
| 331 | return err |
| 332 | } |
| 333 | } |
| 334 | publishStrategies = append(publishStrategies, d.ToRelease(strategy_dto.ToStrategy(l), nil, 5000)) |
| 335 | |
| 336 | err = i.strategyService.CommitStrategy(txCtx, scope, target, l.Id, l) |
| 337 | if err != nil { |
| 338 | return err |
| 339 | } |
| 340 | } |
| 341 | client, err := i.clusterService.GatewayClient(ctx, cluster.DefaultClusterID) |
| 342 | if err != nil { |
| 343 | return err |
| 344 | } |
| 345 | defer func() { |
| 346 | _ = client.Close(ctx) |
| 347 | }() |
| 348 | return client.Strategy().Online(ctx, publishStrategies...) |
| 349 | }) |
| 350 | } |
| 351 | |
| 352 | func (i *imlStrategyModule) Delete(ctx context.Context, id string) error { |
| 353 | _, err := i.strategyService.LatestStrategyCommit(ctx, strategy_dto.ScopeGlobal, "", id) |
nothing calls this directly
no test coverage detected