MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / DeleteMonitor

Method DeleteMonitor

balance.go:463–483  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

461// Returns:
462// - error: An error if the monitor could not be deleted.
463func (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,

Callers 1

TestDeleteMonitorFunction · 0.95

Calls 4

GetMonitorByIDMethod · 0.65
DeleteMonitorMethod · 0.65
DeleteMethod · 0.65
StartMethod · 0.45

Tested by 1

TestDeleteMonitorFunction · 0.76