Skip to content

Commit 99253d2

Browse files
shihTianlu Shi
andauthored
Update README.md, update dependency lock and fix one permission issue (#10)
Co-authored-by: Tianlu Shi <[email protected]>
1 parent f39673f commit 99253d2

File tree

3 files changed

+149
-143
lines changed

3 files changed

+149
-143
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
release:
1313
runs-on: ubuntu-latest
1414
permissions:
15-
contents: read
15+
contents: write
1616
id-token: write
1717
steps:
1818
- name: Check out the repository

README.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* **Minimum requirements** -- Python 3.x (or later) and pip
99
* **Download** -- Download the latest preview release or pick it up from pip:
1010
```
11-
under construction
11+
pip install amazon-sns-extended-client
1212
```
1313

1414

@@ -168,7 +168,6 @@ To use custom keys add the S3 key as a Message Attribute in the MessageAttribute
168168

169169
**Key - "S3Key"**
170170
```python
171-
sns = boto3.client('sns')
172171
sns.publish(
173172
Message="message",
174173
MessageAttributes={
@@ -224,7 +223,7 @@ We publish messages to the created Topic and print the published message from th
224223

225224
```python
226225
import boto3
227-
from src.sns_extended_client import SNSExtendedClientSession
226+
from sns_extended_client import SNSExtendedClientSession
228227
from json import loads
229228

230229
s3_extended_payload_bucket = "extended-client-bucket-store" # S3 bucket with the given bucket name is a resource which is created and accessible with the given AWS credentials
@@ -246,7 +245,7 @@ def fetch_and_print_from_sqs(sqs, queue_url):
246245
message = sqs.receive_message(
247246
QueueUrl=queue_url, MessageAttributeNames=["All"], MaxNumberOfMessages=1
248247
).get("Messages")[0]
249-
message_body = loads(message.get("Body")).get("Message")
248+
message_body = message.get("Body")
250249
print("Published Message: {}".format(message_body))
251250
print("Message Stored in S3 Bucket is: {}\n".format(get_msg_from_s3(message_body)))
252251

@@ -262,11 +261,12 @@ demo_queue_arn = sqs.get_queue_attributes(
262261
QueueUrl=demo_queue_url, AttributeNames=["QueueArn"]
263262
)["Attributes"].get("QueueArn")
264263

265-
sns_extended_client.subscribe(
266-
TopicArn=demo_topic_arn, Protocol="sqs", Endpoint=demo_queue_arn
267-
)
268-
264+
# Set the RawMessageDelivery subscription attribute to TRUE if you want to use
265+
# SQSExtendedClient to help with retrieving msg from S3
266+
sns_extended_client.subscribe(TopicArn=demo_topic_arn, Protocol="sqs",
267+
Endpoint=demo_queue_arn, Attributes={"RawMessageDelivery":"true"})
269268

269+
# Below is the example that all the messages will be sent to the S3 bucket
270270
sns_extended_client.large_payload_support = s3_extended_payload_bucket
271271
sns_extended_client.always_through_s3 = True
272272
sns_extended_client.publish(
@@ -275,6 +275,7 @@ sns_extended_client.publish(
275275
print("\n\nPublished using SNS extended client:")
276276
fetch_and_print_from_sqs(sqs, demo_queue_url) # Prints message stored in s3
277277

278+
# Below is the example that all the messages larger than 32 bytes will be sent to the S3 bucket
278279
print("\nUsing decreased message size threshold:")
279280

280281
sns_extended_client.always_through_s3 = False
@@ -287,7 +288,7 @@ sns_extended_client.publish(
287288
fetch_and_print_from_sqs(sqs, demo_queue_url) # Prints message stored in s3
288289

289290

290-
# publish message using the SNS.Topic resource
291+
# Below is the example to publish message using the SNS.Topic resource
291292
sns_extended_client_resource = SNSExtendedClientSession().resource(
292293
"sns", region_name="us-east-1"
293294
)
@@ -326,6 +327,15 @@ Published Message: ["software.amazon.payloadoffloading.PayloadS3Pointer", {"s3Bu
326327
Message Stored in S3 Bucket is: This message should be published to S3 using the topic resource
327328
```
328329

330+
## DEVELOPMENT
331+
332+
We have built-in Makefile to run test, format check or fix in one command. Please check [Makefile](Makefile) for more information.
333+
334+
Just run below command, and it will do format check and run unit test:
335+
```
336+
make ci
337+
```
338+
329339
## Security
330340

331341
See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.

0 commit comments

Comments
 (0)