-
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
10 changed files
with
166 additions
and
9 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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from amqp_client_python import EventbusRabbitMQ, Config, Options | ||
from amqp_client_python.event import IntegrationEvent, IntegrationEventHandler | ||
from examples.default import queue, rpc_queue, rpc_exchange | ||
|
||
|
||
# rpc_client call inside rpc_provider | ||
# if __name__ == "__main__": | ||
|
||
try: | ||
config = Config(Options(queue, rpc_queue, rpc_exchange)) | ||
eventbus = EventbusRabbitMQ(config) | ||
|
||
def handle(*body): | ||
print(f"body1: {body}") | ||
return b"response" | ||
|
||
def handle3(*body): | ||
print(body) | ||
|
||
class ExampleEventHandler(IntegrationEventHandler): | ||
event_type = rpc_exchange | ||
|
||
def handle(self, *body) -> None: | ||
print(body) | ||
|
||
class ExampleEvent(IntegrationEvent): | ||
EVENT_NAME: str = "NAME" | ||
|
||
def __init__(self, event_type: str, message=[]) -> None: | ||
super().__init__(self.EVENT_NAME, event_type) | ||
self.message = message | ||
|
||
publish_event = ExampleEvent(rpc_exchange, ["message"]) | ||
event_handle = ExampleEventHandler() | ||
|
||
eventbus.provide_resource("user.find", handle) | ||
eventbus.subscribe(publish_event, event_handle, "user.find3") | ||
count = 0 | ||
running = True | ||
while running: | ||
try: | ||
count += 1 | ||
result = eventbus.rpc_client(rpc_exchange, "user.find", ["content_message"]) | ||
print("returned:", result) | ||
eventbus.publish(publish_event, "user.find3") | ||
except BaseException as err: | ||
running = False | ||
print(f"err: {err}") | ||
except (KeyboardInterrupt, BaseException) as err: | ||
print("err", err) | ||
|
||
eventbus.dispose() |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from amqp_client_python import Config, Options, SSLOptions | ||
from pika import URLParameters | ||
|
||
|
||
def test_url(): | ||
user, passwd, host, port = "user", "passwd", "ipdomain", 1234 | ||
config = Config( | ||
Options( | ||
"example", | ||
"rpc_queue", | ||
"rpc_exchange", | ||
f"amqp://{user}:{passwd}@{host}:{port}/", | ||
) | ||
) | ||
assert config.url is None | ||
config.build() | ||
config.url: URLParameters | ||
assert config.url is not None | ||
assert isinstance(config.url, URLParameters) | ||
assert config.url.host == host | ||
assert config.url.port == port | ||
assert config.url.credentials.username == user | ||
assert config.url.credentials.password == passwd | ||
|
||
|
||
def test_ssl(): | ||
config = Config( | ||
Options("example", "rpc_queue", "rpc_exchange"), | ||
SSLOptions( | ||
"./tests/unit/utils/rabbitmq_cert.pem", | ||
"./tests/unit/utils/rabbitmq_key.pem", | ||
"./tests/unit/utils/ca.pem", | ||
), | ||
) | ||
assert config.ssl_options is not None | ||
config.build() | ||
assert config.url.ssl_options is not None |
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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDLTCCAhWgAwIBAgIUXi+oPVUVWLAtyJaDpl7e+0CzsXQwDQYJKoZIhvcNAQEL | ||
BQAwHjEcMBoGA1UECgwTSEFOSW9ULENOPUhBTklvVCBDQTAeFw0yMzAyMDYxMzAy | ||
NTlaFw0zMzAyMDMxMzAyNTlaMB4xHDAaBgNVBAoME0hBTklvVCxDTj1IQU5Jb1Qg | ||
Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCr89iR6l0olBCBR1/j | ||
Rk96ThvAI8REnnOM1BqJfKtqqHmUsRJK4Ok5iAcn0piPSoq5YebO+E1nPdheePTm | ||
kdrPBiJ4Tcbghhg1HZ15fEKy6NKxLFrEwlVTxZ/VPQlUq8B5w3Sl5+ByQVSSFUkx | ||
fjEA/3GfGNLoLq89YK4hOEVN+kCylFEKReQev0Dxt1Gwoe2jNKw0FrXURWci+cq8 | ||
Dr82gTOR8nVG7NCcQooImJxcSzEGuPkLXiWHGawMzOo+2jfDldw0H+RDnn38W8rg | ||
SyN5ZZmnRZVA7JYqN7Cpsces2RPLr6nxeUDpbfPLEZl1ZoirU3YvAbgCRGdbNAJQ | ||
HThJAgMBAAGjYzBhMB0GA1UdDgQWBBTEaGzMbijWCG7BlmZuqxnpnF4GFDAfBgNV | ||
HSMEGDAWgBTEaGzMbijWCG7BlmZuqxnpnF4GFDAPBgNVHRMBAf8EBTADAQH/MA4G | ||
A1UdDwEB/wQEAwIBxjANBgkqhkiG9w0BAQsFAAOCAQEAaCfnj+nBTLfT4d9552g8 | ||
V2uGKwSwKy79kaVsLBot9BsB5JuKqGWn6OVj03Ml3kqGiV4wXZAZ+QZ+4pMAq1UT | ||
5Zdd9CZZ6YoakO12EEGqCokf+TXU4YasdZls0iTnxlV2kYSR8mVojMHl3aBeVzNW | ||
VSZ00ExnerEwXB1XsyaTPi8YHAKVKbLKDKIarjS89TNRQETKfOCprnhhVpTQ8IwX | ||
ZXj1oKqc8ioke8UhTOcirOmBOoJlLtzBs3fin7FOOUJe9KS6qylfAo8N2h7tgT/z | ||
6GrICdaSokhT9quDALpzy5Dth0Eb2FHApILorHEpgXw0bGY3CZQWPXHeI6av/fzN | ||
3w== | ||
-----END CERTIFICATE----- |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDKzCCAhOgAwIBAgIUHp6PIrZ+VRJaKIKaNNJNtbeYslowDQYJKoZIhvcNAQEL | ||
BQAwHjEcMBoGA1UECgwTSEFOSW9ULENOPUhBTklvVCBDQTAeFw0yMzAyMDYxMzAy | ||
NTlaFw0zMzAyMDMxMzAyNTlaMCoxFzAVBgNVBAoMDmRldmljZS1tYW5hZ2VyMQ8w | ||
DQYDVQQDDAZIQU5Jb1QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA | ||
1EDkW9Ljwy1DsacoGAJNf9pXFr8B4nfnaMeE0uHutuo+PetO2Jgb0kZi9EQhns4k | ||
jliDj7lpNccwzjgI0EVhOBb36nrwBABL3L005GXPryn9vbCMiep8Tfpzl5/VABfq | ||
aKuWGz63NV7iFX3Ey34M3cooGlhqxuIisiI8qq74bDSZZOiMLWtbdIq+uybez8qk | ||
C2C8bo0ntgri/ynVDgpHbrpXY5tQdsne81o+UAsUc1KpbaeNRnBcUxU+wbUxjkHo | ||
LFrapY90DsgzUT0i1RVcFxY0cJXPx1i9iJkfb3ZzEWrUakMIr+e5B0v5AeLDjByN | ||
rTlNb9By9jsnmDBGXbQtAgMBAAGjVTBTMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgWg | ||
MBMGA1UdJQQMMAoGCCsGAQUFBwMCMCQGA1UdEQQdMBuHBH8AAAGCCWxvY2FsaG9z | ||
dIIIcmFiYml0bXEwDQYJKoZIhvcNAQELBQADggEBACtOO6VSjLIiGYxfmodvWPfr | ||
srceRyWESLGmOhYpifxpcAzeoV6nEY4KTg8V7DIgUF73umieJ4S5Gy1yjjoqNvWo | ||
lKoHcl2hUgZI+Z57+44e+tywNcErpjm54T0EZO4hpGqLiEm3CsfRqOgVV32xXPYG | ||
BqwfLKqyB+MsofQWhy72aOXkpdHZ3vHyYxdvj9Dj/2XVNmSTSQksF9Fr1M7Uv7NN | ||
UeLEkUgKp3sYFKifFGXf6M5gLhxqq5htWoI46VhZKWqqbJlFhEUcVzu9OS0NpPTL | ||
thBiipLw1qVroCXSUfJkvXcUtviYElEoTmjBdvZITzo9OTnFQN3r588jXqqq7pA= | ||
-----END CERTIFICATE----- |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEpAIBAAKCAQEAwNRA5FvS48MtQ7GnKBgCTX/aVxa/AeJ352jHhNLh7rbqPj3r | ||
TtiYG9JGYvREIZ7OJI5Yg4+5aTXHMM44CNBFYTgW9+p68AQAS9y9NORlz68p/b2w | ||
jInqfE36c5ef1QAX6mirlhs+tzVe4hV9xMt+DN3KKBpYasbiIrIiPKqu+Gw0mWTo | ||
jC1rW3SKvrsm3s/KpAtgvG6NJ7YK4v8p1Q4KR266V2ObUHbJ3vNaPlALFHNSqW2n | ||
jUZwXFMVPsG1MY5B6Cxa2qWPdA7IM1E9ItUVXBcWNHCVz8dYvYiZH292cxFq1GpD | ||
CK/nuQdL+QHiw4wcja05TW/QcvY7J5gwRl20LQIDAQABAoIBAQCINebY6Jwh038n | ||
8FgZlEwcHpJHLoQieq0kQ/mcM7LxAziYWvjbK1jXXkPmJpHyBdGsNPkFhgL89MYO | ||
Db27TB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