Skip to content

Commit 1a1a10e

Browse files
authored
Merge pull request #4 from palpalani/develop
Develop
2 parents 58792e3 + a9ac0c2 commit 1a1a10e

15 files changed

+173
-89
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212
/psalm.xml export-ignore
1313
/psalm.xml.dist export-ignore
1414
/testbench.yaml export-ignore
15+
/UPGRADING.md export-ignore
16+
/phpstan.neon.dist export-ignore
17+
/phpstan-baseline.neon export-ignore

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ updates:
1111
- package-ecosystem: composer
1212
directory: "/"
1313
schedule:
14-
interval: monthly
14+
interval: "weekly"
1515
labels:
1616
- dependencies
1717
versioning-strategy: increase-if-necessary
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: dependabot-auto-merge
2+
on: pull_request_target
3+
4+
permissions:
5+
pull-requests: write
6+
contents: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.actor == 'dependabot[bot]' }}
12+
steps:
13+
14+
- name: Dependabot metadata
15+
id: metadata
16+
uses: dependabot/fetch-metadata@v1.3.3
17+
with:
18+
github-token: "${{ secrets.GITHUB_TOKEN }}"
19+
20+
- name: Auto-merge Dependabot PRs for semver-minor updates
21+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
22+
run: gh pr merge --auto --merge "$PR_URL"
23+
env:
24+
PR_URL: ${{github.event.pull_request.html_url}}
25+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
26+
27+
- name: Auto-merge Dependabot PRs for semver-patch updates
28+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
29+
run: gh pr merge --auto --merge "$PR_URL"
30+
env:
31+
PR_URL: ${{github.event.pull_request.html_url}}
32+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: Check & fix styling
1+
name: Fix PHP code style issues
22

33
on: [push]
44

55
jobs:
6-
php-cs-fixer:
6+
php-code-styling:
77
runs-on: ubuntu-latest
88

99
steps:
@@ -12,12 +12,13 @@ jobs:
1212
with:
1313
ref: ${{ github.head_ref }}
1414

15-
- name: Run PHP CS Fixer
16-
uses: docker://oskarstark/php-cs-fixer-ga
15+
- name: Fix PHP code style issues
16+
uses: aglipanci/laravel-pint-action@1.0.0
1717
with:
18-
args: --config=.php-cs-fixer.dist.php --allow-risky=yes
18+
preset: laravel
1919

2020
- name: Commit changes
2121
uses: stefanzweifel/git-auto-commit-action@v4
2222
with:
2323
commit_message: Fix styling
24+
skip_fetch: true
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Update Changelog"
2+
3+
on:
4+
release:
5+
types: [released]
6+
7+
jobs:
8+
update:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
with:
15+
ref: main
16+
17+
- name: Update Changelog
18+
uses: stefanzweifel/changelog-updater-action@v1
19+
with:
20+
latest-version: ${{ github.event.release.name }}
21+
release-notes: ${{ github.event.release.body }}
22+
23+
- name: Commit updated CHANGELOG
24+
uses: stefanzweifel/git-auto-commit-action@v4
25+
with:
26+
branch: main
27+
commit_message: Update CHANGELOG
28+
file_pattern: CHANGELOG.md

.php-cs-fixer.dist.php

Lines changed: 0 additions & 41 deletions
This file was deleted.

