Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/nodejs-pgsql14.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js(16, 18, 20, 22, 24) w/Postgres 14
name: Node.js(16,18,20,22,24) w/Postgres 14

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nodejs-pgsql15.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js(16, 18, 20, 22, 24) w/Postgres 15
name: Node.js(16,18,20,22,24) w/Postgres 15

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nodejs-pgsql16.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js(16, 18, 20, 22, 24) w/Postgres 16
name: Node.js(16,18,20,22,24) w/Postgres 16

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nodejs-pgsql17.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js(16, 18, 20, 22, 24) w/Postgres 17
name: Node.js(16,18,20,22,24) w/Postgres 17

on:
push:
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/nodejs-pgsql18.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js(16,18,20,22,24) w/Postgres 18

on:
push:
branches: [ "main" ]
pull_request:

permissions:
checks: write
contents: read
pull-requests: write
actions: read

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16, 18, 20, 22, 24]

services:
postgres:
image: kibaes/postgres-logical-replication-dev:18
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgrespw
POSTGRES_DB: playground
ports:
- "5432:5432"

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Info
run: |
echo "Node version: $(node -v)"
echo "NPM version: $(npm -v)"
echo "NPM cache: $(npm config get cache)"
- name: Install/Build
run: |
npm ci
npm run build
- name: Test
run: npm test
- uses: phoenix-actions/test-reporting@v8
if: success() || failure()
id: test-report
with:
name: JEST Tests (${{ matrix.node-version }}, Postgres 18)
path: junit.xml
reporter: jest-junit
token: ${{ secrets.GITHUB_TOKEN }}
100 changes: 49 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
| PostgreSQL 15 | [![Node.js(16, 18, 20, 22, 24) w/Postgres 15](https://github.com/kibae/pg-logical-replication/actions/workflows/nodejs-pgsql15.yml/badge.svg)](https://github.com/kibae/pg-logical-replication/actions/workflows/nodejs-pgsql15.yml) |
| PostgreSQL 16 | [![Node.js(16, 18, 20, 22, 24) w/Postgres 16](https://github.com/kibae/pg-logical-replication/actions/workflows/nodejs-pgsql16.yml/badge.svg)](https://github.com/kibae/pg-logical-replication/actions/workflows/nodejs-pgsql16.yml) |
| PostgreSQL 17 | [![Node.js(16, 18, 20, 22, 24) w/Postgres 17](https://github.com/kibae/pg-logical-replication/actions/workflows/nodejs-pgsql17.yml/badge.svg)](https://github.com/kibae/pg-logical-replication/actions/workflows/nodejs-pgsql17.yml) |
| PostgreSQL 18 | [![Node.js(16, 18, 20, 22, 24) w/Postgres 18](https://github.com/kibae/pg-logical-replication/actions/workflows/nodejs-pgsql18.yml/badge.svg)](https://github.com/kibae/pg-logical-replication/actions/workflows/nodejs-pgsql18.yml) |

## 1. Install

Expand Down Expand Up @@ -97,61 +98,58 @@ service.on('data', (lsn: string, log: Wal2Json.Output) => {
### 3-1. `Constructor(clientConfig: ClientConfig, config?: Partial<LogicalReplicationConfig>)`

```typescript
const service = new LogicalReplicationService(
const service = new LogicalReplicationService({
/**
* node-postgres Client options for connection
* https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/pg/index.d.ts#L16
*/
clientConfig
:
{
user ? : string | undefined;
database ? : string | undefined;
password ? : string | (() => string | Promise<string>) | undefined;
port ? : number | undefined;
host ? : string | undefined;
connectionString ? : string | undefined;
keepAlive ? : boolean | undefined;
stream ? : stream.Duplex | undefined;
statement_timeout ? : false | number | undefined;
parseInputDatesAsUTC ? : boolean | undefined;
ssl ? : boolean | ConnectionOptions | undefined;
query_timeout ? : number | undefined;
keepAliveInitialDelayMillis ? : number | undefined;
idle_in_transaction_session_timeout ? : number | undefined;
application_name ? : string | undefined;
connectionTimeoutMillis ? : number | undefined;
types ? : CustomTypesConfig | undefined;
options ? : string | undefined;
}
,
/**
* Logical replication service config
* https://github.com/kibae/pg-logical-replication/blob/main/src/logical-replication-service.ts#L9
*/
config ? : Partial<{
acknowledge?: {
/**
* If the value is false, acknowledge must be done manually.
* Default: true
*/
auto: boolean;
/**
* Acknowledge is performed every set time (sec). If 0, do not do it.
* Default: 10
*/
timeoutSeconds: 0 | 10 | number;
};
flowControl?: {
/**
* If true, pause the stream until the data handler completes.
* This enables backpressure support for async handlers.
* Default: false
*/
enabled: boolean;
};
}>
)
clientConfig: {
user? : string | undefined;
database? : string | undefined;
password? : string | (() => string | Promise<string>) | undefined;
port? : number | undefined;
host? : string | undefined;
connectionString? : string | undefined;
keepAlive? : boolean | undefined;
stream? : stream.Duplex | undefined;
statement_timeout? : false | number | undefined;
parseInputDatesAsUTC? : boolean | undefined;
ssl? : boolean | ConnectionOptions | undefined;
query_timeout? : number | undefined;
keepAliveInitialDelayMillis? : number | undefined;
idle_in_transaction_session_timeout? : number | undefined;
application_name? : string | undefined;
connectionTimeoutMillis? : number | undefined;
types? : CustomTypesConfig | undefined;
options? : string | undefined;
},
/**
* Logical replication service config
* https://github.com/kibae/pg-logical-replication/blob/main/src/logical-replication-service.ts#L9
*/
config? : Partial<{
acknowledge?: {
/**
* If the value is false, acknowledge must be done manually.
* Default: true
*/
auto: boolean;
/**
* Acknowledge is performed every set time (sec). If 0, do not do it.
* Default: 10
*/
timeoutSeconds: 0 | 10 | number;
};
flowControl?: {
/**
* If true, pause the stream until the data handler completes.
* This enables backpressure support for async handlers.
* Default: false
*/
enabled: boolean;
};
}>
})
```

### 3-2. `subscribe(plugin: AbstractPlugin, slotName: string, uptoLsn?: string): Promise<this>`
Expand Down
6 changes: 6 additions & 0 deletions infra/docker-pg-logical-replication/image/Dockerfile-pgsql18
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM postgres:18

RUN apt update && apt install -y postgresql-18-wal2json postgresql-18-decoderbufs
COPY ["./config-files/postgresql-18.conf", "/etc/postgresql/postgresql.conf"]
COPY ["./docker-entrypoint-initdb.d/*", "/docker-entrypoint-initdb.d/"]

1 change: 1 addition & 0 deletions infra/docker-pg-logical-replication/image/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ docker buildx build -f ./Dockerfile-pgsql14 --platform linux/amd64,linux/arm64/v
docker buildx build -f ./Dockerfile-pgsql15 --platform linux/amd64,linux/arm64/v8 -t kibaes/postgres-logical-replication-dev:15 . --push
docker buildx build -f ./Dockerfile-pgsql16 --platform linux/amd64,linux/arm64/v8 -t kibaes/postgres-logical-replication-dev:16 . --push
docker buildx build -f ./Dockerfile-pgsql17 --platform linux/amd64,linux/arm64/v8 -t kibaes/postgres-logical-replication-dev:17 . --push
docker buildx build -f ./Dockerfile-pgsql18 --platform linux/amd64,linux/arm64/v8 -t kibaes/postgres-logical-replication-dev:18 . --push

Loading
Loading