package resolution import ( mcat "git.novox.be/novox/mesh-sdk/go/catalogue" ) // healthInto composes a resource's `health` into the node-engine's words, or takes it away (to-be 48 §2, // §3): for an engine that reads it, the endpoint becomes the port this machine published it on and the // defaults are written out; for one that does not — older and strict — the field is not sent, and the // resource is judged by liveness alone, as before. func healthInto(resource map[string]any, m mcat.Manifest, with mcat.Rendering) { if _, has := resource[mcat.HealthField]; !has { return } if !with.ReadsHealth { delete(resource, mcat.HealthField) return } h, _, _ := mcat.ReadHealth(resource) out := map[string]any{"kind": h.Kind, "interval": h.Interval.String(), "timeout": h.Timeout.String(), "looks": h.Looks, "grace": h.Grace.String()} if h.Endpoint != "" { out["endpoint"] = h.Endpoint if port, ok := mcat.EndpointPort(m, h.Endpoint); ok { out["port"] = renderingMachinePort(with, m.Module, port) } } if h.Kind == mcat.HealthHTTP { path := h.Path if path == "" { path = "/" } out["path"] = path if h.Status != 0 { out["status"] = h.Status } if h.Body != "" { out["body"] = h.Body } if h.Scheme != "" { out["scheme"] = h.Scheme } } if h.Command != "" { out["command"] = h.Command } if h.Tool != "" { out["tool"] = h.Tool } if h.Needs != "" { out["needs"] = h.Needs } resource[mcat.HealthField] = out }