Skip to content

Commit

Permalink
Merge pull request #1946 from minrk/notify
Browse files Browse the repository at this point in the history
add new constants for 4.3.5
  • Loading branch information
minrk authored Feb 21, 2024
2 parents ead1066 + 4df5219 commit 2e10ff8
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/source/api/zmq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ as well as via enums (``zmq.SocketType.PUSH``, etc.).

.. autoenum:: Event

.. autoenum:: NormMode

.. autoenum:: RouterNotify

.. autoenum:: SecurityMechanism

.. autoenum:: DeviceType
Expand Down
19 changes: 19 additions & 0 deletions zmq/backend/cython/constant_enums.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,20 @@ cdef extern from "zmq.h" nogil:
enum: ZMQ_MORE
enum: ZMQ_SHARED
enum: ZMQ_SRCFD
enum: ZMQ_NORM_FIXED
enum: ZMQ_NORM_CC
enum: ZMQ_NORM_CCL
enum: ZMQ_NORM_CCE
enum: ZMQ_NORM_CCE_ECNONLY
enum: ZMQ_POLLIN
enum: ZMQ_POLLOUT
enum: ZMQ_POLLERR
enum: ZMQ_POLLPRI
enum: ZMQ_RECONNECT_STOP_CONN_REFUSED
enum: ZMQ_RECONNECT_STOP_HANDSHAKE_FAILED
enum: ZMQ_RECONNECT_STOP_AFTER_DISCONNECT
enum: ZMQ_NOTIFY_CONNECT
enum: ZMQ_NOTIFY_DISCONNECT
enum: ZMQ_NULL
enum: ZMQ_PLAIN
enum: ZMQ_CURVE
Expand Down Expand Up @@ -206,6 +213,18 @@ cdef extern from "zmq.h" nogil:
enum: ZMQ_HELLO_MSG
enum: ZMQ_DISCONNECT_MSG
enum: ZMQ_PRIORITY
enum: ZMQ_BUSY_POLL
enum: ZMQ_HICCUP_MSG
enum: ZMQ_XSUB_VERBOSE_UNSUBSCRIBE
enum: ZMQ_TOPICS_COUNT
enum: ZMQ_NORM_MODE
enum: ZMQ_NORM_UNICAST_NACK
enum: ZMQ_NORM_BUFFER_SIZE
enum: ZMQ_NORM_SEGMENT_SIZE
enum: ZMQ_NORM_BLOCK_SIZE
enum: ZMQ_NORM_NUM_PARITY
enum: ZMQ_NORM_NUM_AUTOPARITY
enum: ZMQ_NORM_PUSH
enum: ZMQ_PAIR
enum: ZMQ_PUB
enum: ZMQ_SUB
Expand Down
86 changes: 86 additions & 0 deletions zmq/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,19 @@ def __new__(cls, value: int, opt_type: _OptType = _OptType.int):
HELLO_MSG = 110, _OptType.bytes
DISCONNECT_MSG = 111, _OptType.bytes
PRIORITY = 112
# 4.3.5
BUSY_POLL = 113
HICCUP_MSG = 114, _OptType.bytes
XSUB_VERBOSE_UNSUBSCRIBE = 115
TOPICS_COUNT = 116
NORM_MODE = 117
NORM_UNICAST_NACK = 118
NORM_BUFFER_SIZE = 119
NORM_SEGMENT_SIZE = 120
NORM_BLOCK_SIZE = 121
NORM_NUM_PARITY = 122
NORM_NUM_AUTOPARITY = 123
NORM_PUSH = 124


class MessageOption(IntEnum):
Expand All @@ -282,6 +295,39 @@ class Flag(IntFlag):
NOBLOCK = DONTWAIT


class RouterNotify(IntEnum):
"""Values for zmq.ROUTER_NOTIFY socket option
.. versionadded:: 26
.. versionadded:: libzmq-4.3.0 (draft)
"""

@staticmethod
def _global_name(name):
return f"NOTIFY_{name}"

CONNECT = 1
DISCONNECT = 2


class NormMode(IntEnum):
"""Values for zmq.NORM_MODE socket option
.. versionadded:: 26
.. versionadded:: libzmq-4.3.5 (draft)
"""

@staticmethod
def _global_name(name):
return f"NORM_{name}"

FIXED = 0
CC = 1
CCL = 2
CCE = 3
CCE_ECNONLY = 4


class SecurityMechanism(IntEnum):
"""Security mechanisms (as returned by ``socket.get(zmq.MECHANISM)``)
Expand Down Expand Up @@ -502,13 +548,20 @@ class DeviceType(IntEnum):
MORE: int = MessageOption.MORE
SHARED: int = MessageOption.SHARED
SRCFD: int = MessageOption.SRCFD
NORM_FIXED: int = NormMode.FIXED
NORM_CC: int = NormMode.CC
NORM_CCL: int = NormMode.CCL
NORM_CCE: int = NormMode.CCE
NORM_CCE_ECNONLY: int = NormMode.CCE_ECNONLY
POLLIN: int = PollEvent.POLLIN
POLLOUT: int = PollEvent.POLLOUT
POLLERR: int = PollEvent.POLLERR
POLLPRI: int = PollEvent.POLLPRI
RECONNECT_STOP_CONN_REFUSED: int = ReconnectStop.CONN_REFUSED
RECONNECT_STOP_HANDSHAKE_FAILED: int = ReconnectStop.HANDSHAKE_FAILED
RECONNECT_STOP_AFTER_DISCONNECT: int = ReconnectStop.AFTER_DISCONNECT
NOTIFY_CONNECT: int = RouterNotify.CONNECT
NOTIFY_DISCONNECT: int = RouterNotify.DISCONNECT
NULL: int = SecurityMechanism.NULL
PLAIN: int = SecurityMechanism.PLAIN
CURVE: int = SecurityMechanism.CURVE
Expand Down Expand Up @@ -620,6 +673,18 @@ class DeviceType(IntEnum):
HELLO_MSG: int = SocketOption.HELLO_MSG
DISCONNECT_MSG: int = SocketOption.DISCONNECT_MSG
PRIORITY: int = SocketOption.PRIORITY
BUSY_POLL: int = SocketOption.BUSY_POLL
HICCUP_MSG: int = SocketOption.HICCUP_MSG
XSUB_VERBOSE_UNSUBSCRIBE: int = SocketOption.XSUB_VERBOSE_UNSUBSCRIBE
TOPICS_COUNT: int = SocketOption.TOPICS_COUNT
NORM_MODE: int = SocketOption.NORM_MODE
NORM_UNICAST_NACK: int = SocketOption.NORM_UNICAST_NACK
NORM_BUFFER_SIZE: int = SocketOption.NORM_BUFFER_SIZE
NORM_SEGMENT_SIZE: int = SocketOption.NORM_SEGMENT_SIZE
NORM_BLOCK_SIZE: int = SocketOption.NORM_BLOCK_SIZE
NORM_NUM_PARITY: int = SocketOption.NORM_NUM_PARITY
NORM_NUM_AUTOPARITY: int = SocketOption.NORM_NUM_AUTOPARITY
NORM_PUSH: int = SocketOption.NORM_PUSH
PAIR: int = SocketType.PAIR
PUB: int = SocketType.PUB
SUB: int = SocketType.SUB
Expand Down Expand Up @@ -738,6 +803,12 @@ class DeviceType(IntEnum):
"MORE",
"SHARED",
"SRCFD",
"NormMode",
"NORM_FIXED",
"NORM_CC",
"NORM_CCL",
"NORM_CCE",
"NORM_CCE_ECNONLY",
"PollEvent",
"POLLIN",
"POLLOUT",
Expand All @@ -747,6 +818,9 @@ class DeviceType(IntEnum):
"RECONNECT_STOP_CONN_REFUSED",
"RECONNECT_STOP_HANDSHAKE_FAILED",
"RECONNECT_STOP_AFTER_DISCONNECT",
"RouterNotify",
"NOTIFY_CONNECT",
"NOTIFY_DISCONNECT",
"SecurityMechanism",
"NULL",
"PLAIN",
Expand Down Expand Up @@ -860,6 +934,18 @@ class DeviceType(IntEnum):
"HELLO_MSG",
"DISCONNECT_MSG",
"PRIORITY",
"BUSY_POLL",
"HICCUP_MSG",
"XSUB_VERBOSE_UNSUBSCRIBE",
"TOPICS_COUNT",
"NORM_MODE",
"NORM_UNICAST_NACK",
"NORM_BUFFER_SIZE",
"NORM_SEGMENT_SIZE",
"NORM_BLOCK_SIZE",
"NORM_NUM_PARITY",
"NORM_NUM_AUTOPARITY",
"NORM_PUSH",
"SocketType",
"PAIR",
"PUB",
Expand Down
5 changes: 5 additions & 0 deletions zmq/tests/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ def test_int_sockopts(self):
'ONLY_FIRST_SUBSCRIBE',
'PRIORITY',
'RECONNECT_STOP',
'NORM_',
'ROUTER_',
'BUSY_POLL',
'XSUB_VERBOSE_',
'TOPICS_',
)
):
# some sockopts are write-only
Expand Down

0 comments on commit 2e10ff8

Please sign in to comment.