@flowcore/pathways 0.15.3 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.16.0](https://github.com/flowcore-io/flowcore-pathways/compare/v0.15.3...v0.16.0) (2025-06-03)
4
+
5
+
6
+ ### Features
7
+
8
+ * **postgres:** :sparkles: add connection pool configuration options for PostgreSQL ([9ba9966](https://github.com/flowcore-io/flowcore-pathways/commit/9ba9966706c13bba441ef8538a0ecfe405191307))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **postgres:** :art: clean up whitespace in postgres-adapter.ts ([d16e0a9](https://github.com/flowcore-io/flowcore-pathways/commit/d16e0a9dfc0b02e533143dfcc5fe34e57bf22cea))
14
+ * **postgres:** :art: update PostgresJsOptions interface for better type safety ([0fee92e](https://github.com/flowcore-io/flowcore-pathways/commit/0fee92eaad3ceb9a387cb6cee9d3029a254b8c15))
15
+
3
16
  ## [0.15.3](https://github.com/flowcore-io/flowcore-pathways/compare/v0.15.2...v0.15.3) (2025-06-03)
4
17
 
5
18
 
@@ -1,3 +1,16 @@
1
+ /**
2
+ * Connection pool configuration options for PostgreSQL
3
+ */
4
+ export interface PostgresPoolConfig {
5
+ /** Maximum number of connections in the pool (default: 10) */
6
+ max?: number;
7
+ /** Maximum lifetime in seconds for connections (default: random between 45-90 minutes) */
8
+ max_lifetime?: number;
9
+ /** Idle connection timeout in seconds (default: 0 - no timeout) */
10
+ idle_timeout?: number;
11
+ /** Connect timeout in seconds (default: 30) */
12
+ connect_timeout?: number;
13
+ }
1
14
  /**
2
15
  * Configuration for PostgreSQL connection using a connection string
3
16
  */
@@ -11,6 +24,8 @@ export interface PostgresConnectionStringConfig {
11
24
  password?: never;
12
25
  database?: never;
13
26
  ssl?: never;
27
+ /** Connection pool configuration */
28
+ pool?: PostgresPoolConfig;
14
29
  }
15
30
  /**
16
31
  * Configuration for PostgreSQL connection using individual parameters
@@ -30,6 +45,8 @@ export interface PostgresParametersConfig {
30
45
  database: string;
31
46
  /** Whether to use SSL for the connection */
32
47
  ssl?: boolean;
48
+ /** Connection pool configuration */
49
+ pool?: PostgresPoolConfig;
33
50
  }
34
51
  /**
35
52
  * Configuration options for PostgreSQL connection
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-adapter.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/postgres-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,gHAAgH;IAChH,gBAAgB,EAAE,MAAM,CAAA;IAExB,yEAAyE;IACzE,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,GAAG,CAAC,EAAE,KAAK,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,KAAK,CAAA;IAExB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAA;IAChB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,4CAA4C;IAC5C,GAAG,CAAC,EAAE,OAAO,CAAA;CACd;AAED;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,8BAA8B,GAAG,wBAAwB,CAAA;AAEtF;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IAExB;;;OAGG;IACH,UAAU,IAAI,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CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IAErD;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACxD;AAoBD;;GAEG;AACH,qBAAa,iBAAkB,YAAW,eAAe;IACvD,8CAA8C;IAC9C,OAAO,CAAC,QAAQ,CAA2F;IAC3G,oCAAoC;IACpC,OAAO,CAAC,GAAG,CAA8B;IACzC,mCAAmC;IACnC,OAAO,CAAC,MAAM,CAAgB;IAC9B,yDAAyD;IACzD,OAAO,CAAC,gBAAgB,CAAQ;IAEhC;;;;OAIG;gBACS,MAAM,EAAE,cAAc;IAgBlC;;;;;OAKG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA8B9B;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAOjC;;;;;;OAMG;IACG,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAO/D;;;;;OAKG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAMlE;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAI5F"}
@@ -60,7 +60,23 @@ export class PostgresJsAdapter {
60
60
  try {
61
61
  const module = await import("postgres");
62
62
  this.postgres = module.default;
63
- this.sql = this.postgres(this.connectionString);
63
+ // Build postgres.js options from pool configuration
64
+ const postgresOptions = {};
65
+ if (this.config.pool) {
66
+ if (this.config.pool.max !== undefined) {
67
+ postgresOptions.max = this.config.pool.max;
68
+ }
69
+ if (this.config.pool.max_lifetime !== undefined) {
70
+ postgresOptions.max_lifetime = this.config.pool.max_lifetime;
71
+ }
72
+ if (this.config.pool.idle_timeout !== undefined) {
73
+ postgresOptions.idle_timeout = this.config.pool.idle_timeout;
74
+ }
75
+ if (this.config.pool.connect_timeout !== undefined) {
76
+ postgresOptions.connect_timeout = this.config.pool.connect_timeout;
77
+ }
78
+ }
79
+ this.sql = this.postgres(this.connectionString, postgresOptions);
64
80
  }
65
81
  catch (error) {
66
82
  console.error("Failed to connect to PostgreSQL:", error);
@@ -1,4 +1,5 @@
1
1
  import type { PathwayState } from "../types.js";
2
+ import type { PostgresPoolConfig } from "./postgres-adapter.js";
2
3
  /**
3
4
  * Configuration for PostgreSQL pathway state storage using a connection string
4
5
  */
@@ -16,6 +17,8 @@ export interface PostgresPathwayStateConnectionStringConfig {
16
17
  tableName?: string;
17
18
  /** Time-to-live in milliseconds for processed events (default: 5 minutes) */
18
19
  ttlMs?: number;
20
+ /** Connection pool configuration */
21
+ pool?: PostgresPoolConfig;
19
22
  }
20
23
  /**
21
24
  * Configuration for PostgreSQL pathway state storage using individual parameters
@@ -39,6 +42,8 @@ export interface PostgresPathwayStateParametersConfig {
39
42
  tableName?: string;
40
43
  /** Time-to-live in milliseconds for processed events (default: 5 minutes) */
41
44
  ttlMs?: number;
45
+ /** Connection pool configuration */
46
+ pool?: PostgresPoolConfig;
42
47
  }
43
48
  /**
44
49
  * Configuration options for PostgreSQL pathway state storage
@@ -74,7 +79,13 @@ export type PostgresPathwayStateConfig = PostgresPathwayStateConnectionStringCon
74
79
  * const postgresState = createPostgresPathwayState({
75
80
  * connectionString: "postgres://user:password@localhost:5432/mydb",
76
81
  * tableName: "event_processing_state", // Optional
77
- * ttlMs: 24 * 60 * 60 * 1000 // 24 hours (optional)
82
+ * ttlMs: 24 * 60 * 60 * 1000, // 24 hours (optional)
83
+ * pool: { // Optional connection pool configuration
84
+ * max: 20, // Maximum 20 connections in pool
85
+ * idle_timeout: 30, // Close idle connections after 30 seconds
86
+ * connect_timeout: 10, // 10 second connection timeout
87
+ * max_lifetime: 3600 // Connections live maximum 1 hour
88
+ * }
78
89
  * });
79
90
  *
80
91
  * // Or with individual parameters
@@ -86,7 +97,12 @@ export type PostgresPathwayStateConfig = PostgresPathwayStateConnectionStringCon
86
97
  * database: "mydb",
87
98
  * ssl: false,
88
99
  * tableName: "event_processing_state", // Optional
89
- * ttlMs: 30 * 60 * 1000 // 30 minutes (optional)
100
+ * ttlMs: 30 * 60 * 1000, // 30 minutes (optional)
101
+ * pool: { // Optional connection pool configuration
102
+ * max: 15, // Maximum 15 connections in pool
103
+ * idle_timeout: 60, // Close idle connections after 60 seconds
104
+ * connect_timeout: 5 // 5 second connection timeout
105
+ * }
90
106
  * });
91
107
  *
92
108
  * // Use with PathwaysBuilder
@@ -257,6 +273,17 @@ export declare class PostgresPathwayState implements PathwayState {
257
273
  * ttlMs: 7 * 24 * 60 * 60 * 1000 // 1 week
258
274
  * });
259
275
  *
276
+ * // With connection pool configuration
277
+ * const state = createPostgresPathwayState({
278
+ * connectionString: "postgres://user:pass@localhost:5432/db",
279
+ * pool: {
280
+ * max: 25, // Maximum 25 connections
281
+ * idle_timeout: 120, // Close idle connections after 2 minutes
282
+ * connect_timeout: 15, // 15 second connection timeout
283
+ * max_lifetime: 1800 // Connections live maximum 30 minutes
284
+ * }
285
+ * });
286
+ *
260
287
  * // Use with PathwaysBuilder
261
288
  * const pathways = new PathwaysBuilder({
262
289
  * // Other config
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-pathway-state.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/postgres-pathway-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI/C;;GAEG;AACH,MAAM,WAAW,0CAA0C;IACzD,gHAAgH;IAChH,gBAAgB,EAAE,MAAM,CAAA;IAExB,yEAAyE;IACzE,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,IAAI,CAAC,EAAE,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;;;OA2BG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBlD;;;;;OAKG;YACW,cAAc;IAQ5B;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAK7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,0BAA0B,GAAG,oBAAoB,CAGnG"}
@@ -25,7 +25,13 @@ import { createPostgresAdapter } from "./postgres-adapter.js";
25
25
  * const postgresState = createPostgresPathwayState({
26
26
  * connectionString: "postgres://user:password@localhost:5432/mydb",
27
27
  * tableName: "event_processing_state", // Optional
28
- * ttlMs: 24 * 60 * 60 * 1000 // 24 hours (optional)
28
+ * ttlMs: 24 * 60 * 60 * 1000, // 24 hours (optional)
29
+ * pool: { // Optional connection pool configuration
30
+ * max: 20, // Maximum 20 connections in pool
31
+ * idle_timeout: 30, // Close idle connections after 30 seconds
32
+ * connect_timeout: 10, // 10 second connection timeout
33
+ * max_lifetime: 3600 // Connections live maximum 1 hour
34
+ * }
29
35
  * });
30
36
  *
31
37
  * // Or with individual parameters
@@ -37,7 +43,12 @@ import { createPostgresAdapter } from "./postgres-adapter.js";
37
43
  * database: "mydb",
38
44
  * ssl: false,
39
45
  * tableName: "event_processing_state", // Optional
40
- * ttlMs: 30 * 60 * 1000 // 30 minutes (optional)
46
+ * ttlMs: 30 * 60 * 1000, // 30 minutes (optional)
47
+ * pool: { // Optional connection pool configuration
48
+ * max: 15, // Maximum 15 connections in pool
49
+ * idle_timeout: 60, // Close idle connections after 60 seconds
50
+ * connect_timeout: 5 // 5 second connection timeout
51
+ * }
41
52
  * });
42
53
  *
43
54
  * // Use with PathwaysBuilder
@@ -118,6 +129,7 @@ export class PostgresPathwayState {
118
129
  // Use connection string if provided
119
130
  this.postgres = await createPostgresAdapter({
120
131
  connectionString: this.config.connectionString,
132
+ pool: this.config.pool,
121
133
  });
122
134
  }
123
135
  else {
@@ -130,6 +142,7 @@ export class PostgresPathwayState {
130
142
  password: this.config.password,
131
143
  database: this.config.database,
132
144
  ssl: this.config.ssl,
145
+ pool: this.config.pool,
133
146
  });
134
147
  }
135
148
  // Check if the table exists
@@ -325,6 +338,17 @@ Object.defineProperty(PostgresPathwayState, "DEFAULT_TABLE_NAME", {
325
338
  * ttlMs: 7 * 24 * 60 * 60 * 1000 // 1 week
326
339
  * });
327
340
  *
341
+ * // With connection pool configuration
342
+ * const state = createPostgresPathwayState({
343
+ * connectionString: "postgres://user:pass@localhost:5432/db",
344
+ * pool: {
345
+ * max: 25, // Maximum 25 connections
346
+ * idle_timeout: 120, // Close idle connections after 2 minutes
347
+ * connect_timeout: 15, // 15 second connection timeout
348
+ * max_lifetime: 1800 // Connections live maximum 30 minutes
349
+ * }
350
+ * });
351
+ *
328
352
  * // Use with PathwaysBuilder
329
353
  * const pathways = new PathwaysBuilder({
330
354
  * // Other config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowcore/pathways",
3
- "version": "0.15.3",
3
+ "version": "0.16.0",
4
4
  "description": "A TypeScript Library for creating Flowcore Pathways, simplifying the integration with the flowcore platform",
5
5
  "homepage": "https://github.com/flowcore-io/flowcore-pathways#readme",
6
6
  "repository": {
@@ -1,3 +1,16 @@
1
+ /**
2
+ * Connection pool configuration options for PostgreSQL
3
+ */
4
+ export interface PostgresPoolConfig {
5
+ /** Maximum number of connections in the pool (default: 10) */
6
+ max?: number;
7
+ /** Maximum lifetime in seconds for connections (default: random between 45-90 minutes) */
8
+ max_lifetime?: number;
9
+ /** Idle connection timeout in seconds (default: 0 - no timeout) */
10
+ idle_timeout?: number;
11
+ /** Connect timeout in seconds (default: 30) */
12
+ connect_timeout?: number;
13
+ }
1
14
  /**
2
15
  * Configuration for PostgreSQL connection using a connection string
3
16
  */
@@ -11,6 +24,8 @@ export interface PostgresConnectionStringConfig {
11
24
  password?: never;
12
25
  database?: never;
13
26
  ssl?: never;
27
+ /** Connection pool configuration */
28
+ pool?: PostgresPoolConfig;
14
29
  }
15
30
  /**
16
31
  * Configuration for PostgreSQL connection using individual parameters
@@ -30,6 +45,8 @@ export interface PostgresParametersConfig {
30
45
  database: string;
31
46
  /** Whether to use SSL for the connection */
32
47
  ssl?: boolean;
48
+ /** Connection pool configuration */
49
+ pool?: PostgresPoolConfig;
33
50
  }
34
51
  /**
35
52
  * Configuration options for PostgreSQL connection
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-adapter.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/postgres-adapter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,gHAAgH;IAChH,gBAAgB,EAAE,MAAM,CAAA;IAExB,yEAAyE;IACzE,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,IAAI,CAAC,EAAE,KAAK,CAAA;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,GAAG,CAAC,EAAE,KAAK,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,KAAK,CAAA;IAExB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAA;IAChB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,4CAA4C;IAC5C,GAAG,CAAC,EAAE,OAAO,CA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
87
87
  try {
88
88
  const module = await Promise.resolve().then(() => __importStar(require("postgres")));
89
89
  this.postgres = module.default;
90
- this.sql = this.postgres(this.connectionString);
90
+ // Build postgres.js options from pool configuration
91
+ const postgresOptions = {};
92
+ if (this.config.pool) {
93
+ if (this.config.pool.max !== undefined) {
94
+ postgresOptions.max = this.config.pool.max;
95
+ }
96
+ if (this.config.pool.max_lifetime !== undefined) {
97
+ postgresOptions.max_lifetime = this.config.pool.max_lifetime;
98
+ }
99
+ if (this.config.pool.idle_timeout !== undefined) {
100
+ postgresOptions.idle_timeout = this.config.pool.idle_timeout;
101
+ }
102
+ if (this.config.pool.connect_timeout !== undefined) {
103
+ postgresOptions.connect_timeout = this.config.pool.connect_timeout;
104
+ }
105
+ }
106
+ this.sql = this.postgres(this.connectionString, postgresOptions);
91
107
  }
92
108
  catch (error) {
93
109
  console.error("Failed to connect to PostgreSQL:", error);
@@ -1,4 +1,5 @@
1
1
  import type { PathwayState } from "../types.js";
2
+ import type { PostgresPoolConfig } from "./postgres-adapter.js";
2
3
  /**
3
4
  * Configuration for PostgreSQL pathway state storage using a connection string
4
5
  */
@@ -16,6 +17,8 @@ export interface PostgresPathwayStateConnectionStringConfig {
16
17
  tableName?: string;
17
18
  /** Time-to-live in milliseconds for processed events (default: 5 minutes) */
18
19
  ttlMs?: number;
20
+ /** Connection pool configuration */
21
+ pool?: PostgresPoolConfig;
19
22
  }
20
23
  /**
21
24
  * Configuration for PostgreSQL pathway state storage using individual parameters
@@ -39,6 +42,8 @@ export interface PostgresPathwayStateParametersConfig {
39
42
  tableName?: string;
40
43
  /** Time-to-live in milliseconds for processed events (default: 5 minutes) */
41
44
  ttlMs?: number;
45
+ /** Connection pool configuration */
46
+ pool?: PostgresPoolConfig;
42
47
  }
43
48
  /**
44
49
  * Configuration options for PostgreSQL pathway state storage
@@ -74,7 +79,13 @@ export type PostgresPathwayStateConfig = PostgresPathwayStateConnectionStringCon
74
79
  * const postgresState = createPostgresPathwayState({
75
80
  * connectionString: "postgres://user:password@localhost:5432/mydb",
76
81
  * tableName: "event_processing_state", // Optional
77
- * ttlMs: 24 * 60 * 60 * 1000 // 24 hours (optional)
82
+ * ttlMs: 24 * 60 * 60 * 1000, // 24 hours (optional)
83
+ * pool: { // Optional connection pool configuration
84
+ * max: 20, // Maximum 20 connections in pool
85
+ * idle_timeout: 30, // Close idle connections after 30 seconds
86
+ * connect_timeout: 10, // 10 second connection timeout
87
+ * max_lifetime: 3600 // Connections live maximum 1 hour
88
+ * }
78
89
  * });
79
90
  *
80
91
  * // Or with individual parameters
@@ -86,7 +97,12 @@ export type PostgresPathwayStateConfig = PostgresPathwayStateConnectionStringCon
86
97
  * database: "mydb",
87
98
  * ssl: false,
88
99
  * tableName: "event_processing_state", // Optional
89
- * ttlMs: 30 * 60 * 1000 // 30 minutes (optional)
100
+ * ttlMs: 30 * 60 * 1000, // 30 minutes (optional)
101
+ * pool: { // Optional connection pool configuration
102
+ * max: 15, // Maximum 15 connections in pool
103
+ * idle_timeout: 60, // Close idle connections after 60 seconds
104
+ * connect_timeout: 5 // 5 second connection timeout
105
+ * }
90
106
  * });
91
107
  *
92
108
  * // Use with PathwaysBuilder
@@ -257,6 +273,17 @@ export declare class PostgresPathwayState implements PathwayState {
257
273
  * ttlMs: 7 * 24 * 60 * 60 * 1000 // 1 week
258
274
  * });
259
275
  *
276
+ * // With connection pool configuration
277
+ * const state = createPostgresPathwayState({
278
+ * connectionString: "postgres://user:pass@localhost:5432/db",
279
+ * pool: {
280
+ * max: 25, // Maximum 25 connections
281
+ * idle_timeout: 120, // Close idle connections after 2 minutes
282
+ * connect_timeout: 15, // 15 second connection timeout
283
+ * max_lifetime: 1800 // Connections live maximum 30 minutes
284
+ * }
285
+ * });
286
+ *
260
287
  * // Use with PathwaysBuilder
261
288
  * const pathways = new PathwaysBuilder({
262
289
  * // Other config
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-pathway-state.d.ts","sourceRoot":"","sources":["../../../src/pathways/postgres/postgres-pathway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;OAGG;IACH,OAAO,CAAC,SAAS,CAAQ;IAEzB;;;OAGG;IACH,OAAO,CAAC,KAAK,CAAQ;IAErB;;;OAGG;IACH,OAAO,CAAC,WAAW,CAAQ;IAE3B;;;;OAIG;gBACiB,MAAM,EAAE,0BAA0B;IAMtD;;;;;OAKG;YACW,UAAU;IAyDxB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBlD;;;;;OAKG;YACW,cAAc;IAQ5B;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAK7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,0BAA0B,GAAG,oBAAoB,CAGnG"}
@@ -29,7 +29,13 @@ const postgres_adapter_js_1 = require("./postgres-adapter.js");
29
29
  * const postgresState = createPostgresPathwayState({
30
30
  * connectionString: "postgres://user:password@localhost:5432/mydb",
31
31
  * tableName: "event_processing_state", // Optional
32
- * ttlMs: 24 * 60 * 60 * 1000 // 24 hours (optional)
32
+ * ttlMs: 24 * 60 * 60 * 1000, // 24 hours (optional)
33
+ * pool: { // Optional connection pool configuration
34
+ * max: 20, // Maximum 20 connections in pool
35
+ * idle_timeout: 30, // Close idle connections after 30 seconds
36
+ * connect_timeout: 10, // 10 second connection timeout
37
+ * max_lifetime: 3600 // Connections live maximum 1 hour
38
+ * }
33
39
  * });
34
40
  *
35
41
  * // Or with individual parameters
@@ -41,7 +47,12 @@ const postgres_adapter_js_1 = require("./postgres-adapter.js");
41
47
  * database: "mydb",
42
48
  * ssl: false,
43
49
  * tableName: "event_processing_state", // Optional
44
- * ttlMs: 30 * 60 * 1000 // 30 minutes (optional)
50
+ * ttlMs: 30 * 60 * 1000, // 30 minutes (optional)
51
+ * pool: { // Optional connection pool configuration
52
+ * max: 15, // Maximum 15 connections in pool
53
+ * idle_timeout: 60, // Close idle connections after 60 seconds
54
+ * connect_timeout: 5 // 5 second connection timeout
55
+ * }
45
56
  * });
46
57
  *
47
58
  * // Use with PathwaysBuilder
@@ -122,6 +133,7 @@ class PostgresPathwayState {
122
133
  // Use connection string if provided
123
134
  this.postgres = await (0, postgres_adapter_js_1.createPostgresAdapter)({
124
135
  connectionString: this.config.connectionString,
136
+ pool: this.config.pool,
125
137
  });
126
138
  }
127
139
  else {
@@ -134,6 +146,7 @@ class PostgresPathwayState {
134
146
  password: this.config.password,
135
147
  database: this.config.database,
136
148
  ssl: this.config.ssl,
149
+ pool: this.config.pool,
137
150
  });
138
151
  }
139
152
  // Check if the table exists
@@ -330,6 +343,17 @@ Object.defineProperty(PostgresPathwayState, "DEFAULT_TABLE_NAME", {
330
343
  * ttlMs: 7 * 24 * 60 * 60 * 1000 // 1 week
331
344
  * });
332
345
  *
346
+ * // With connection pool configuration
347
+ * const state = createPostgresPathwayState({
348
+ * connectionString: "postgres://user:pass@localhost:5432/db",
349
+ * pool: {
350
+ * max: 25, // Maximum 25 connections
351
+ * idle_timeout: 120, // Close idle connections after 2 minutes
352
+ * connect_timeout: 15, // 15 second connection timeout
353
+ * max_lifetime: 1800 // Connections live maximum 30 minutes
354
+ * }
355
+ * });
356
+ *
333
357
  * // Use with PathwaysBuilder
334
358
  * const pathways = new PathwaysBuilder({
335
359
  * // Other config