Skip to content

Commit

Permalink
Problem: out of date with zproject
Browse files Browse the repository at this point in the history
Solution: regenerate
  • Loading branch information
bluca committed Sep 2, 2017
1 parent 16399cc commit f97357e
Show file tree
Hide file tree
Showing 10 changed files with 475 additions and 4 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
@@ -0,0 +1,19 @@
# This is a skeleton created by zproject.
# You can add hand-written code here.
# See http://editorconfig.org/ and https://github.com/editorconfig/ for
# details about the format and links to plugins for IDEs and editors which
# do not yet support this configuration out of the box - but easily can.

# This is a top-level setting for project sources under this directory
root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
charset = utf-8

[*.am]
indent_style = tab
9 changes: 8 additions & 1 deletion bindings/python_cffi/setup.py
Expand Up @@ -11,6 +11,13 @@
description = """Python cffi bindings of: an open-source framework for proximity-based p2p apps""", description = """Python cffi bindings of: an open-source framework for proximity-based p2p apps""",
packages = ["zyre_cffi", ], packages = ["zyre_cffi", ],
setup_requires=["cffi"], setup_requires=["cffi"],
cffi_modules=["zyre_cffi/build.py:ffibuilder"], cffi_modules=[
"zyre_cffi/build.py:ffibuilder",
"zyre_cffi/build.py:ffidestructorbuilder"
],
install_requires=["cffi"], install_requires=["cffi"],
) )
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################
266 changes: 266 additions & 0 deletions bindings/python_cffi/zyre_cffi/Zyre.py
@@ -0,0 +1,266 @@
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################
from .utils import *
from . import native
from . import destructors
libzyre = native.lib
libzyre_destructors = destructors.lib
ffi = native.ffi

class Zyre(object):
"""
An open-source framework for proximity-based P2P apps
"""

def __init__(self, name):
"""
Constructor, creates a new Zyre node. Note that until you start the
node it is silent and invisible to other nodes on the network.
The node name is provided to other nodes during discovery. If you
specify NULL, Zyre generates a randomized node name from the UUID.
"""
p = libzyre.zyre_new(self._p, to_bytes(name))
if p == ffi.NULL:
raise MemoryError("Could not allocate person")

# ffi.gc returns a copy of the cdata object which will have the
# destructor called when the Python object is GC'd:
# https://cffi.readthedocs.org/en/latest/using.html#ffi-interface
self._p = ffi.gc(p, libzyre_destructors.zyre_destroy_py)

def uuid(self):
"""
Return our node UUID string, after successful initialization
"""
return libzyre.zyre_uuid(self._p)

def name(self):
"""
Return our node name, after successful initialization. First 6
characters of UUID by default.
"""
return libzyre.zyre_name(self._p)

def set_name(self, name):
"""
Set the public name of this node overriding the default. The name is
provide during discovery and come in each ENTER message.
"""
return libzyre.zyre_set_name(self._p, to_bytes(name))

def set_header(self, name, format, ):
"""
Set node header; these are provided to other nodes during discovery
and come in each ENTER message.
"""
return libzyre.zyre_set_header(self._p, to_bytes(name), format, )

def set_verbose(self):
"""
Set verbose mode; this tells the node to log all traffic as well as
all major events.
"""
return libzyre.zyre_set_verbose(self._p)

def set_port(self, port_nbr):
"""
Set UDP beacon discovery port; defaults to 5670, this call overrides
that so you can create independent clusters on the same network, for
e.g. development vs. production. Has no effect after zyre_start().
"""
return libzyre.zyre_set_port(self._p, port_nbr)

def set_evasive_timeout(self, interval):
"""
Set the peer evasiveness timeout, in milliseconds. Default is 5000.
This can be tuned in order to deal with expected network conditions
and the response time expected by the application. This is tied to
the beacon interval and rate of messages received.
"""
return libzyre.zyre_set_evasive_timeout(self._p, interval)

def set_expired_timeout(self, interval):
"""
Set the peer expiration timeout, in milliseconds. Default is 30000.
This can be tuned in order to deal with expected network conditions
and the response time expected by the application. This is tied to
the beacon interval and rate of messages received.
"""
return libzyre.zyre_set_expired_timeout(self._p, interval)

def set_interval(self, interval):
"""
Set UDP beacon discovery interval, in milliseconds. Default is instant
beacon exploration followed by pinging every 1,000 msecs.
"""
return libzyre.zyre_set_interval(self._p, interval)

