utils
import "github.com/open-outbox/relay/internal/utils"Package utils provides shared helper functions and common logic used across the Open Outbox Relay, including logging decorators and error handling utilities.
- func LoadBytes(input string) ([]byte, error)
- func LogIfError(logger *zap.Logger, err error, msg string, fields …zap.Field)
func LoadBytes
Section titled “func LoadBytes”func LoadBytes(input string) ([]byte, error)LoadBytes converts a configuration string into raw bytes. It supports: - Explicit file paths prefixed with “file://” (e.g., “file:///etc/certs/ca.crt”) - Explicit Base64 encoded data prefixed with “base64://” (e.g., “base64://TUlJQk…”) - Inline, un-prefixed raw PEM text blocks - Plain un-prefixed text fallback (treated as raw bytes)
func LogIfError
Section titled “func LogIfError”func LogIfError(logger *zap.Logger, err error, msg string, fields ...zap.Field)LogIfError writes a log entry at the Error level only if the provided error is non-nil and does not represent a normal context cancellation.
This is typically used to handle background process errors where context.Canceled is an expected signal during shutdown rather than a failure.