package buildrun import ( "strings" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" ) // The words of a key that failed on a transport fault (design 47 G §568, A-76): `transport fault: , , // `, the class one of ADR 0664 §1's four, the seat and node the step's, the cause the last run's in the build // module's words. No other failure opens `transport fault:`. // TransportFaultPrefix opens the error of a key that failed on a transport fault. const TransportFaultPrefix = builds.TransportFaultPrefix // The classes of a transport fault. const ( ClassNoResponders = "no responders" ClassNameLookup = "name lookup" ClassConnection = "connection" ClassDeadline = "deadline" ) // FaultClass is the class of a call's error or a step's reason: the words the builder's retake reads a transport fault by // (buildstep.PassingCause), read as no responders, a name lookup, a deadline or, for every other refused, reset or cut // connection, a connection. func FaultClass(cause string) string { c := strings.ToLower(cause) has := func(words ...string) bool { for _, w := range words { if strings.Contains(c, w) { return true } } return false } switch { case has("no responders", strings.ToLower(buildstep.HolderSilentWords), "jetstream not enabled"): return ClassNoResponders case has("no such host", "name resolution", "lookup ", "could not resolve", "enotfound", "eai_again"): return ClassNameLookup case has("deadline", "timeout", "timed out", "etimedout"): return ClassDeadline } return ClassConnection } // TransportFault is the error of a key that failed on a transport fault of the seat's step on node, with the cause of its // last run. func TransportFault(class, seat, node, cause string) string { return TransportFaultPrefix + " " + class + ", " + seat + " " + node + ", " + cause }