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

reactor.net.zmq.ZeroMQServerSocketOptions Maven / Gradle / Ivy

The newest version!
package reactor.net.zmq;

import org.zeromq.ZContext;
import org.zeromq.ZMQ;
import reactor.function.Consumer;
import reactor.net.config.ServerSocketOptions;
import reactor.util.Assert;

/**
 * {@link reactor.net.config.ServerSocketOptions} that include ZeroMQ-specific configuration options.
 *
 * @author Jon Brisbin
 */
public class ZeroMQServerSocketOptions extends ServerSocketOptions {

	private ZContext context;
	private int socketType = ZMQ.ROUTER;
	private Consumer socketConfigurer;
	private String               listenAddresses;

	/**
	 * Get the {@link org.zeromq.ZMQ.Context} to use for IO.
	 *
	 * @return the {@link org.zeromq.ZMQ.Context} to use
	 */
	public ZContext context() {
		return context;
	}

	/**
	 * Set the {@link org.zeromq.ZMQ.Context} to use for IO.
	 *
	 * @param context
	 * 		the {@link org.zeromq.ZMQ.Context} to use
	 *
	 * @return {@literal this}
	 */
	public ZeroMQServerSocketOptions context(ZContext context) {
		Assert.notNull(context, "ZeroMQ Context cannot be null");
		this.context = context;
		return this;
	}

	/**
	 * The type of the ZMQ socket to create.
	 *
	 * @return the ZMQ socket type
	 */
	public int socketType() {
		return socketType;
	}

	/**
	 * Set the type of ZMQ socket to create.
	 *
	 * @param socketType
	 * 		the ZMQ socket type
	 *
	 * @return {@literal this}
	 */
	public ZeroMQServerSocketOptions socketType(int socketType) {
		this.socketType = socketType;
		return this;
	}


	/**
	 * The {@link reactor.function.Consumer} responsible for configuring the underlying ZeroMQ socket.
	 *
	 * @return the ZMQ.Socket configurer
	 */
	public Consumer socketConfigurer() {
		return socketConfigurer;
	}

	/**
	 * Set the {@link reactor.function.Consumer} responsible for configure the underlying ZeroMQ socket.
	 *
	 * @param socketConfigurer
	 * 		the ZMQ.Socket configurer
	 *
	 * @return {@literal this}
	 */
	public ZeroMQServerSocketOptions socketConfigurer(Consumer socketConfigurer) {
		this.socketConfigurer = socketConfigurer;
		return this;
	}


	public String listenAddresses() {
		return listenAddresses;
	}

	public ZeroMQServerSocketOptions listenAddresses(String listenAddresses) {
		this.listenAddresses = listenAddresses;
		return this;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy