-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working test for saving outbox entries.
- Loading branch information
1 parent
e93bdad
commit 963014a
Showing
4 changed files
with
58 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,18 @@ | ||
# outbox-core | ||
# outbox-prisma-adapter | ||
|
||
Main package that contains the core functionality of the Outbox pattern to provide "at least once" delivery semantics for messages. | ||
This package provides a Prisma adapter for the Outbox pattern. | ||
|
||
## Installation | ||
### Development | ||
|
||
```bash | ||
npm i -S @message-queue-toolkit/outbox-core | ||
``` | ||
|
||
## Usage | ||
|
||
To process outbox entries and emit them to the message queue, you need to create an instance of the `OutboxPeriodicJob` class: | ||
#### Tests | ||
|
||
```typescript | ||
import { OutboxPeriodicJob } from '@message-queue-toolkit/outbox-core'; | ||
To run the tests, you need to have a PostgreSQL database running. You can use the following command to start a PostgreSQL database using Docker: | ||
|
||
const job = new OutboxPeriodicJob( | ||
//Implementation of OutboxStorage interface, TODO: Point to other packages in message-queue-toolkit | ||
outboxStorage, | ||
//Default available accumulator for gathering outbox entries as the process job is progressing. | ||
new InMemoryOutboxAccumulator(), | ||
//DomainEventEmitter, it will be used to publish events, see @message-queue-toolkit/core | ||
eventEmitter, | ||
//See PeriodicJobDependencies from @lokalise/background-jobs-common | ||
dependencies, | ||
//Retry count, how many times outbox entries should be retried to be processed | ||
3, | ||
//emitBatchSize - how many outbox entries should be emitted at once | ||
10, | ||
//internalInMs - how often the job should be executed, e.g. below it runs every 1sec | ||
1000 | ||
) | ||
```sh | ||
docker-compose up -d | ||
``` | ||
|
||
Job will take care of processing outbox entries emitted by: | ||
```typescript | ||
const emitter = new OutboxEventEmitter( | ||
//Same instance of outbox storage that is used by OutboxPeriodicJob | ||
outboxStorage | ||
) | ||
Then update Prisma client: | ||
```sh | ||
npx prisma generate --schema=./test/schema.prisma | ||
``` |
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