UpdateMonitor updates an existing balance monitor. It starts a tracing span, updates the monitor, and records relevant events and errors. Parameters: - ctx context.Context: The context for the operation. - monitor *model.BalanceMonitor: A pointer to the BalanceMonitor model to be updated. Returns:
(ctx context.Context, monitor *model.BalanceMonitor)
| 436 | // Returns: |
| 437 | // - error: An error if the monitor could not be updated. |
| 438 | func (l *LedgerForge) UpdateMonitor(ctx context.Context, monitor *model.BalanceMonitor) error { |
| 439 | _, span := balanceTracer.Start(ctx, "UpdateMonitor") |
| 440 | defer span.End() |
| 441 | |
| 442 | err := l.datasource.UpdateMonitor(monitor) |
| 443 | if err != nil { |
| 444 | span.RecordError(err) |
| 445 | return err |
| 446 | } |
| 447 | |
| 448 | _ = l.cache.Delete(ctx, "monitors:"+monitor.BalanceID) |
| 449 | |
| 450 | span.AddEvent("Monitor updated", trace.WithAttributes(attribute.String("monitor.id", monitor.MonitorID))) |
| 451 | return nil |
| 452 | } |
| 453 | |
| 454 | // DeleteMonitor deletes a balance monitor by its ID. |
| 455 | // It starts a tracing span, deletes the monitor, and records relevant events and errors. |