Documentation ¶
Index ¶
Constants ¶
const ( // DefaultMaxRetries is the default number of retries for a request. DefaultMaxRetries int = 5 // DefaultBackoff is the default backoff time for a request. DefaultBackoff time.Duration = 150 * time.Millisecond )
const ( ContentTypeJSON = "application/json" ContentTypeJSONAlternative = "application/vnd.api+json" ContentTypeOctetStream = "application/octet-stream" ContentTypeMessagePack = "application/msgpack" ContentEncodingGzip = "gzip" HeaderContentType = "Content-Type" HeaderContentEncoding = "Content-Encoding" HeaderAcceptEncoding = "Accept-Encoding" HeaderRateLimitReset = "x-ratelimit-reset" HTTPStatusTooManyRequests = 429 FormatJSON = "json" FormatMessagePack = "msgpack" )
Constants for common strings
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { GetSettings() (*SettingsResponseData, error) GetEarlyFlakeDetectionData() (*EfdResponseData, error) GetCommits(localCommits []string) ([]string, error) SendPackFiles(commitSha string, packFiles []string) (bytes int64, err error) SendCoveragePayload(ciTestCovPayload io.Reader) error GetSkippableTests() (correlationID string, skippables map[string]map[string][]SkippableResponseDataAttributes, err error) }
Client is an interface for sending requests to the Datadog backend.
func NewClient ¶
func NewClient() Client
NewClient creates a new client with the default service name.
func NewClientForCodeCoverage ¶ added in v1.70.0
func NewClientForCodeCoverage() Client
NewClientForCodeCoverage creates a new client for sending code coverage payloads.
func NewClientWithServiceName ¶
NewClientWithServiceName creates a new client with the given service name.
func NewClientWithServiceNameAndSubdomain ¶ added in v1.70.0
NewClientWithServiceNameAndSubdomain creates a new client with the given service name and subdomain.
type EfdRequestData ¶
type EfdResponseData ¶
type EfdResponseData struct {
Tests EfdResponseDataModules `json:"tests"`
}
type EfdResponseDataModules ¶
type EfdResponseDataModules map[string]EfdResponseDataSuites
type EfdResponseDataSuites ¶
type FormFile ¶
type FormFile struct { FieldName string // The name of the form field FileName string // The name of the file Content interface{} // The content of the file (can be []byte, map, struct, etc.) ContentType string // The MIME type of the file (e.g., "application/json", "application/octet-stream") }
FormFile represents a file to be uploaded in a multipart form request.
type RequestConfig ¶
type RequestConfig struct { Method string // HTTP method: GET or POST URL string // Request URL Headers map[string]string // Additional HTTP headers Body interface{} // Request body for JSON, MessagePack, or raw bytes Format string // Format: "json" or "msgpack" Compressed bool // Whether to use gzip compression Files []FormFile // Files to be uploaded in a multipart form data request MaxRetries int // Maximum number of retries Backoff time.Duration // Initial backoff duration for retries }
RequestConfig holds configuration for a request.
type RequestHandler ¶
RequestHandler handles HTTP requests with retries and different formats.
func NewRequestHandler ¶
func NewRequestHandler() *RequestHandler
NewRequestHandler creates a new RequestHandler with a default HTTP client.
func NewRequestHandlerWithClient ¶
func NewRequestHandlerWithClient(client *http.Client) *RequestHandler
NewRequestHandlerWithClient creates a new RequestHandler with a custom http.Client
func (*RequestHandler) SendRequest ¶
func (rh *RequestHandler) SendRequest(config RequestConfig) (*Response, error)
SendRequest sends an HTTP request based on the provided configuration.
type Response ¶
type Response struct { Body []byte // Response body in raw format Format string // Format of the response (json or msgpack) StatusCode int // HTTP status code CanUnmarshal bool // Whether the response body can be unmarshalled Compressed bool // Whether to use gzip compression }
Response represents the HTTP response with deserialization capabilities and status code.
type SettingsRequestData ¶
type SettingsRequestData struct { Service string `json:"service,omitempty"` Env string `json:"env,omitempty"` RepositoryURL string `json:"repository_url,omitempty"` Branch string `json:"branch,omitempty"` Sha string `json:"sha,omitempty"` Configurations testConfigurations `json:"configurations,omitempty"` }
type SettingsResponseData ¶
type SettingsResponseData struct { CodeCoverage bool `json:"code_coverage"` EarlyFlakeDetection struct { Enabled bool `json:"enabled"` SlowTestRetries struct { TenS int `json:"10s"` ThirtyS int `json:"30s"` FiveM int `json:"5m"` FiveS int `json:"5s"` } `json:"slow_test_retries"` FaultySessionThreshold int `json:"faulty_session_threshold"` } `json:"early_flake_detection"` FlakyTestRetriesEnabled bool `json:"flaky_test_retries_enabled"` ItrEnabled bool `json:"itr_enabled"` RequireGit bool `json:"require_git"` TestsSkipping bool `json:"tests_skipping"` }