Documentation
¶
Index ¶
- type APIClient
- func (c *APIClient) ConfirmUpload(ctx context.Context, remoteRunID string, artifact core.Artifact) error
- func (c *APIClient) CreateRun(ctx context.Context, run *core.Run) (string, error)
- func (c *APIClient) GetPresignedURL(ctx context.Context, remoteRunID string, artifact core.Artifact) (*ArtifactPresignResponse, error)
- type ArtifactConfirmRequest
- type ArtifactPresignRequest
- type ArtifactPresignResponse
- type Client
- type Config
- type ConfirmUploadRequest
- type CreateRunRequest
- type CreateRunResponse
- type MockUploadCall
- type MockUploadClient
- func (m *MockUploadClient) CallCount() int
- func (m *MockUploadClient) CalledWith(runID string) bool
- func (m *MockUploadClient) Reset()
- func (m *MockUploadClient) SetError(runID string, errMsg string)
- func (m *MockUploadClient) SetResult(runID string, err error)
- func (m *MockUploadClient) SetSuccess(runID string)
- func (m *MockUploadClient) UploadRun(ctx context.Context, runID string) error
- type PresignedURLRequest
- type PresignedURLResponse
- type UploadClient
- type UploadResult
- type Uploader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
APIClient handles communication with the QA backend server. It's responsible for creating run records and requesting presigned URLs.
func NewAPIClient ¶
NewAPIClient constructs a client for the QA backend API.
func (*APIClient) ConfirmUpload ¶
func (c *APIClient) ConfirmUpload(ctx context.Context, remoteRunID string, artifact core.Artifact) error
ConfirmUpload tells the backend that an artifact was successfully uploaded. Note: Backend expects batch format, so we wrap the single artifact in an array.
func (*APIClient) CreateRun ¶
CreateRun registers a new run with the QA backend and returns the server-assigned ID.
func (*APIClient) GetPresignedURL ¶
func (c *APIClient) GetPresignedURL(ctx context.Context, remoteRunID string, artifact core.Artifact) (*ArtifactPresignResponse, error)
GetPresignedURL requests a presigned URL for uploading a single artifact. Note: Backend expects batch format, so we wrap the single artifact in an array.
type ArtifactConfirmRequest ¶
type ArtifactConfirmRequest struct {
ArtifactID string `json:"artifact_id"` // Backend-assigned ULID (required!)
Filename string `json:"filename"` // Changed from file_name to match backend
ChecksumSHA256 string `json:"checksum_sha256"`
UploadedAt time.Time `json:"uploaded_at"`
}
ArtifactConfirmRequest represents a single artifact in the confirm request.
type ArtifactPresignRequest ¶
type ArtifactPresignRequest struct {
Filename string `json:"filename"` // Changed from file_name to match backend
Role string `json:"role"` // Required by backend (manifest, data, log, etc.)
ContentType string `json:"content_type"`
SizeBytes int64 `json:"size_bytes"`
ChecksumSHA256 string `json:"checksum_sha256"`
Source string `json:"source,omitempty"` // Optional, defaults to "cli"
}
ArtifactPresignRequest represents a single artifact in the presign request.
type ArtifactPresignResponse ¶
type ArtifactPresignResponse struct {
ArtifactID string `json:"artifact_id"` // Backend-assigned ULID
URL string `json:"url,omitempty"` // Presigned URL (empty if existing)
Method string `json:"method,omitempty"` // Usually "PUT"
Headers map[string]string `json:"headers,omitempty"` // Additional headers required
ExpiresAt string `json:"expires_at,omitempty"` // ISO timestamp
Status string `json:"status,omitempty"` // "existing" if artifact already uploaded
}
ArtifactPresignResponse represents a single artifact in the presign response.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client orchestrates the full upload process: 1. Load run metadata from disk 2. Create run record on server 3. Request presigned URLs for each artifact 4. Upload files with retry 5. Confirm successful uploads 6. Update local state
type Config ¶
type Config struct {
APIURL string
AuthToken string
ProjectID string
CacheRoot string
MaxRetries int
}
Config holds the settings needed to create an upload client.
type ConfirmUploadRequest ¶
type ConfirmUploadRequest struct {
Artifacts []ArtifactConfirmRequest `json:"artifacts"`
}
ConfirmUploadRequest notifies the backend that artifact uploads completed (batch format).
type CreateRunRequest ¶
type CreateRunRequest struct {
ProjectID string `json:"project_id"`
Manifest core.Manifest `json:"manifest"`
Source core.SourceMeta `json:"source"`
Capture core.CaptureSettings `json:"capture"`
StartedAt time.Time `json:"started_at"`
Completed *time.Time `json:"completed_at,omitempty"`
RecordsCount uint64 `json:"records_count"`
}
CreateRunRequest is sent to the backend to initialize a new run record.
type CreateRunResponse ¶
type CreateRunResponse struct {
RunID string `json:"run_id"`
}
CreateRunResponse contains the server-assigned run ID.
type MockUploadCall ¶
MockUploadCall records a single call to UploadRun
type MockUploadClient ¶
type MockUploadClient struct {
// UploadFunc is called when UploadRun is invoked
// If nil, returns success by default
UploadFunc func(ctx context.Context, runID string) error
// Calls tracks all calls to UploadRun
Calls []MockUploadCall
// Results maps runID to predetermined results
// Useful for testing specific scenarios
Results map[string]error
// contains filtered or unexported fields
}
MockUploadClient is a mock implementation of UploadClient for testing. It allows developers to simulate upload success, failure, and delays.
func NewMockUploadClient ¶
func NewMockUploadClient() *MockUploadClient
NewMockUploadClient creates a new mock upload client.
func (*MockUploadClient) CallCount ¶
func (m *MockUploadClient) CallCount() int
CallCount returns the number of times UploadRun was called.
func (*MockUploadClient) CalledWith ¶
func (m *MockUploadClient) CalledWith(runID string) bool
CalledWith returns true if UploadRun was called with the given runID.
func (*MockUploadClient) Reset ¶
func (m *MockUploadClient) Reset()
Reset clears all recorded calls.
func (*MockUploadClient) SetError ¶
func (m *MockUploadClient) SetError(runID string, errMsg string)
SetError is a convenience method to set an error result.
func (*MockUploadClient) SetResult ¶
func (m *MockUploadClient) SetResult(runID string, err error)
SetResult configures a predetermined result for a specific runID.
func (*MockUploadClient) SetSuccess ¶
func (m *MockUploadClient) SetSuccess(runID string)
SetSuccess is a convenience method to set a success result.
type PresignedURLRequest ¶
type PresignedURLRequest struct {
Artifacts []ArtifactPresignRequest `json:"artifacts"`
}
PresignedURLRequest asks the server for presigned URLs (batch format).
type PresignedURLResponse ¶
type PresignedURLResponse struct {
Artifacts []ArtifactPresignResponse `json:"artifacts"`
}
PresignedURLResponse contains the batch response from the backend.
type UploadClient ¶
UploadClient defines the interface for uploading runs. This allows for easy mocking in tests.
type UploadResult ¶
type UploadResult struct {
Artifact core.Artifact
Success bool
Attempts int
Error error
UploadedAt *time.Time
}
UploadResult tracks the outcome of an upload attempt.
type Uploader ¶
type Uploader struct {
// contains filtered or unexported fields
}
Uploader handles the actual file upload to presigned URLs with retry logic.
func NewUploader ¶
NewUploader creates an uploader with configurable retry behavior.
func (*Uploader) Upload ¶
func (u *Uploader) Upload(ctx context.Context, artifact core.Artifact, presignedURL *ArtifactPresignResponse) (*UploadResult, error)
Upload uploads a single file to a presigned URL with automatic retry and exponential backoff. This is where the "resilience" happens - network failures are expected and handled gracefully.