Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

1.0 KB
Raw Blame
package actionlifecycle

import (
	"context"

	unified "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"
)

type dispatchAttemptContextKey struct{}

func withDispatchAttempt(ctx context.Context, attempt unified.ActionDispatchAttempt) context.Context {
	return context.WithValue(ctx, dispatchAttemptContextKey{}, attempt)
}

// ContextWithCommittedDispatchAttempt is exposed for executor conformance
// tests and transport adapters. Production callers must obtain attempt from a
// successful lifecycle-store admission before using it.
func ContextWithCommittedDispatchAttempt(ctx context.Context, attempt unified.ActionDispatchAttempt) context.Context {
	return withDispatchAttempt(ctx, attempt)
}

// DispatchAttemptFromContext returns the committed transport authority for an
// executor call. Executors must use its ID as the transport request identity.
func DispatchAttemptFromContext(ctx context.Context) (unified.ActionDispatchAttempt, bool) {
	attempt, ok := ctx.Value(dispatchAttemptContextKey{}).(unified.ActionDispatchAttempt)
	return attempt, ok
}