feat: add FlareSolverr client and configuration for session management
All checks were successful
ci/woodpecker/push/pipeline Pipeline was successful
All checks were successful
ci/woodpecker/push/pipeline Pipeline was successful
This commit is contained in:
parent
d1741bcd32
commit
3e6bbdc723
1
.env
1
.env
@ -6,6 +6,7 @@ MINIO_ENDPOINT=http://omv2.badger-pirarucu.ts.net:9000
|
|||||||
MINIO_USER=rov
|
MINIO_USER=rov
|
||||||
MINIO_PASS=!E9v4i0v3
|
MINIO_PASS=!E9v4i0v3
|
||||||
|
|
||||||
|
FLARESOLVERR_ENDPOINT=https://flare-solverr.badger-pirarucu.ts.net
|
||||||
WEBSCRAPPER_ENDPOINT=http://mangamochi.badger-pirarucu.ts.net:8090/url
|
WEBSCRAPPER_ENDPOINT=http://mangamochi.badger-pirarucu.ts.net:8090/url
|
||||||
MANGAMATCHER_ENDPOINT=http://mangamochi.badger-pirarucu.ts.net:8000/match-title
|
MANGAMATCHER_ENDPOINT=http://mangamochi.badger-pirarucu.ts.net:8000/match-title
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,71 @@
|
|||||||
|
package com.magamochi.mangamochi.client;
|
||||||
|
|
||||||
|
import io.github.resilience4j.retry.annotation.Retry;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Builder;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
@FeignClient(name = "flare-solverr", url = "${flare-solverr.endpoint}/v1")
|
||||||
|
@Retry(name = "FlareSolverrRetry")
|
||||||
|
public interface FlareSolverrClient {
|
||||||
|
@PostMapping(
|
||||||
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||||
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
GetResponse get(@RequestBody GetRequest request);
|
||||||
|
|
||||||
|
@PostMapping(
|
||||||
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||||
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
SessionCreateResponse createSession(@RequestBody SessionCreateRequest request);
|
||||||
|
|
||||||
|
@PostMapping(
|
||||||
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||||
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
SessionDestroyResponse destroySession(@RequestBody SessionDestroyRequest request);
|
||||||
|
|
||||||
|
@PostMapping(
|
||||||
|
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||||
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
SessionListResponse listSessions(@RequestBody SessionListRequest request);
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
class GetRequest {
|
||||||
|
@Builder.Default private String cmd = "request.get";
|
||||||
|
|
||||||
|
@Builder.Default private Integer maxTimeout = 120000;
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
private String session;
|
||||||
|
}
|
||||||
|
|
||||||
|
record GetResponse(String status, String message, Solution solution) {
|
||||||
|
public record Solution(String url, Integer status, String response) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
class SessionCreateRequest {
|
||||||
|
@Builder.Default private String cmd = "sessions.create";
|
||||||
|
}
|
||||||
|
|
||||||
|
record SessionCreateResponse(String status, String message, String session) {}
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
class SessionDestroyRequest {
|
||||||
|
@Builder.Default private String cmd = "sessions.destroy";
|
||||||
|
|
||||||
|
private String session;
|
||||||
|
}
|
||||||
|
|
||||||
|
record SessionDestroyResponse(String status, String message) {}
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
class SessionListRequest {
|
||||||
|
@Builder.Default private String cmd = "sessions.list";
|
||||||
|
}
|
||||||
|
|
||||||
|
record SessionListResponse(String status, String message, List<String> sessions) {}
|
||||||
|
}
|
||||||
@ -38,6 +38,9 @@ springdoc:
|
|||||||
web-scrapper:
|
web-scrapper:
|
||||||
endpoint: ${WEBSCRAPPER_ENDPOINT}
|
endpoint: ${WEBSCRAPPER_ENDPOINT}
|
||||||
|
|
||||||
|
flare-solverr:
|
||||||
|
endpoint: ${FLARESOLVERR_ENDPOINT}
|
||||||
|
|
||||||
minio:
|
minio:
|
||||||
endpoint: ${MINIO_ENDPOINT}
|
endpoint: ${MINIO_ENDPOINT}
|
||||||
accessKey: ${MINIO_USER}
|
accessKey: ${MINIO_USER}
|
||||||
@ -59,6 +62,12 @@ manga-matcher:
|
|||||||
resilience4j:
|
resilience4j:
|
||||||
retry:
|
retry:
|
||||||
instances:
|
instances:
|
||||||
|
FlareSolverrRetry:
|
||||||
|
max-attempts: 2
|
||||||
|
wait-duration:
|
||||||
|
seconds: 5
|
||||||
|
retry-exceptions:
|
||||||
|
- feign.FeignException
|
||||||
MangaDexRetry:
|
MangaDexRetry:
|
||||||
max-attempts: 5
|
max-attempts: 5
|
||||||
wait-duration:
|
wait-duration:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user