def set_interface(self, value):
"""
Set network interface for UDP beacons. If you do not set this, CZMQ will
choose an interface for you. On boxes with several interfaces you should
specify which one you want to use, or strange things can happen.
"""
return libzyre.zyre_set_interface(self._p, to_bytes(value))

def set_endpoint(self, format, ):
"""
By default, Zyre binds to an ephemeral TCP port and broadcasts the local
host name using UDP beaconing. When you call this method, Zyre will use
gossip discovery instead of UDP beaconing. You MUST set-up the gossip
service separately using zyre_gossip_bind() and _connect(). Note that the
endpoint MUST be valid for both bind and connect operations. You can use
inproc://, ipc://, or tcp:// transports (for tcp://, use an IP address
that is meaningful to remote as well as local nodes). Returns 0 if
the bind was successful, else -1.
"""
return libzyre.zyre_set_endpoint(self._p, format, )

def gossip_bind(self, format, ):
"""
Set-up gossip discovery of other nodes. At least one node in the cluster
must bind to a well-known gossip endpoint, so other nodes can connect to
it. Note that gossip endpoints are completely distinct from Zyre node
endpoints, and should not overlap (they can use the same transport).
"""
return libzyre.zyre_gossip_bind(self._p, format, )

def gossip_connect(self, format, ):
"""
Set-up gossip discovery of other nodes. A node may connect to multiple
other nodes, for redundancy paths. For details of the gossip network
design, see the CZMQ zgossip class.
"""
return libzyre.zyre_gossip_connect(self._p, format, )

def start(self):
"""
Start node, after setting header values. When you start a node it
begins discovery and connection. Returns 0 if OK, -1 if it wasn't
possible to start the node.
"""
return libzyre.zyre_start(self._p)

def stop(self):
"""
Stop node; this signals to other peers that this node will go away.
This is polite; however you can also just destroy the node without
stopping it.
"""
return libzyre.zyre_stop(self._p)

def join(self, group):
"""
Join a named group; after joining a group you can send messages to
the group and all Zyre nodes in that group will receive them.
"""
return libzyre.zyre_join(self._p, to_bytes(group))

def leave(self, group):
"""
Leave a group
"""
return libzyre.zyre_leave(self._p, to_bytes(group))

def recv(self):
"""
Receive next message from network; the message may be a control
message (ENTER, EXIT, JOIN, LEAVE) or data (WHISPER, SHOUT).
Returns zmsg_t object, or NULL if interrupted
"""
return libzyre.zyre_recv(self._p)

def whisper(self, peer, msg_p):
"""
Send message to single peer, specified as a UUID string
Destroys message after sending
"""
return libzyre.zyre_whisper(self._p, to_bytes(peer), msg_p._p)

def shout(self, group, msg_p):
"""
Send message to a named group
Destroys message after sending
"""
return libzyre.zyre_shout(self._p, to_bytes(group), msg_p._p)

def whispers(self, peer, format, ):
"""
Send formatted string to a single peer specified as UUID string
"""
return libzyre.zyre_whispers(self._p, to_bytes(peer), format, )

def shouts(self, group, format, ):
"""
Send formatted string to a named group
"""
return libzyre.zyre_shouts(self._p, to_bytes(group), format, )

def peers(self):
"""
Return zlist of current peer ids.
"""
return libzyre.zyre_peers(self._p)

def peers_by_group(self, name):
"""
Return zlist of current peers of this group.
"""
return libzyre.zyre_peers_by_group(self._p, to_bytes(name))

def own_groups(self):
"""
Return zlist of currently joined groups.
"""
return libzyre.zyre_own_groups(self._p)

def peer_groups(self):
"""
Return zlist of groups known through connected peers.
"""
return libzyre.zyre_peer_groups(self._p)

def peer_address(self, peer):
"""
Return the endpoint of a connected peer.
"""
return libzyre.zyre_peer_address(self._p, to_bytes(peer))

def peer_header_value(self, peer, name):
"""
Return the value of a header of a conected peer.
Returns null if peer or key doesn't exits.
"""
return libzyre.zyre_peer_header_value(self._p, to_bytes(peer), to_bytes(name))

def socket(self):
"""
Return socket for talking to the Zyre node, for polling
"""
return libzyre.zyre_socket(self._p)

def print(self):
"""
Print zyre node information to stdout
"""
return libzyre.zyre_print(self._p)

def version():
"""
Return the Zyre version for run-time API detection; returns
major * 10000 + minor * 100 + patch, as a single integer.
"""
return libzyre.zyre_version()

def test(verbose):
"""
Self test of this class.
"""
return libzyre.zyre_test(verbose)

################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################

0 comments on commit f97357e

Please sign in to comment.