added advertising
This commit is contained in:
25
src/main/java/com/krylov/refound/config/AsyncConfig.java
Normal file
25
src/main/java/com/krylov/refound/config/AsyncConfig.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.krylov.refound.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Configuration
|
||||
@EnableAsync
|
||||
public class AsyncConfig {
|
||||
|
||||
@Bean(name = "ffmpegExecutor")
|
||||
public Executor ffmpegExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
// FFmpeg сам многопоточный внутри — не нужно много параллельных процессов
|
||||
executor.setCorePoolSize(2);
|
||||
executor.setMaxPoolSize(2);
|
||||
executor.setQueueCapacity(20);
|
||||
executor.setThreadNamePrefix("ffmpeg-");
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,12 @@ import software.amazon.awssdk.services.s3.S3Client;
|
||||
import software.amazon.awssdk.services.s3.S3Configuration;
|
||||
|
||||
import java.net.URI;
|
||||
import software.amazon.awssdk.services.s3.presigner.S3Presigner;
|
||||
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
public class S3ClientConfig {
|
||||
|
||||
private final MinioProperties properties;
|
||||
|
||||
@Bean
|
||||
@@ -21,12 +23,29 @@ public class S3ClientConfig {
|
||||
return S3Client.builder()
|
||||
.endpointOverride(URI.create(properties.endpoint()))
|
||||
.region(Region.of(properties.region()))
|
||||
.credentialsProvider(StaticCredentialsProvider.create(
|
||||
AwsBasicCredentials.create(properties.accessKey(), properties.secretKey())))
|
||||
// ВАЖНО для MinIO: path-style вместо virtual-hosted style
|
||||
.serviceConfiguration(S3Configuration.builder()
|
||||
.pathStyleAccessEnabled(true)
|
||||
.build())
|
||||
.credentialsProvider(credentialsProvider())
|
||||
.serviceConfiguration(pathStyleConfiguration())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public S3Presigner s3Presigner() {
|
||||
return S3Presigner.builder()
|
||||
.endpointOverride(URI.create(properties.endpoint()))
|
||||
.region(Region.of(properties.region()))
|
||||
.credentialsProvider(credentialsProvider())
|
||||
.serviceConfiguration(pathStyleConfiguration())
|
||||
.build();
|
||||
}
|
||||
|
||||
private StaticCredentialsProvider credentialsProvider() {
|
||||
return StaticCredentialsProvider.create(
|
||||
AwsBasicCredentials.create(properties.accessKey(), properties.secretKey()));
|
||||
}
|
||||
|
||||
private S3Configuration pathStyleConfiguration() {
|
||||
return S3Configuration.builder()
|
||||
.pathStyleAccessEnabled(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user