package com.sonic.cow.config;

import com.byteplus.ark.runtime.service.ArkService;
import okhttp3.ConnectionPool;
import okhttp3.Dispatcher;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
public class ArkServiceConfig {

    @Value("${volcengine.baseUrl}")
    private String baseUrl;
    @Value("${volcengine.apiKey}")
    private String apiKey;

    @Bean(name = "volcengineArkService")
    public ArkService volcengineArkService() {
        Dispatcher dispatcher = new Dispatcher();
        ConnectionPool connectionPool = new ConnectionPool(5, 1, TimeUnit.SECONDS);
        return ArkService.builder()
                .baseUrl(baseUrl)
                .dispatcher(dispatcher)
                .connectionPool(connectionPool)
                .apiKey(apiKey)
                .build();
    }

}
