
org.zeromq.ZEvent Maven / Gradle / Ivy
package org.zeromq;
import java.nio.channels.SelectableChannel;
import java.time.Duration;
import java.util.Objects;
import java.util.function.Function;
import org.zeromq.ZMQ.Socket;
import org.zeromq.ZMonitor.Event;
import zmq.ZError;
/**
* A high level wrapper for an event that stores all value as Enum or java object instead of integer, and associate a
* severity with them.
* The events are handled using the following rules.
*
*
* Events list
*
* Event
* Value type
* Severity level
*
*
* CONNECTED
* {@link java.nio.channels.SelectableChannel}
* debug
*
*
* CONNECT_DELAYED
* {@link ZMQ.Error} or null if no error
* debug
*
*
* CONNECT_RETRIED
* {@link java.time.Duration}
* debug
*
*
* LISTENING
* {@link java.nio.channels.SelectableChannel}
* debug
*
*
* BIND_FAILED
* {@link ZMQ.Error} or null if no error
* error
*
*
* ACCEPTED
* {@link java.nio.channels.SelectableChannel}
* debug
*
*
* ACCEPT_FAILED
* {@link ZMQ.Error} or null if no error
* error
*
*
* CLOSED
* {@link java.nio.channels.SelectableChannel}
* debug
*
*
* CLOSE_FAILED
* {@link ZMQ.Error} or null if no error
* error
*
*
* DISCONNECTED
* {@link java.nio.channels.SelectableChannel}
* info
*
*
* MONITOR_STOPPED
* null value
* debug
*
*
* HANDSHAKE_FAILED_NO_DETAIL
* {@link ZMQ.Error} or null if no error
* error
*
*
* HANDSHAKE_SUCCEEDED
* {@link ZMQ.Error} or null if no error
* debug
*
*
* HANDSHAKE_FAILED_PROTOCOL
* {@link ZMonitor.ProtocolCode}
* error
*
*
* HANDSHAKE_FAILED_AUTH
* {@link java.lang.Integer}
* warn
*
*
* HANDSHAKE_PROTOCOL
* {@link java.lang.Integer}
* debug
*
*
*/
public class ZEvent
{
/**
* An interface used to consume events in monitor
*/
public interface ZEventConsummer extends zmq.ZMQ.EventConsummer
{
void consume(ZEvent ev);
default void consume(zmq.ZMQ.Event event)
{
consume(new ZEvent(event, SelectableChannel.class::cast));
}
}
private final Event event;
// To keep backward compatibility, the old value field only store integer
// The resolved value (Error, channel or other) is stored in resolvedValue field.
private final Object value;
private final String address;
private ZEvent(zmq.ZMQ.Event event, Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy