Documentation
¶
Index ¶
- Constants
- type Client
- type FormFile
- type KnownTestsRequestData
- type KnownTestsResponseData
- type KnownTestsResponseDataModules
- type KnownTestsResponseDataSuites
- type RequestConfig
- type RequestHandler
- type Response
- type SettingsRequestData
- type SettingsResponseData
- type SkippableResponseDataAttributes
- type TestManagementTestsResponseDataModules
- type TestManagementTestsResponseDataSuites
- type TestManagementTestsResponseDataTestProperties
- type TestManagementTestsResponseDataTestPropertiesAttributes
- type TestManagementTestsResponseDataTests
Constants ¶
const ( // DefaultMaxRetries is the default number of retries for a request. DefaultMaxRetries int = 3 // DefaultBackoff is the default backoff time for a request. DefaultBackoff time.Duration = 100 * 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)
GetKnownTests() (*KnownTestsResponseData, error)
GetCommits(localCommits []string) ([]string, error)
SendPackFiles(commitSha string, packFiles []string) (bytes int64, err error)
SendCoveragePayload(ciTestCovPayload io.Reader) error
SendCoveragePayloadWithFormat(ciTestCovPayload io.Reader, format string) error
GetSkippableTests() (correlationID string, skippables map[string]map[string][]SkippableResponseDataAttributes, err error)
GetTestManagementTests() (*TestManagementTestsResponseDataModules, error)
SendLogs(logsPayload io.Reader) 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 ¶
func NewClientForCodeCoverage() Client
NewClientForCodeCoverage creates a new client for sending code coverage payloads.
func NewClientForLogs ¶
func NewClientForLogs() Client
NewClientForLogs creates a new client for sending logs payloads.
func NewClientWithServiceName ¶
NewClientWithServiceName creates a new client with the given service name.
func NewClientWithServiceNameAndSubdomain ¶
NewClientWithServiceNameAndSubdomain creates a new client with the given service name and subdomain.
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 KnownTestsRequestData ¶
type KnownTestsResponseData ¶
type KnownTestsResponseData struct {
Tests KnownTestsResponseDataModules `json:"tests"`
}
type KnownTestsResponseDataModules ¶
type KnownTestsResponseDataModules map[string]KnownTestsResponseDataSuites
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"`
KnownTestsEnabled bool `json:"known_tests_enabled"`
ImpactedTestsEnabled bool `json:"impacted_tests_enabled"`
TestManagement struct {
Enabled bool `json:"enabled"`
AttemptToFixRetries int `json:"attempt_to_fix_retries"`
} `json:"test_management"`
}
type TestManagementTestsResponseDataModules ¶
type TestManagementTestsResponseDataModules struct {
Modules map[string]TestManagementTestsResponseDataSuites `json:"modules"`
}
type TestManagementTestsResponseDataSuites ¶
type TestManagementTestsResponseDataSuites struct {
Suites map[string]TestManagementTestsResponseDataTests `json:"suites"`
}
type TestManagementTestsResponseDataTestProperties ¶
type TestManagementTestsResponseDataTestProperties struct {
Properties TestManagementTestsResponseDataTestPropertiesAttributes `json:"properties"`
}
type TestManagementTestsResponseDataTests ¶
type TestManagementTestsResponseDataTests struct {
Tests map[string]TestManagementTestsResponseDataTestProperties `json:"tests"`
}