All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.charlemaznable.varys.impl.VarysReadTimeoutProvider Maven / Gradle / Ivy

There is a newer version: 2023.0.4
Show newest version
package com.github.charlemaznable.varys.impl;

import com.github.charlemaznable.core.net.ohclient.annotation.ClientTimeout.TimeoutProvider;
import com.github.charlemaznable.varys.config.VarysConfig;
import com.google.inject.Inject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Nullable;

import static com.github.charlemaznable.core.lang.Condition.nullThen;
import static com.github.charlemaznable.core.miner.MinerFactory.getMiner;

@Component
public final class VarysReadTimeoutProvider implements TimeoutProvider {

    private final VarysConfig varysConfig;

    public VarysReadTimeoutProvider() {
        this(null);
    }

    @Inject
    @Autowired
    public VarysReadTimeoutProvider(@Nullable VarysConfig varysConfig) {
        this.varysConfig = nullThen(varysConfig, () -> getMiner(VarysConfig.class));
    }

    @Override
    public long timeout(Class clazz) {
        return varysConfig.readTimeout();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy