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

io.dropwizard.unixsocket.UnixSocketConnectorFactory Maven / Gradle / Ivy

There is a newer version: 5.0.0-alpha.5
Show newest version
package io.dropwizard.unixsocket;

import com.codahale.metrics.MetricRegistry;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import io.dropwizard.jetty.HttpConnectorFactory;
import io.dropwizard.metrics.jetty11.InstrumentedConnectionFactory;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.unixdomain.server.UnixDomainServerConnector;
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
import org.eclipse.jetty.util.thread.ThreadPool;

import java.nio.file.Paths;

import static com.codahale.metrics.MetricRegistry.name;

/**
 * Builds Unix Domain Socket connectors.
 * 

* Configuration Parameters: *

* * * * * * * * * * *
NameDefaultDescription
{@code path}/tmp/dropwizard.sock * The path to the unix domain socket file. *
*

*/ @JsonTypeName("unix-socket") public class UnixSocketConnectorFactory extends HttpConnectorFactory { private String path = "/tmp/dropwizard.sock"; @JsonProperty public String getPath() { return path; } @JsonProperty public void setPath(String path) { this.path = path; } @Override public Connector build(Server server, MetricRegistry metrics, String name, @Nullable ThreadPool threadPool) { var scheduler = new ScheduledExecutorScheduler(); var bufferPool = buildBufferPool(); var httpConfig = buildHttpConfiguration(); var httpConnectionFactory = buildHttpConnectionFactory(httpConfig); var instrumentedConnectionFactory = new InstrumentedConnectionFactory(httpConnectionFactory, metrics.timer(httpConnections())); final UnixDomainServerConnector connector = new UnixDomainServerConnector(server, threadPool, scheduler, bufferPool, getAcceptorThreads().orElse(-1), getSelectorThreads().orElse(-1), instrumentedConnectionFactory); if (getAcceptQueueSize() != null) { connector.setAcceptQueueSize(getAcceptQueueSize()); } connector.setUnixDomainPath(Paths.get(path)); connector.setIdleTimeout(getIdleTimeout().toMilliseconds()); connector.setName(name); return connector; } @Override protected String httpConnections() { return name(UnixSocketConnectorFactory.class, path, "connections"); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy