Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions internal/service/task_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,22 @@ func (s *TaskService) ExecutePendingTasks(ctx context.Context, maxTasks int) err

tracing.AddAttribute(ctx, "execution_mode", "http")

// Create HTTP client with timeout (shared across all tasks for connection reuse)
httpClient := &http.Client{
Timeout: 53 * time.Second, // 53 seconds timeout as requested
Transport: &http.Transport{
MaxIdleConns: 100,
MaxIdleConnsPerHost: 100,
IdleConnTimeout: 90 * time.Second,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true, // Skip TLS verification
},
},
}

// Wrap with OpenCensus tracing
httpClient = tracing.WrapHTTPClient(httpClient)

// Use a wait group to wait for all HTTP requests to complete
var wg sync.WaitGroup

Expand Down Expand Up @@ -293,19 +309,6 @@ func (s *TaskService) ExecutePendingTasks(ctx context.Context, maxTasks int) err
return
}

// Create HTTP client with timeout
httpClient := &http.Client{
Timeout: 53 * time.Second, // 53 seconds timeout as requested
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true, // Skip TLS verification
},
},
}

// Wrap with OpenCensus tracing
httpClient = tracing.WrapHTTPClient(httpClient)

// Create request with tracing context
endpoint := fmt.Sprintf("%s/api/tasks.execute", s.apiEndpoint)
req, err := http.NewRequest(http.MethodPost, endpoint, bytes.NewBuffer(reqBody))
Expand Down