Vertx EventBus Client
Project description
TCP-eventbus-client-Python
This is a TCP eventbus implementation for python clients.
example:
from vertx import EventBus
ebus = EventBus('localhost', 7000)
# Define a handler to handle message
def handler(msg):
print("Got message from server: %s" % msg)
# Connects to target bridge, it will connect automatically
ebus.connect()
# register a handler on address `test`
ebus.register_handler("test", handler)
# send a json message to address: `test`, the handler will be called
ebus.send("test", body={'name': 'python'})
# You can also send a message, and specify the reply_address
ebus.send("echo", reply_address="test", body={'desc': 'send to echo, reply to test'})
# publish message
ebus.publish("publish-address", body={'name': 'python'})
# unregister the handler after everything is done
ebus.unregister_handler("test")
# close the EventBus to release resources, after closed, it cannot be used anymore
ebus.close()
Options
The options supported when creating the EventBus are:
timeout- the socket timeout, in seconds, defaults to60seconds.connection_timeout- connection timeout, in seconds, defaults to600seconds.retry_interval- retry interval on connection, in seconds, defaults to5seconds.ping_interval- heart beat for ping/pong, in seconds, defaults to5seconds.reply_timeout- message reply timeout, in seconds, defaults to60seconds.auto_connect- if client should connect to server automatically if it is not connected yet, or on failures, defaults toTrue.ssl_options- thesslrelated options, please refer to SSL Options below.
TLS support
This client supports TLS connection, you need to either specify the ssl_options or a ssl.SSLContext:
from vertx import EventBus
# for no ClientAuth required, just specify the ca_file:
ebus = EventBus(options={"ssl_options": {"ca_file": "/path/to/ca.crt"}})
# you can also specify the ca_path(directory of the certs) or ca_data:
ebus = EventBus(options={"ssl_options": {"ca_path": "/path/to/certs/"}})
ebus = EventBus(options={"ssl_options": {"ca_data": "my_cert_data"}})
# for ClientAuth, specify cert_file and key_file:
ebus = EventBus(options={"ssl_options": {"ca_file": "/path/to/ca.crt", "cert_file": "/path/to/client.crt"},
"key_file": "/path/to/client.key"})
# You can also specify a SSLContext directly if you have one already:
my_content = create_ssl_context()
ebus = EventBus(host="localhost", port=7000, ssl_context=my_context)
SSL Options
The SSL options supported by this client are:
ca_file- The CA certificate file which is used to verity the server.ca_path- The directory where the CA certificates are.ca_data- The CA certificate data which is used to verify the server.ciphers- The ciphers client wants to use on ssl handshake.check_hostname- Should check hostname or not. When any ofca_*is specified, it isTrueif it is not specified.verify_mode- Verify mode when doing handshake. When any ofca_*is specified, it isssl.CERT_REQUIREDif it is not specified.cert_file- The client certificate file in ClientAuth case.key_file- The client key file in ClientAuth case.key_password- The password of client key file in ClientAuth case.
Build and install locally
# build the package
./build.sh --dist
# With the tar file you can install it anywhere
pip install dist/vertx-eventbus-client*.tar.gz
# Install from PyPI:
pip install vertx-eventbus-client
Build and Deploy to PyPi:
- Update the version in the
setup.py:
# change this value to the desired version, like: 1.0.0
version="1.0.0.dev0"
- Use the following command to build and publish to PyPi:
./build.sh --publish
then you will be asked for username and password like:
Publish the package to Pypi.org
Uploading distributions to https://upload.pypi.org/legacy/
Enter your username:
NOTE: You need to have
twineinstalled in your machine to be able to publish.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file vertx-eventbus-client-1.0.0.tar.gz.
File metadata
- Download URL: vertx-eventbus-client-1.0.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78914bff3589aaf1a9c6e6f8739ad8c9c1c58a9864c6637e2143525c3f80dedb
|
|
| MD5 |
510c060462cfe4e9579f6c9595af5c4f
|
|
| BLAKE2b-256 |
5b8e3e4f40cb214aa8a2f1deb20e9bac2a86b51c6b009ad83cf0ac8a99d3cc48
|