View Javadoc
1   /*
2    * Copyright (c) 2023. Roland T. Lichti, Kaiserpfalz EDV-Service.
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16   */
17  
18  package de.kaiserpfalzedv.services.eansearch.client;
19  
20  import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
21  
22  import java.util.Set;
23  
24  import org.springframework.cloud.openfeign.FeignClient;
25  import org.springframework.web.bind.annotation.RequestMapping;
26  import org.springframework.web.bind.annotation.RequestMethod;
27  import org.springframework.web.bind.annotation.RequestParam;
28  
29  import de.kaiserpfalzedv.services.eansearch.model.EanData;
30  import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;
31  import io.github.resilience4j.retry.annotation.Retry;
32  import io.micrometer.core.annotation.Counted;
33  import io.micrometer.core.annotation.Timed;
34  
35  /**
36   * <p>EanSearchClient -- The client for accessing the web service.</p>
37   *
38   *
39   * @author rlichti {@literal <rlichti@kaiserpfalz-edv.de>}
40   * @since 3.0.0  2023-01-17
41   */
42  @FeignClient(name = "eansearch", configuration = EanSearchClientConfig.class, path = "/api")
43  public interface EanSearchClient {
44      @RequestMapping(method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
45      @Retry(name = "eansearch")
46      @CircuitBreaker(name = "eansearch")
47      @Timed("ean-search.lookup.ean.time")
48      @Counted("ean-search.lookup.ean.count")
49      // @Retry(delay = 2000, maxDuration = 6000, retryOn = {EanSearchTooManyRequestsException.class, RateLimitException.class}, abortOn = EanSearchException.class)
50      // @CircuitBreaker(failOn = EanSearchException.class, requestVolumeThreshold = 5)
51      Set<EanData> barcodeLookupEAN(@RequestParam("ean") final String ean13);
52  
53      @RequestMapping(method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
54      @Retry(name = "eansearch")
55      @CircuitBreaker(name = "eansearch")
56      @Timed("ean-search.lookup.upc.time")
57      @Counted("ean-search.lookup.upc.count")
58      // @Retry(delay = 2000, maxDuration = 6000, retryOn = {EanSearchTooManyRequestsException.class, RateLimitException.class}, abortOn = EanSearchException.class)
59      // @CircuitBreaker(failOn = EanSearchException.class, requestVolumeThreshold = 5)
60      Set<EanData> barcodeLookupUPC(@RequestParam("upc") final String upc12);
61  
62      @RequestMapping(method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
63      @Retry(name = "eansearch")
64      @CircuitBreaker(name = "eansearch")
65      @Timed("ean-search.lookup.isbn.time")
66      @Counted("ean-search.lookup.isbn.count")
67      Set<EanData> barcodeLookupISBN(@RequestParam("isbn") final String isbn10);
68  }