DeleteMonitor deletes a balance monitor by its ID. It starts a tracing span, deletes the monitor, and records relevant events and errors. Parameters: - ctx context.Context: The context for the operation. - id string: The ID of the monitor to delete. Returns: - error: An error if the monitor could
(ctx context.Context, id string)
| 461 | // Returns: |
| 462 | // - error: An error if the monitor could not be deleted. |
| 463 | func (l *LedgerForge) DeleteMonitor(ctx context.Context, id string) error { |
| 464 | _, span := balanceTracer.Start(ctx, "DeleteMonitor") |
| 465 | defer span.End() |
| 466 | |
| 467 | monitor, err := l.datasource.GetMonitorByID(id) |
| 468 | if err != nil { |
| 469 | span.RecordError(err) |
| 470 | return err |
| 471 | } |
| 472 | |
| 473 | err = l.datasource.DeleteMonitor(id) |
| 474 | if err != nil { |
| 475 | span.RecordError(err) |
| 476 | return err |
| 477 | } |
| 478 | |
| 479 | _ = l.cache.Delete(ctx, "monitors:"+monitor.BalanceID) |
| 480 | |
| 481 | span.AddEvent("Monitor deleted", trace.WithAttributes(attribute.String("monitor.id", id))) |
| 482 | return nil |
| 483 | } |
| 484 | |
| 485 | // TakeBalanceSnapshots creates daily snapshots of balances in batches. |
| 486 | // It accepts a batch size parameter to control the number of balances processed at once, |