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

io.hyperfoil.tools.horreum.action.SlackClient Maven / Gradle / Ivy

There is a newer version: 0.15.3
Show newest version
package io.hyperfoil.tools.horreum.action;

import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

import io.quarkus.runtime.Startup;
import io.vertx.core.http.HttpVersion;
import io.vertx.ext.web.client.WebClientOptions;
import io.vertx.mutiny.core.Vertx;
import io.vertx.mutiny.ext.web.client.WebClient;

@ApplicationScoped
@Startup
public class SlackClient {
    @Inject
    Vertx vertx;

    private WebClient httpClient;

    @PostConstruct
    public void postConstruct() {
        WebClientOptions options = new WebClientOptions()
                .setFollowRedirects(false)
                .setMaxPoolSize(1) // we won't use more than 1 connection to prevent server rate limiting
                .setConnectTimeout(2_000) // only wait 2s
                .setKeepAlive(false);
        httpClient = WebClient.create(vertx, new WebClientOptions(options).setProtocolVersion(HttpVersion.HTTP_1_1));
    }

    public WebClient httpClient() {
        return httpClient;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy