国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? Java java?? ?? ???? API ??: ?? ??? ??? ?? ??? ??

???? API ??: ?? ??? ??? ?? ??? ??

Jan 04, 2025 pm 03:48 PM

Building Resilient APIs: Mistakes I Made and How I Overcame Them

API? ?? ??????? ?????. Spring Boot? ?? API ??? ???? ? ?? ??? ?? ??? ??? ? ?? ??? ??? ???? ??????. ?? ??? ???? ???? ??? ??? ???? API? ??? API? ???? ??? ? ?? ??? ??? ??? ?????. ??? ?? ??? ? ?? ??? ?? ??? ??? ??? ??????. ???? ???? ??? ??? ?? ? ??? ????.

?? 1: ?? ?? ?? ??

?? ?? ????? ?? ???? ? ???? ?3? ???? ?? ???? API? ??????. ?? ??? ???? ?? ???? ??? ???? ????? ?? ?? ??? ??? ?? ?????. ???? ???? ?? ???? ??? ???? ???? ?? ?? ??? ?????. ? API? ??? ???? ??? ?????.

??: API? ???? ??? ??????. ?? ???? ???? ???? ???? ?? ??? ??????. ??? ??? ??? 500 ?? ?? ??? ??? ????.

?? ??: ?? ?? ?? ?? ??? ???? ??????. Spring Boot? ???? ??? ??? ??? ??? ????.

@Configuration
public class RestTemplateConfig {

    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder) {
        return builder
                .setConnectTimeout(Duration.ofSeconds(5))
                .setReadTimeout(Duration.ofSeconds(5))
                .additionalInterceptors(new RestTemplateLoggingInterceptor())
                .build();
    }

    // Custom interceptor to log request/response details
    @RequiredArgsConstructor
    public class RestTemplateLoggingInterceptor implements ClientHttpRequestInterceptor {
        private static final Logger log = LoggerFactory.getLogger(RestTemplateLoggingInterceptor.class);

        @Override
        public ClientHttpResponse intercept(HttpRequest request, byte[] body, 
                                          ClientHttpRequestExecution execution) throws IOException {
            long startTime = System.currentTimeMillis();
            log.info("Making request to: {}", request.getURI());

            ClientHttpResponse response = execution.execute(request, body);

            long duration = System.currentTimeMillis() - startTime;
            log.info("Request completed in {}ms with status: {}", 
                    duration, response.getStatusCode());

            return response;
        }
    }
}

? ???? ??? ?? ??? ??? ?? ??? ?? ??? ??? ?????? ? ??? ?? ??? ?????.

?? 2: ?? ???? ???? ??

?? ?? ????: ??? ???? ?? ???? ? ?? ?? ??? ?? ?????. ? API? ??? ???? ???? ?????. ?? ??? ??? ?? ????? ?? ????? ?? ???? ? ?? ??? ??????.

??? ??? ?? ????? ?? ??? ?? ? ?????. ??? ???? ???? ?? ???? ????? ??? ??? ??? ? ????.

??: ???? ???? ?? ???? ????? ??????? ?? ??? ???? ?? ????? ??? ?????.

?? ??: ?? ?? ??? ??? ??????. Spring Cloud Resilience4j? ???? ??? ???? ?? ? ?????.

@Configuration
public class Resilience4jConfig {

    @Bean
    public CircuitBreakerConfig circuitBreakerConfig() {
        return CircuitBreakerConfig.custom()
                .failureRateThreshold(50)
                .waitDurationInOpenState(Duration.ofSeconds(60))
                .permittedNumberOfCallsInHalfOpenState(2)
                .slidingWindowSize(2)
                .build();
    }

    @Bean
    public RetryConfig retryConfig() {
        return RetryConfig.custom()
                .maxAttempts(3)
                .waitDuration(Duration.ofSeconds(2))
                .build();
    }
}

@Service
@Slf4j
public class ResilientService {

    private final CircuitBreaker circuitBreaker;
    private final RestTemplate restTemplate;

    public ResilientService(CircuitBreakerRegistry registry, RestTemplate restTemplate) {
        this.circuitBreaker = registry.circuitBreaker("internalService");
        this.restTemplate = restTemplate;
    }

    @CircuitBreaker(name = "internalService", fallbackMethod = "fallbackResponse")
    @Retry(name = "internalService")
    public String callInternalService() {
        return restTemplate.getForObject("https://internal-service.com/data", String.class);
    }

