package com.devjob.application.client;

import com.devjob.application.dto.JobInfo;
import com.devjob.common.dto.ApiResponse;
import org.springframework.resilience.annotation.ConcurrencyLimit;
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 {

    // 안쪽 방어 두 겹: 동시 호출 15개로 제한(벌크헤드) + 일시적 오류면 재시도.
    // 4xx(없는 공고 등)는 재시도해도 소용없으니 제외한다.
    @GetExchange("/api/jobs/{id}")
    @ConcurrencyLimit(15)
    @Retryable(maxRetries = 3, delay = 200, excludes = HttpClientErrorException.class)
    ApiResponse<JobInfo> getJob(@PathVariable("id") Long id);
}
