MCPcopy Index your code
hub / github.com/PatchMon/PatchMon / resolveDBFromPayload

Function resolveDBFromPayload

server-source-code/internal/queue/workers.go:34–46  ·  view source on GitHub ↗

resolveDBFromPayload returns the DB to use: from poolCache when host is in payload, else defaultDB.

(ctx context.Context, payload []byte, defaultDB *database.DB, poolCache *hostctx.PoolCache)

Source from the content-addressed store, hash-verified

32
33// resolveDBFromPayload returns the DB to use: from poolCache when host is in payload, else defaultDB.
34func resolveDBFromPayload(ctx context.Context, payload []byte, defaultDB *database.DB, poolCache *hostctx.PoolCache) *database.DB {
35 db := defaultDB
36 if len(payload) == 0 || poolCache == nil {
37 return db
38 }
39 var p AutomationPayload
40 if err := json.Unmarshal(payload, &p); err == nil && strings.TrimSpace(p.Host) != "" {
41 if resolved, err := poolCache.GetOrCreate(ctx, p.Host); err == nil && resolved != nil {
42 db = resolved
43 }
44 }
45 return db
46}
47
48// workerTenantKey prefixes a Redis key with the context domain for multi-context isolation.
49// Mirrors hostctx.TenantKey but works in worker context where only the host string

Callers 14

ProcessTaskMethod · 0.85
ProcessTaskMethod · 0.85
ProcessTaskMethod · 0.85
ProcessTaskMethod · 0.85
ProcessTaskMethod · 0.85
ProcessTaskMethod · 0.85
ProcessTaskMethod · 0.85
ProcessTaskMethod · 0.85
ProcessTaskMethod · 0.85
ProcessTaskMethod · 0.85
ProcessTaskMethod · 0.85
ProcessTaskMethod · 0.85

Calls 2

UnmarshalMethod · 0.80
GetOrCreateMethod · 0.45

Tested by

no test coverage detected