    public String fallbackResponse(Exception ex) {
        log.warn("Circuit breaker activated, returning fallback response", ex);
        return new FallbackResponse("Service temporarily unavailable", 
                                  getBackupData()).toJson();
    }

    private Object getBackupData() {
        // Implement cache or default data strategy
        return new CachedDataService().getLatestValidData();
    }
}

? ??? ??? ? API? ?? ???? ?? ???? ???? ?? ???? ??? ???? ??????.

?? 3: ??? ?? ??

?? ?? ????: ???? ?? ??? ?? ?? ???? ?????. ? API??? ???? ??(?: ?? ??? HTTP 500)? ????? ?? ??? ??? ?? ?? ??? ???????.

??: ???? ??? ?????? ???????, ?? ????? ???? ???? ?? ??? ??????.

?? ??: Spring? @ControllerAdvice ??? ???? ?? ??? ?? ?????? ??????. ?? ? ?? ??? ????.

@Configuration
public class RestTemplateConfig {

    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder) {
        return builder
                .setConnectTimeout(Duration.ofSeconds(5))
                .setReadTimeout(Duration.ofSeconds(5))
                .additionalInterceptors(new RestTemplateLoggingInterceptor())
                .build();
    }

    // Custom interceptor to log request/response details
    @RequiredArgsConstructor
    public class RestTemplateLoggingInterceptor implements ClientHttpRequestInterceptor {
        private static final Logger log = LoggerFactory.getLogger(RestTemplateLoggingInterceptor.class);

        @Override
        public ClientHttpResponse intercept(HttpRequest request, byte[] body, 
                                          ClientHttpRequestExecution execution) throws IOException {
            long startTime = System.currentTimeMillis();
            log.info("Making request to: {}", request.getURI());

            ClientHttpResponse response = execution.execute(request, body);

            long duration = System.currentTimeMillis() - startTime;
            log.info("Request completed in {}ms with status: {}", 
                    duration, response.getStatusCode());

            return response;
        }
    }
}

?? ?? ?? ???? ???? ????? ???? ??? ???? ??? ?????.

?? 4: ?? ?? ??

?? ?? ????: ?? ??? ?, ???? ???? ????? API ???? ??????. ?? ????? ?? ?????? ?? ???? API? ?? ??? ??? ???? ?? ?? ?? ???? ???? ???????.

??: ??? ??? ????? ??? ??????.

?? ??: ? ??? ???? ?? Redis? ?? Bucket4j? ???? ?? ??? ??????. ?? ??? ????.

@Configuration
public class Resilience4jConfig {

    @Bean
    public CircuitBreakerConfig circuitBreakerConfig() {
        return CircuitBreakerConfig.custom()
                .failureRateThreshold(50)
                .waitDurationInOpenState(Duration.ofSeconds(60))
                .permittedNumberOfCallsInHalfOpenState(2)
                .slidingWindowSize(2)
                .build();
    }

    @Bean
    public RetryConfig retryConfig() {
        return RetryConfig.custom()
                .maxAttempts(3)
                .waitDuration(Duration.ofSeconds(2))
                .build();
    }
}

@Service
@Slf4j
public class ResilientService {

    private final CircuitBreaker circuitBreaker;
    private final RestTemplate restTemplate;

    public ResilientService(CircuitBreakerRegistry registry, RestTemplate restTemplate) {
        this.circuitBreaker = registry.circuitBreaker("internalService");
        this.restTemplate = restTemplate;
    }

    @CircuitBreaker(name = "internalService", fallbackMethod = "fallbackResponse")
    @Retry(name = "internalService")
    public String callInternalService() {
        return restTemplate.getForObject("https://internal-service.com/data", String.class);
    }

    public String fallbackResponse(Exception ex) {
        log.warn("Circuit breaker activated, returning fallback response", ex);
        return new FallbackResponse("Service temporarily unavailable", 
                                  getBackupData()).toJson();
    }

    private Object getBackupData() {
        // Implement cache or default data strategy
        return new CachedDataService().getLatestValidData();
    }
}

?? ?? ??? ??? ???? API? ???? ??? ?????.

?? 5: ?? ???? ???

?? ?? ?????? ?? ???? ??? ??? ??? ?? ?? ???? ??? ?? ?? ?????. ??? ???? ??? ???? ?? ?? ??? ???? ? ???? ??? ?? ?????.

??: ?? ??? ??? ?? ?? ??? ???? ???? ??? ?????.

