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

software.crldev.elrondspringbootstarterreactive.config.ErdClientConfig Maven / Gradle / Ivy

Go to download

A SpringBoot Starter solution designed to ensure easy and efficient integration with the Elrond Network using a Reactive API layer.

The newest version!
package software.crldev.elrondspringbootstarterreactive.config;

import software.crldev.elrondspringbootstarterreactive.properties.ErdClientProperties;
import io.netty.handler.timeout.ReadTimeoutHandler;
import io.netty.handler.timeout.WriteTimeoutHandler;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.netty.http.client.HttpClient;
import java.util.concurrent.TimeUnit;

/**
 * Class used for the configuration of ErdClient
 *
 * @author carlo_stanciu
 */
public class ErdClientConfig {
    private final String gatewayUrl;
    private final WebClient.Builder erdClientBuilder;

    /**
     * Constructor for creating an ErdClientConfig instance using properties
     *
     * @param clientProperties - injected properties required for webclient configuration
     */
    public ErdClientConfig(ErdClientProperties clientProperties) {
        this.gatewayUrl = clientProperties.getGateway();
        var httpClient = HttpClient.create().doOnConnected(conn -> conn.addHandler(new ReadTimeoutHandler(clientProperties.getReadTimeoutMillis(), TimeUnit.MILLISECONDS)).addHandler(new WriteTimeoutHandler(clientProperties.getWriteTimeoutMillis(), TimeUnit.MILLISECONDS)));
        this.erdClientBuilder = WebClient.builder().baseUrl(gatewayUrl).clientConnector(new ReactorClientHttpConnector(httpClient));
    }

    public String getGatewayUrl() {
        return this.gatewayUrl;
    }

    public WebClient.Builder getErdClientBuilder() {
        return this.erdClientBuilder;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy