Source

crossroads / crossroads / constants.py

# -*- coding: utf-8 -*-
'''Crossroads constants.'''

################################################################################
## CROSSROADS ERRORS ###########################################################
################################################################################

# number random enough not to collide with different errno ranges on different
# OSes. The assumption is that error_t is at least 32-bit type.
HAUSNUMERO = 156384712
# NOTE: on Windows platforms some of the standard POSIX errnos are not defined
ENOTSUP = HAUSNUMERO + 1
EPROTONOSUPPORT = HAUSNUMERO + 2
ENOBUFS = HAUSNUMERO + 3
ENETDOWN = HAUSNUMERO + 4
EADDRINUSE = HAUSNUMERO + 5
EADDRNOTAVAIL = HAUSNUMERO + 6
ECONNREFUSED = HAUSNUMERO + 7
EINPROGRESS = HAUSNUMERO + 8
ENOTSOCK = HAUSNUMERO + 9
EAFNOSUPPORT = HAUSNUMERO + 10

# native Crossroads error codes
EFSM = HAUSNUMERO + 51
ENOCOMPATPROTO = HAUSNUMERO + 52
ETERM = HAUSNUMERO + 53

################################################################################
# CROSSROADS CONTEXT DEFINITION ################################################
################################################################################

MAX_SOCKETS = 1
IO_THREADS = 2
PLUGIN = 3

# implicit constants
_MAX_SOCKETS = 512
_IO_THREADS = 1

################################################################################
## CROSSROADS SOCKET DEFINITION ################################################
################################################################################

# socket types
PAIR = 0
PUB = 1
SUB = 2
REQ = 3
REP = 4
XREQ = 5
XREP = 6
PULL = 7
PUSH = 8
XPUB = 9
XSUB = 10
SURVEYOR = 11
RESPONDENT = 12
XSURVEYOR = 13
XRESPONDENT = 14
# legacy socket type aliases
ROUTER = XREP
DEALER = XREQ
# socket options
AFFINITY = 4
IDENTITY = 5
SUBSCRIBE = 6
UNSUBSCRIBE = 7
RATE = 8
RECOVERY_IVL = 9
SNDBUF = 11
RCVBUF = 12
RCVMORE = 13
FD = 14
EVENTS = 15
TYPE = 16
LINGER = 17
RECONNECT_IVL = 18
BACKLOG = 19
RECONNECT_IVL_MAX = 21
MAXMSGSIZE = 22
SNDHWM = 23
RCVHWM = 24
MULTICAST_HOPS = 25
RCVTIMEO = 27
SNDTIMEO = 28
IPV4ONLY = 31
KEEPALIVE = 32
PROTOCOL = 33
SURVEY_TIMEOUT = 35
# message options
MORE = 1
# send/recv options
DONTWAIT = 1
SNDMORE = 2

################################################################################
## I/O MULTIPLEXING ############################################################
################################################################################

POLLIN = 1
POLLOUT = 2
POLLERR = 4

SOCKET_TYPES = frozenset((
    PAIR, PUB, SUB, REQ, REP, XREQ, XREP, PULL, PUSH, XPUB, XSUB, SURVEYOR,
    RESPONDENT, XSURVEYOR, XRESPONDENT,
))
BINARY_OPTS = frozenset((SUBSCRIBE, UNSUBSCRIBE, IDENTITY))
INT_OPTS = frozenset((
    SNDHWM, RCVHWM, RATE, RECOVERY_IVL, SNDBUF, RCVBUF, LINGER, RECONNECT_IVL,
    RECONNECT_IVL_MAX, BACKLOG, MULTICAST_HOPS, RCVTIMEO, SNDTIMEO, IPV4ONLY,
    KEEPALIVE, SURVEY_TIMEOUT, RCVMORE,
))
INT64_OPTS = ((AFFINITY, MAXMSGSIZE))

from errno import (
    EAGAIN, EFAULT, EINVAL, ENETDOWN, ENOBUFS, ENODEV, ENOMEM, ETIMEDOUT,
    EMFILE)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.