Documentation
¶
Index ¶
- Constants
- Variables
- func Base64ToJWK(privateKey string) (jwk jose.JSONWebKey, err error)
- func CreateTimeoutContext(ctx context.Context, timeoutSeconds *int32) (context.Context, context.CancelFunc)
- func EcdsaToJWK(key any) (*jose.JSONWebKey, error)
- func GenerateKeys() (*jose.JSONWebKey, *jose.JSONWebKey, error)
- func GeneratePARJWT(orgId int64, runnerId string, privateKey *ecdsa.PrivateKey, ...) (string, error)
- func HandleTimeoutError(ctx context.Context, err error, timeoutSeconds *int32, logger log.Logger) (bool, error)
- func JWKToPEM(pubJWK *jose.JSONWebKey) (string, error)
- func MakeRunnerURN(region string, orgID int64, runnerID string) string
- func ParseResponseBody(contentType string, data []byte, responseParsing string, ...) (interface{}, error)
- func RetryHTTPRequest[T any](ctx context.Context, op func() (T, int, error), opts RetryHTTPOptions) (T, error)
- func ValidateAPIKey(key string) (bool, error)
- func ValidateAppKey(key string) (bool, error)
- type CircuitBreaker
- type FormDataField
- type PARError
- func DefaultActionError(e error) PARError
- func DefaultActionErrorWithDisplayError(e error, displayError string) PARError
- func DefaultPARError(e error) PARError
- func NewPARError(code aperrorpb.ActionPlatformErrorCode, e error) PARError
- func NewPARErrorWithDisplayError(code aperrorpb.ActionPlatformErrorCode, e error, displayError string) PARError
- type RetryHTTPOptions
- type RunnerURNParts
Constants ¶
const ( Raw string = "raw" JSON string = "json" FormData string = "form-data" FormURLEncoded string = "form-urlencoded" )
Variables ¶
var CharsetAliases = map[string]string{
"iso-8859-1": "latin1",
"iso88591": "latin1",
"iso8859-1": "latin1",
}
var Encoding = []string{"ascii", "utf8", "utf-8", "utf16le", "ucs2", "ucs-2", "base64", "base64url", "latin1", "binary", "hex"}
Functions ¶
func Base64ToJWK ¶
func Base64ToJWK(privateKey string) (jwk jose.JSONWebKey, err error)
func CreateTimeoutContext ¶
func CreateTimeoutContext(ctx context.Context, timeoutSeconds *int32) (context.Context, context.CancelFunc)
CreateTimeoutContext creates a context with timeout if timeoutSeconds is provided and greater than 0. Otherwise, it returns the original context with a no-op cancel function.
func EcdsaToJWK ¶
func EcdsaToJWK(key any) (*jose.JSONWebKey, error)
func GenerateKeys ¶
func GenerateKeys() (*jose.JSONWebKey, *jose.JSONWebKey, error)
func GeneratePARJWT ¶
func HandleTimeoutError ¶
func HandleTimeoutError(ctx context.Context, err error, timeoutSeconds *int32, logger log.Logger) (bool, error)
HandleTimeoutError checks if an error occurred due to context deadline exceeded, logs a warning if so, and returns whether a timeout occurred along with a formatted error message. This is used by both AppBuilderRunner and WorkflowRunner to handle task timeouts consistently.
func JWKToPEM ¶
func JWKToPEM(pubJWK *jose.JSONWebKey) (string, error)
JWKToPEM converts a JWK public key to PEM format
func ParseResponseBody ¶
func RetryHTTPRequest ¶
func RetryHTTPRequest[T any](ctx context.Context, op func() (T, int, error), opts RetryHTTPOptions) (T, error)
RetryHTTPRequest runs op with exponential backoff. op returns (result, statusCode, err); statusCode should be 0 for transport-level errors where no HTTP response was received.
4xx responses are treated as permanent (no retry) since they typically indicate a non-transient client problem (bad credentials, malformed payload). Transport errors and 5xx responses are retried.
func ValidateAPIKey ¶
ValidateAPIKey checks whether key is a well-formed Datadog API key
func ValidateAppKey ¶
ValidateAppKey checks whether key is a well-formed Datadog application key.
Types ¶
type CircuitBreaker ¶
type CircuitBreaker struct {
// contains filtered or unexported fields
}
CircuitBreaker is a rudimentary circuit breaker that performs retries using exponential backoff.
func NewCircuitBreaker ¶
func NewCircuitBreaker(name string, minBackoff, maxBackoff, waitBeforeRetry time.Duration, maxAttempts int32) *CircuitBreaker
type FormDataField ¶
type PARError ¶
type PARError struct {
*aperrorpb.ActionPlatformError
}
func DefaultActionError ¶
DefaultActionError generates the default PAR action error with a default action error code.
func DefaultActionErrorWithDisplayError ¶
DefaultActionErrorWithDisplayError generates the default PAR action error with a default action error code and display error.
func DefaultPARError ¶
DefaultPARError generates the default PAR error with a default error code, and default internal error message.
func NewPARError ¶
func NewPARError(code aperrorpb.ActionPlatformErrorCode, e error) PARError
NewPARError creates a general PAR error with default config.
func NewPARErrorWithDisplayError ¶
func NewPARErrorWithDisplayError(code aperrorpb.ActionPlatformErrorCode, e error, displayError string) PARError
NewPARErrorWithDisplayError creates a general PAR error with display error.
type RetryHTTPOptions ¶
type RetryHTTPOptions struct {
InitialInterval time.Duration
MaxInterval time.Duration
MaxElapsedTime time.Duration
}
RetryHTTPOptions controls the retry policy for RetryHTTPRequest.
MaxElapsedTime == 0 disables the elapsed-time cap, meaning retries continue until the request succeeds, hits a permanent failure (4xx), or the caller's context is cancelled.
type RunnerURNParts ¶
func ParseRunnerURN ¶
func ParseRunnerURN(urn string) (RunnerURNParts, error)