README.md

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
[![Total Downloads](https://img.shields.io/packagist/dt/palpalani/laravel-sqs-queue-json-reader.svg?style=flat-square)](https://packagist.org/packages/palpalani/laravel-sqs-queue-json-reader)
77

88

9-
Custom SQS queue reader for Laravel projects that supports raw JSON payloads.
10-
Laravel expects SQS messages to be generated in a
9+
Custom SQS queue reader for Laravel projects that supports raw JSON payloads and reads multiple messages. Laravel expects SQS messages to be generated in a
1110
specific format that includes job handler class and a serialized job.
1211

1312
Note: Implemented to read multiple messages from queue.
1413

15-
But in certain cases you may want to parse messages from 3rd party
16-
applications, custom JSON messages and so on.
14+
This library is very useful when you want to parse messages from 3rd party
15+
applications such as stripe webhooks, shopify webhooks, mailgun web hooks, custom JSON messages and so on.
1716

1817
## Installation
1918

@@ -44,7 +43,7 @@ return [
4443
],
4544
'mailgun-webhooks' => [
4645
'class' => App\Jobs\MailgunHandler::class,
47-
'count' => 100,
46+
'count' => 10,
4847
]
4948
],
5049

@@ -71,8 +70,8 @@ Add `sqs-json` connection to your config/queue.php, Ex:
7170
'driver' => 'sqs-json',
7271
'key' => env('AWS_ACCESS_KEY_ID', ''),
7372
'secret' => env('AWS_SECRET_ACCESS_KEY', ''),
74-
'prefix' => env('SQS_PREFIX', 'https://sqs.us-west-2.amazonaws.com/1234567890'),
75-
'queue' => env('SQS_QUEUE', 'stripe-webhooks'),
73+
'prefix' => env('AWS_SQS_PREFIX', 'https://sqs.us-west-2.amazonaws.com/1234567890'),
74+
'queue' => env('AWS_SQS_QUEUE', 'external-webhooks'),
7675
'region' => env('AWS_DEFAULT_REGION', 'us-west-2'),
7776
],
7877
]
@@ -97,7 +96,7 @@ class ExampleController extends Controller
9796
{
9897
// Dispatch job with some data.
9998
$job = new DispatcherJob([
100-
'music' => 'Sample SQS message',
99+
'music' => 'Ponni nathi from PS-1',
101100
'singer' => 'AR. Rahman',
102101
'time' => time()
103102
]);
@@ -120,6 +119,31 @@ Above code will push the following JSON object to SQS queue:
120119
'job' field is not used, actually. It's just kept for compatibility with Laravel
121120
Framework.
122121

122+
### Processing job
123+
124+
Run the following commnd for testing the dispatched job.
125+
126+
`php artisan queue:work sqs-json`
127+
128+
For production, use supervisor with the following configuration.
129+
130+
```
131+
[program:sqs-json-reader]
132+
process_name=%(program_name)s_%(process_num)02d
133+
command=php /var/html/app/artisan queue:work sqs-json --sleep=30 --timeout=50 --tries=2 --memory=128 --daemon
134+
directory=/var/html/app
135+
autostart=true
136+
autorestart=true
137+
startretries=10
138+
user=root
139+
numprocs=1
140+
redirect_stderr=true
141+
stdout_logfile=/var/html/app/horizon.log
142+
stderr_logfile=/tmp/horizon-error.log
143+
stopwaitsecs=3600
144+
priority=1000
145+
```
146+
123147
### Receiving from SQS
124148

125149
If a 3rd-party application or API Gateway to SQS implementation is creating
@@ -151,8 +175,12 @@ class SqsHandlerJob extends Job
151175
}
152176
```
153177

178+
For more information about AWS SQS check [offical docs](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-queue-parameters.html).
179+
154180
## Testing
155181

182+
We already configured the script, just run the command:
183+
156184
```bash
157185
composer test
158186
```
@@ -165,6 +193,16 @@ Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed re
165193

166194
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
167195

196+
## Other Laravel packages
197+
198+
[GrumPHP rector task](https://github.com/palpalani/grumphp-rector-task) GrumPHP with a task that runs RectorPHP for your Laravel projects.
199+
[Email Deny List (blacklist) Check - IP Deny List (blacklist) Check](https://github.com/palpalani/laravel-dns-deny-list-check) Deny list (blacklist) checker will test a mail server IP address against over 50 DNS based email blacklists. (Commonly called Realtime blacklist, DNSBL or RBL).
200+
[Spamassassin spam score of emails](https://github.com/palpalani/laravel-spamassassin-score) Checks the spam score of email contents using spamassassin database.
201+
[Laravel Login Notifications](https://github.com/palpalani/laravel-login-notifications) A login event notification for Laravel projects. By default, it will send notification only on production environment only.
202+
[Laravel Toastr](https://github.com/palpalani/laravel-toastr) Implements toastr.js for Laravel. Toastr.js is a Javascript library for non-blocking notifications.
203+
[Beast](https://github.com/palpalani/beast) Beast is Screenshot as a Service using Nodejs, Chrome and Aws Lamda. Convert a webpage to an image using headless Chrome Takes screenshot of any given URL/Html content and returns base64 encoded buffer.
204+
[eCommerce Product Recommendations](https://github.com/palpalani/eCommerce-Product-Recommendations) Analyse order history of customers and recommend products for new customers which enables higher sales volume.
205+
168206
## Security Vulnerabilities
169207

170208
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

composer.json

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
"palpalani",
66
"sqs-reader",
77
"sqs-json",
8-
"plain-message",
9-
"bulk-message",
8+
"sqs-text-reader",
9+
"sqs-plain-message",
10+
"sqs-bulk-message",
11+
"laravel-sqs",
1012
"laravel-sqs-queue-json-reader"
1113
],
1214
"homepage": "https://github.com/palpalani/laravel-sqs-queue-json-reader",
@@ -15,7 +17,7 @@
1517
{
1618
"name": "palPalani",
1719
"email": "palani.p@gmail.com",
18-
"homepage": "https://southdreamz.com",
20+
"homepage": "https://github.com/palpalani",
1921
"role": "Developer"
2022
}
2123
],
@@ -28,10 +30,13 @@
2830
"aws/aws-sdk-php": "^3.0"
2931
},
3032
"require-dev": {
33+
"laravel/pint": "^1.1",
34+
"nunomaduro/collision": "^6.2",
35+
"nunomaduro/larastan": "^2.1",
3136
"orchestra/testbench": "^6.9|^7.0",
32-
"phpunit/phpunit": "^9.3",
33-
"psalm/plugin-laravel": "^2.0",
34-
"vimeo/psalm": "^4.4"
37+
"phpstan/extension-installer": "^1.1",
38+
"phpstan/phpstan-deprecation-rules": "^1.0",
39+
"phpunit/phpunit": "^9.3"
3540
},
3641
"autoload": {
3742
"psr-4": {
@@ -44,12 +49,16 @@
4449
}
4550
},
4651
"scripts": {
47-
"psalm": "vendor/bin/psalm",
52+
"analyse": "vendor/bin/phpstan analyse",
4853
"test": "./vendor/bin/testbench package:test --parallel --no-coverage",
49-
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
54+
"test-coverage": "vendor/bin/phpunit --coverage-html coverage",
55+
"format": "vendor/bin/pint"
5056
},
5157
"config": {
52-
"sort-packages": true
58+
"sort-packages": true,
59+
"allow-plugins": {
60+
"phpstan/extension-installer": true
61+
}
5362
},
5463
"extra": {
5564
"laravel": {

config/sqs-queue-reader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
'mailgun-webhooks' => [
1515
'class' => App\Jobs\MailgunHandler::class,
1616
'count' => 100,
17-
]
17+
],
1818
],
1919

2020
// If no handlers specified then default handler will be executed.
@@ -25,5 +25,5 @@
2525

2626
// Number of messages need to read from SQS.
2727
'count' => 1,
28-
]
28+
],
2929
];

phpstan-baseline.neon

Whitespace-only changes.

0 commit comments

Comments
 (0)