?? ??: ?? ??? ?? Spring Boot Actuator? ???? ??? ???? ?? Prometheus? Grafana? ??????.

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {

    @ExceptionHandler(HttpClientErrorException.class)
    public ResponseEntity<ErrorResponse> handleHttpClientError(HttpClientErrorException ex, 
                                                             WebRequest request) {
        log.error("Client error occurred", ex);

        ErrorResponse error = ErrorResponse.builder()
                .timestamp(LocalDateTime.now())
                .status(ex.getStatusCode().value())
                .message(sanitizeErrorMessage(ex.getMessage()))
                .path(((ServletWebRequest) request).getRequest().getRequestURI())
                .build();

        return ResponseEntity.status(ex.getStatusCode()).body(error);
    }

    @ExceptionHandler(Exception.class)
    public ResponseEntity<ErrorResponse> handleGeneralException(Exception ex, 
                                                              WebRequest request) {
        log.error("Unexpected error occurred", ex);

        ErrorResponse error = ErrorResponse.builder()
                .timestamp(LocalDateTime.now())
                .status(HttpStatus.INTERNAL_SERVER_ERROR.value())
                .message("An unexpected error occurred. Please try again later.")
                .path(((ServletWebRequest) request).getRequest().getRequestURI())
                .build();

        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(error);
    }

    private String sanitizeErrorMessage(String message) {
        // Remove sensitive information from error messages
        return message.replaceAll("(password|secret|key)=\[.*?\]", "=[REDACTED]");
    }
}

?? ELK Stack(Elasticsearch, Logstash, Kibana)? ???? ???? ??? ??????. ?? ?? ??? ?? ???? ?? ??????.

?????

??? ?? API? ???? ?? ??? ???? ??? ? ??? ?????. ?? ?? ?? ??? ??? ????.

  1. ?? ?? ??? ?? ?? ??? ?????.
  2. ?? ??? ????? ?? ???? ?????.
  3. ?? ??? ?? ????? ???? ???? ????.
  4. ??? ??? ???? ?? ?? ??? ?????.

??? ??? ?? API ??? ???? ??? ???????. ??? ??? ????? ?? ?? ??? ??? ???? ?? ????!

?? ??: ???? ???? ??? ??? ???? ???? ???? ?????. ??? ? ?? ??? ??? ?? ??? ???? ????? ????? ?? ???? API? ??? ? ??? ??? ???.

? ??? ???? API ??: ?? ??? ??? ?? ??? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

??? ????
1600
29
PHP ????
1502
276
???
?? ??? ??? ????? ?? ?? ??? ??? ????? ?? Jul 07, 2025 am 02:24 AM

Java? ??? ?? ??, ?? ? ??? (? : Projectreactor) ? Java19? ?? ???? ??? ??? ?????? ?????. 1. CompletableFuture? ?? ??? ?? ?? ??? ? ?? ??? ????? ?? ??????? ? ?? ??? ?????. 2. Projectreactor? ?? ? ??? ??? ???? ?? ???? ? ??? ???? ?? ? ?????? ?????. 3. ?? ???? ??? ??? ??? I/O ??? ? ??? ???? ?? ??? ????? ??? ???? ????. ? ???? ?? ??? ????? ??? ??? ??? ?? ??? ??? ?????? ???? ???? ?? ?? ??? ??????.

???? ??? ?????? ?? ?? ???? ??? ?????? ?? ?? Jul 07, 2025 am 02:35 AM

Java?? ??? ?? ?? ??? ???? ? ?????. ?? ???? ??? ?????. 1. ?? ?? ? ???? ??????? ?? ?? ?? ??? ???? ??? ?????. 2. ?? ??, ???, ??? ?? ?? ?? ???? ????? ?? ??? ??? ??? ?????. 3. ENUMMAP ? ENUMSET? ???? ?? ? ?? ???? ???? ??? ???? ? ?????? ?????. 4. ?? ?, ??? ?? ?? ??? ?? ????? ?? ??? ??? ?????.? ????? ?? ???? ????????. ??? ???? ???? ?? ??? ????? ??? ?? ? ??? ?? ?????? ???????.

Java Nio? ? ??? ????? Java Nio? ? ??? ????? Jul 08, 2025 am 02:55 AM

Javanio? Java 1.4? ?? ? ??? IOAPI???. 1) ?? ? ??? ?????, 2) ??, ?? ? ??? ?? ?? ??, 3) ? ??? ??? ???? 4) ?? ??? ?? IO?? ? ????? ?????. 1) ? ?? IO? ??? ?? ??? ???, 2) ??? ??? ?? ???? ?????, 3) ???? ?????? ???? 4) ??? ?? ??? ?? ?? ? ??? ?????. 1) ??? ??/??? ??? ?? ?????, 2) ???? ???? ???? ?? ???? ???????. 3) ??? ??? ??? ???????.

