-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
62 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,10 @@ | ||
from amqp_client_python import ( | ||
EventbusRabbitMQ, | ||
Config, Options | ||
) | ||
from amqp_client_python.event import IntegrationEvent | ||
from amqp_client_python import EventbusWrapperRabbitMQ, Config, Options | ||
from examples.default import queue, rpc_queue, rpc_exchange, rpc_routing_key | ||
|
||
|
||
class ExampleEvent(IntegrationEvent): | ||
EVENT_NAME: str = "ExampleEvent" | ||
def __init__(self, event_type: str, message = []) -> None: | ||
super().__init__(self.EVENT_NAME, event_type) | ||
self.message = message | ||
|
||
|
||
config = Config(Options(queue, rpc_queue, rpc_exchange)) | ||
eventbus = EventbusRabbitMQ(config=config) | ||
eventbus = EventbusWrapperRabbitMQ(config=config) | ||
|
||
|
||
publish_event = ExampleEvent(rpc_exchange, ["message"]) | ||
print(eventbus.publish(publish_event, rpc_routing_key, "direct")) | ||
# run this example with subscribe.py to see the complete cicle of sending and receiving messages. | ||
print(eventbus.publish(rpc_exchange, rpc_routing_key, "direct").result()) | ||
# run this example with subscribe.py to see the complete cicle of sending and receiving messages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
# DEPRECATED EVENTBUS | ||
from amqp_client_python import ( | ||
EventbusRabbitMQ, | ||
Config, Options, | ||
EventbusWrapperRabbitMQ, | ||
Config, | ||
Options, | ||
) | ||
from examples.default import queue, rpc_queue, rpc_exchange, rpc_routing_key | ||
|
||
|
||
config = Config(Options(queue, rpc_queue, rpc_exchange)) | ||
eventbus = EventbusRabbitMQ(config=config) | ||
eventbus = EventbusWrapperRabbitMQ(config=config) | ||
|
||
|
||
print(eventbus.rpc_client(rpc_exchange, rpc_routing_key, ["hello2"])) | ||
# run this example with rpc_subscribe.py to see the complete cicle of sending and receiving messages. | ||
print(eventbus.rpc_client(rpc_exchange, rpc_routing_key, "hello2").result()) | ||
# run this example with rpc_subscribe.py to see the complete cicle of sending and receiving messages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
# DEPRECATED EVENTBUS | ||
from amqp_client_python import ( | ||
EventbusRabbitMQ, | ||
Config, Options | ||
) | ||
from typing import Union | ||
from amqp_client_python import EventbusWrapperRabbitMQ, Config, Options | ||
from examples.default import queue, rpc_queue, rpc_exchange, rpc_routing_key | ||
|
||
|
||
config = Config(Options(queue, rpc_queue, rpc_exchange)) | ||
eventbus = EventbusRabbitMQ(config=config) | ||
eventbus = EventbusWrapperRabbitMQ(config=config) | ||
|
||
def handle(*body): | ||
print(body) | ||
|
||
def handle(body) -> Union[str, bytes]: | ||
print(f"{body}", flush=True) | ||
return b"result" | ||
|
||
eventbus.provide_resource(rpc_routing_key, handle) | ||
# run this example with rpc_publish.py to see the complete cicle of sending and receiving messages. | ||
|
||
|
||
eventbus.provide_resource(rpc_routing_key, handle).result() | ||
# run this example with rpc_publish.py to see the complete cicle of sending and receiving messages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
# DEPRECATED EVENTBUS | ||
from amqp_client_python import ( | ||
EventbusRabbitMQ, | ||
Config, Options, | ||
SSLOptions | ||
) | ||
from examples.default import ( queue, rpc_queue, rpc_exchange, rpc_routing_key, | ||
certfile_path, keyfile_path, ca_certs_path, port | ||
from typing import Union | ||
from amqp_client_python import EventbusWrapperRabbitMQ, Config, Options, SSLOptions | ||
from examples.default import ( | ||
queue, | ||
rpc_queue, | ||
rpc_exchange, | ||
rpc_routing_key, | ||
certfile_path, | ||
keyfile_path, | ||
ca_certs_path, | ||
port, | ||
) | ||
|
||
|
||
config = Config(Options(queue, rpc_queue, rpc_exchange, port=port), SSLOptions(certfile_path, keyfile_path, ca_certs_path)) | ||
eventbus = EventbusRabbitMQ(config=config) | ||
config = Config( | ||
Options(queue, rpc_queue, rpc_exchange, port=port), | ||
SSLOptions(certfile_path, keyfile_path, ca_certs_path), | ||
) | ||
eventbus = EventbusWrapperRabbitMQ(config=config) | ||
|
||
|
||
def handle(body): | ||
print(body) | ||
def handle(body) -> Union[str, bytes]: | ||
print(f"{body}", flush=True) | ||
return "result" | ||
eventbus.provide_resource(rpc_routing_key, handle) | ||
eventbus.start_rpc_server() | ||
|
||
|
||
eventbus.provide_resource(rpc_routing_key, handle).result() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,15 @@ | ||
# DEPRECATED | ||
from amqp_client_python import ( | ||
EventbusRabbitMQ, | ||
Config, Options | ||
) | ||
from amqp_client_python.event import IntegrationEvent, IntegrationEventHandler | ||
from amqp_client_python import EventbusWrapperRabbitMQ, Config, Options | ||
from examples.default import queue, rpc_queue, rpc_exchange, rpc_routing_key | ||
|
||
|
||
class ExampleEvent(IntegrationEvent): | ||
EVENT_NAME: str = "ExampleEvent" | ||
ROUTING_KEY: str = rpc_routing_key | ||
|
||
def __init__(self, event_type: str, message = []) -> None: | ||
super().__init__(self.EVENT_NAME, event_type) | ||
self.message = message | ||
self.routing_key = self.ROUTING_KEY | ||
|
||
|
||
class ExampleEventHandler(IntegrationEventHandler): | ||
def handle(self, body) -> None: | ||
print(body) | ||
config = Config(Options(queue, rpc_queue, rpc_exchange)) | ||
eventbus = EventbusWrapperRabbitMQ(config=config) | ||
|
||
|
||
config = Config(Options(queue, rpc_queue, rpc_exchange)) | ||
eventbus = EventbusRabbitMQ(config=config) | ||
def handler(body) -> None: | ||
print(f"{body}", flush=True) | ||
|
||
def handle(*body): | ||
print(body) | ||
return "result" | ||
|
||
subscribe_event = ExampleEvent(rpc_exchange) | ||
subscribe_event_handle = ExampleEventHandler() | ||
eventbus.subscribe(subscribe_event, subscribe_event_handle, rpc_routing_key) | ||
# run this example with publish.py to see the complete cicle of sending and receiving messages. | ||
eventbus.subscribe(rpc_exchange, rpc_routing_key, handler).result() | ||
# run this example with publish.py to see the complete cicle of sending and receiving messages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters