package com.devjob.application.client;

import com.devjob.application.dto.JobInfo;
import com.devjob.common.dto.ApiResponse;
import org.springframework.resilience.annotation.Retryable;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.service.annotation.GetExchange;
import org.springframework.web.service.annotation.HttpExchange;

@HttpExchange
public interface JobHttpClient {

    // 일시적 오류(5xx·연결 오류)면 200ms 뒤 최대 3번 재시도. 4xx(없는 공고 등)는 재시도해도 소용없으니 제외한다.
    @GetExchange("/api/jobs/{id}")
    @Retryable(maxRetries = 3, delay = 200, excludes = HttpClientErrorException.class)
    ApiResponse<JobInfo> getJob(@PathVariable("id") Long id);
}
