package com.ssyf.third.bmiss.core;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Map;

/**
 * 超时配置类
 */
@Data
@Accessors(chain = true)
public class TimeoutConfig {
    private int connectTimeout = 10000;
    private int readTimeout = 30000;
    private int totalTimeout = 60000;
    
    public TimeoutConfig() {}
    
    public TimeoutConfig(Map<String, Object> data) {
        this.connectTimeout = ((Number) data.getOrDefault("connect_timeout", 10)).intValue() * 1000;
        this.readTimeout = ((Number) data.getOrDefault("read_timeout", 30)).intValue() * 1000;
        this.totalTimeout = ((Number) data.getOrDefault("timeout", 60)).intValue() * 1000;
    }
}