?? ?? ???? ????? ??? ?????? ?? ?? ???? ????? ??? ?????? Jul 15, 2025 am 03:10 AM

?? ?? Java? ?? ???? ?? ? ? ? ????? ????, ? ??? ??? ??? ??? ???? ? ????. 1. ?? ?? hashcode () ???? ???? ?? ?? ???? ?? ??? ?? ?? ???? ?????. 2. ?? ??? ??? ?? ?? ???? ??? ??? ? ????. ?? ??? ?? ? ??? ??? ?????. JDK8 ? ?? ? ??? ?? ?? (?? ?? 8) ??? ????? ?? ???? ?? ? ??? ?????. 3. ??? ?? ???? ?? ???? ?? equals () ? hashcode () ???? ?? ???????. 4. ?? ?? ??? ???? ?????. ?? ?? ??? ???? ?? ?? (?? 0.75)? ??? ?? ? ???; 5. ?? ?? ??? ??? ??? Multithreaded?? Concu? ???????.

Java ?? ? ?? ??? ???? ?? Java ?? ? ?? ??? ???? ?? Jul 07, 2025 am 02:43 AM

Java ??? ??? ???? ??? ??? ??? ?????, ???? ????, ?????? ??? ? ????. 1. ??? ????? ???? ??? ? ? ??? ?? ?? ????? ???? ? ???? ??????. 2. ???? ?? ?? ???? ??? ??? ???? ?? ?? ???? ??? ??? ? ????. 3. ???? ???? ??? ??? ?? ??? ?? ? ? ??????. 4. ?? ?? ?? ??? ? ??? ??? ?? ????? ?? ?? ??? ??? ? ????. 5. ??, ?? ?? ??, ?? ?? ?? ???, ????? ?? ?? ? ???? ??? ????? ??????.

Java? ?? ? ??? ??? ?????? Java? ?? ? ??? ??? ?????? Jul 09, 2025 am 01:32 AM

Java? Singleton Design Pattern? ???? ??? ???? ? ?? ?? ??? ? ?? ??? ?? ??? ??? ???? ???? ?? ???? ?? ???? ???? ??? ?????. ?? ???? ??? ?????. 1. ?????, ? ????? ? ?? ??? ?? ? ?? ????, ?? ?? ??? ?? ??? ???? ?? ??? ?????. 2. ???-?? ??, ??? ?? ?? ?? ?? ??? ?? ?? ??? ???? ??? ???? ? ???? ?? ??? ????. 3. ??? ?? ?? ????? ?? ????? ??? ??? ?? ??? ? ??? ??? ?? ?? ????? ?????. 4. ?? ??? ???? ???, ??? ??? ? ?? ??? ???? ?? ??? ???? ??? ??? ?????. ?? ??? ?? ?? ?? ??? ??? ? ????.

Java ?? ?? Java ?? ?? Jul 12, 2025 am 02:55 AM

?? ??? ??? ???? ???? ? ??? ?? ?? ???? ?? ? ????. 1. ??. ofnullable? null ??? ??? ???? ?????. ?? ??, ??? ?? ??? ? Orelse? ???? ???? ? ???? ??? ???? ?????. 2. ?? ?? ?? ???? ?? ?? ???? NPE? ???? ??? ??? ??? ???? ???? ???? ?????. 3. ??? ??? ???? ??? ? ???, ??? ???? ???? ?? ??? ?? ?????. ??? ??? ??? ???? ??? ??? Orelse? ?? ?????. 4. ?? ???? ??? ??? ?? ??? ??? ???? ???? ?? ???? ???? ???? ?? ??? ?? ????? NU? ?? ?????.

java.io.notserializableException? ???? ??? java.io.notserializableException? ???? ??? Jul 12, 2025 am 03:07 AM

java.io.notserializableException? ????? ?? ?? ??? ??? ???? ?? ???? ??? ??? ?????? ???? ?? ? ??? ??? ??? ????? ???? ????. 1. ?? ???? ??? ??????. 2. ???? ?? ??? ?? ???? ??? ??? ?????????. 3. ??? ? ????? ?? ??? ??? ??????. 4. ?? ?? ?? ? ???? ? ??? ??? ??????. 5. ?????? ???? ?? ???? ??????. 6. ? ??? ?? ?? ??? ??? ?? ?? ??? ?? ??? ??? ???? ?? ??? ??????. 7. ??? ??????

See all articles