@atomservice/postgres 0.1.17 → 0.1.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomservice/postgres",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "PostgreSQL 原子服务",
5
5
  "type": "module",
6
6
  "author": "openorson",
@@ -28,6 +28,6 @@
28
28
  ".": "./src/index.ts"
29
29
  },
30
30
  "peerDependencies": {
31
- "@atomservice/core": "0.1.17"
31
+ "@atomservice/core": "0.1.19"
32
32
  }
33
33
  }
@@ -1,4 +1,4 @@
1
- import { tmpl } from "@atomservice/core"
1
+ import { composeResourcesBlock, tmpl } from "@atomservice/core"
2
2
  import { POSTGRES_IMAGE } from "./postgres.consts.ts"
3
3
  import type { PostgresOptions } from "./postgres.options.ts"
4
4
 
@@ -6,9 +6,11 @@ export function postgresCompose(
6
6
  containerName: string,
7
7
  version: string,
8
8
  dataDir: string,
9
- opts: Pick<PostgresOptions, "password" | "hostPort" | "maxConnections" | "sharedBuffers">,
9
+ opts: Pick<PostgresOptions, "password" | "hostPort" | "maxConnections" | "sharedBuffers" | "resources" | "restart">,
10
10
  ): string {
11
- const { password, hostPort, maxConnections, sharedBuffers } = opts
11
+ const { password, hostPort, maxConnections, sharedBuffers, resources } = opts
12
+ const resourcesBlock = composeResourcesBlock(resources)
13
+ const restart = opts.restart ?? "unless-stopped"
12
14
 
13
15
  const portsBlock = hostPort ? `\n ports:\n - "${hostPort}:5432"` : ""
14
16
 
@@ -30,7 +32,7 @@ services:
30
32
  - ${dataDir}:/var/lib/postgresql${portsBlock}
31
33
  networks:
32
34
  - atomservice
33
- restart: unless-stopped
35
+ restart: ${restart}${resourcesBlock}
34
36
  healthcheck:
35
37
  test: ["CMD-SHELL", "pg_isready -U postgres"]
36
38
  interval: 10s
@@ -11,16 +11,11 @@ export interface DatabaseConfig {
11
11
  extensions?: string[]
12
12
  }
13
13
 
14
- export interface PostgresOptions {
15
- /**
16
- * 实例标识
17
- *
18
- * - 用于区分不同实例
19
- *
20
- * @default "default"
21
- */
22
- id?: string
14
+ import type { BaseServiceOptions } from "@atomservice/core"
15
+
16
+ export interface PostgresOptions extends BaseServiceOptions {
23
17
  /**
18
+
24
19
  * 镜像版本
25
20
  *
26
21
  * @default "18"