Skip to content

Commit

Permalink
Merge pull request #22 from openfoodfoundation/feature/sqs
Browse files Browse the repository at this point in the history
Feature: Updated SQS config doco
  • Loading branch information
ok200paul authored Aug 16, 2024
2 parents 7137b68 + 5b65d32 commit 2d8f8e8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ SANCTUM_STATEFUL_DOMAINS=vine.test

BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database
QUEUE_CONNECTION=sync

CACHE_STORE=database
CACHE_PREFIX=
Expand All @@ -63,7 +63,8 @@ AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

SQS_PREFIX=
SQS_QUEUE=


VITE_APP_NAME="${APP_NAME}"
Expand Down
2 changes: 2 additions & 0 deletions .env.testing
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
SQS_PREFIX=
SQS_QUEUE=

VITE_APP_NAME="${APP_NAME}"

18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,27 @@ The S3 bucket uses a configuration called `root`, which separates the base bucke

NOTE: No extra config is required for this behaviour on AWS S3. It is not the default for any other filesystem storage providers.

## Queue Configuration
By default, the queue is set to `sync`: `QUEUE_CONNECTION=sync` which runs jobs as part of the current request. You are free to reconfigure this.

If using AWS SQS, you need to create queues for each environment, and update the env vars as follows:

```dotenv
QUEUE_CONNECTION=sqs
SQS_QUEUE="queue-name-${APP_ENV}" # eg ofn-vine-uk-local as set in AWS SQS
SQS_PREFIX=https://sqs.${AWS_DEFAULT_REGION}.amazonaws.com/[YOUR-AWS-ACCOUNT-ID]
```
You'll also need to run at least one properly configured queue worker on your server environment for this to work.

## API Middleware - Protecting The API

In /bootstrap.app.php we've configured middleware as follows:

```php
$middleware->alias([
'abilities' => CheckForAnyTokenAbilities::class,
]);
$middleware->alias(
[
'abilities' => CheckForAnyTokenAbilities::class,
]);
```

This runs the API middleware through `CheckForAnyTokenAbilities`, checking the incoming personal access token for the
Expand Down

0 comments on commit 2d8f8e8

Please sign in to comment.