MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / Dispatch

Method Dispatch

app/controlplane/pkg/auditor/dispatcher.go:64–80  ·  view source on GitHub ↗

Dispatch generates the audit event from entry and the given options and publishes it. Best-effort: failures are logged and reported to Sentry, never returned, so they can't fail or slow down the caller. A disabled dispatcher is a no-op.

(entry LogEntry, opts ...GeneratorOption)

Source from the content-addressed store, hash-verified

62// returned, so they can't fail or slow down the caller. A disabled dispatcher
63// is a no-op.
64func (d *Dispatcher) Dispatch(entry LogEntry, opts ...GeneratorOption) {
65 if !d.Enabled() {
66 return
67 }
68
69 payload, err := GenerateAuditEvent(entry, opts...)
70 if err != nil {
71 d.log.Errorw("msg", "failed to generate audit event", "error", err)
72 sentry.CaptureException(fmt.Errorf("failed to generate audit event: %w", err))
73 return
74 }
75
76 if err := d.publisher.Publish(payload); err != nil {
77 d.log.Errorw("msg", "failed to publish audit event", "error", err)
78 sentry.CaptureException(fmt.Errorf("failed to publish audit event: %w", err))
79 }
80}

Callers 2

TestDispatcherDispatchFunction · 0.95

Calls 4

EnabledMethod · 0.95
GenerateAuditEventFunction · 0.85
ErrorwMethod · 0.65
PublishMethod · 0.65

Tested by 2

TestDispatcherDispatchFunction · 0.76