Skip to content

Commit 366db97

Browse files
committed
formatting
1 parent 144c4f9 commit 366db97

File tree

8 files changed

+17
-25
lines changed

8 files changed

+17
-25
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ You can check the [`ssl example`](./examples/tls/tls_example.py) to see how to e
149149

150150
The client supports oauth2 authentication.
151151

152-
You can check the [`oauth2 example`](./examples/oauth/oaut.py) to see how to establish and refresh a connection using an oauth2 token
152+
You can check the [`oauth2 example`](examples/oauth/oAuth2.py) to see how to establish and refresh a connection using an oauth2 token
153153

154154
### Managing disconnections
155155

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Client examples
44
- [Reconnection](./reconnection/reconnection_example.py) - Producer and Consumer example with reconnection
55
- [TLS](./tls/tls_example.py) - Producer and Consumer using a TLS connection
66
- [Streams](./streams/example_with_streams.py) - Example supporting stream capabilities
7-
- [Oauth](./oauth/oauth.py) - Connection through Oauth token
7+
- [Oauth](./oauth/oAuth2.py) - Connection through Oauth token

examples/getting_started/getting_started.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
AddressHelper,
66
AMQPMessagingHandler,
77
Connection,
8-
Converter,
98
Environment,
109
Event,
1110
ExchangeSpecification,
1211
ExchangeToQueueBindingSpecification,
1312
Message,
1413
OutcomeState,
1514
QuorumQueueSpecification,
15+
Converter,
1616
)
1717

1818
MESSAGES_TO_PUBLISH = 100

examples/oauth/oaut.py renamed to examples/oauth/oAuth2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ def create_connection(environment: Environment) -> Connection:
8686

8787

8888
def main() -> None:
89-
exchange_name = "test-exchange"
90-
queue_name = "example-queue"
91-
routing_key = "routing-key"
89+
exchange_name = "oAuth2-test-exchange"
90+
queue_name = "oAuth2-example-queue"
91+
routing_key = "oAuth2-routing-key"
9292

9393
print("connection to amqp server")
9494
oaut_token = token(

examples/streams/example_with_streams.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
OffsetSpecification,
1212
StreamOptions,
1313
StreamSpecification,
14+
Converter,
1415
)
1516

1617
MESSAGES_TO_PUBLISH = 100
@@ -26,7 +27,7 @@ def on_amqp_message(self, event: Event):
2627
# just messages with banana filters get received
2728
print(
2829
"received message from stream: "
29-
+ str(event.message.body)
30+
+ Converter.bytes_to_string(event.message.body)
3031
+ " with offset: "
3132
+ str(event.message.annotations["x-stream-offset"])
3233
)
@@ -118,15 +119,16 @@ def main() -> None:
118119
for i in range(MESSAGES_TO_PUBLISH):
119120
publisher.publish(
120121
Message(
121-
body="apple: " + str(i), annotations={"x-stream-filter-value": "apple"}
122+
Converter.string_to_bytes(body="apple: " + str(i)),
123+
annotations={"x-stream-filter-value": "apple"},
122124
)
123125
)
124126

125127
# publish with a filter of banana
126128
for i in range(MESSAGES_TO_PUBLISH):
127129
publisher.publish(
128130
Message(
129-
body="banana: " + str(i),
131+
body=Converter.string_to_bytes("banana: " + str(i)),
130132
annotations={"x-stream-filter-value": "banana"},
131133
)
132134
)

examples/tls/tls_example.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ def create_connection(environment: Environment) -> Connection:
8181

8282

8383
def main() -> None:
84-
exchange_name = "test-exchange"
85-
queue_name = "example-queue"
86-
routing_key = "routing-key"
84+
exchange_name = "tls-test-exchange"
85+
queue_name = "tls-example-queue"
86+
routing_key = "tls-routing-key"
8787
ca_p12_store = ".ci/certs/ca.p12"
8888
ca_cert_file = ".ci/certs/ca_certificate.pem"
8989
client_cert = ".ci/certs/client_localhost_certificate.pem"

rabbitmq_amqp_python_client/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
RecoveryConfiguration,
1616
StreamOptions,
1717
)
18+
19+
from .utils import Converter
1820
from .environment import Environment
1921
from .exceptions import (
2022
ArgumentOutOfRangeException,
@@ -91,4 +93,5 @@
9193
"ExchangeCustomSpecification",
9294
"RecoveryConfiguration",
9395
"OAuth2Options",
96+
"Converter",
9497
]

rabbitmq_amqp_python_client/utils.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,6 @@ def validate_annotations(annotations: []) -> bool: # type: ignore
99
return validated
1010

1111

12-
def string_to_bytes(body: str) -> bytes:
13-
"""
14-
Convert a string to the body of a message.
15-
16-
Args:
17-
body: The string to convert
18-
19-
Returns:
20-
bytes: The byte representation of the string
21-
"""
22-
return str.encode(body)
23-
24-
2512
class Converter:
2613

2714
@staticmethod

0 commit comments

Comments
 (0)