@atomservice/config 0.1.16 → 0.1.18

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/config",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "配置中心原子服务:基于 Bun 的高性能配置管理服务",
5
5
  "type": "module",
6
6
  "author": "openorson",
@@ -29,9 +29,9 @@
29
29
  ".": "./src/index.ts"
30
30
  },
31
31
  "dependencies": {
32
- "@atomservice/gateway": "0.1.16"
32
+ "@atomservice/gateway": "0.1.18"
33
33
  },
34
34
  "peerDependencies": {
35
- "@atomservice/core": "0.1.16"
35
+ "@atomservice/core": "0.1.18"
36
36
  }
37
37
  }
@@ -1,9 +1,11 @@
1
- import { tmpl } from "@atomservice/core"
1
+ import { composeResourcesBlock, tmpl } from "@atomservice/core"
2
2
  import { CONFIG_SERVER_PORT } from "./config.consts.ts"
3
3
  import type { ConfigComposeOptions } from "./config.types.ts"
4
4
 
5
5
  export function configCompose(opts: ConfigComposeOptions): string {
6
6
  const portsBlock = opts.hostPort ? `\n ports:\n - "${opts.hostPort}:${CONFIG_SERVER_PORT}"` : ""
7
+ const resourcesBlock = composeResourcesBlock(opts.resources)
8
+ const restart = opts.restart ?? "unless-stopped"
7
9
 
8
10
  return tmpl`\
9
11
  services:
@@ -18,7 +20,7 @@ services:
18
20
  - "${CONFIG_SERVER_PORT}"${portsBlock}
19
21
  networks:
20
22
  - atomservice
21
- restart: unless-stopped
23
+ restart: ${restart}${resourcesBlock}
22
24
  healthcheck:
23
25
  test: ["CMD", "curl", "-sf", "http://localhost:${CONFIG_SERVER_PORT}/v1/health"]
24
26
  interval: 10s
@@ -1,13 +1,7 @@
1
- import type { CallableService } from "@atomservice/core"
1
+ import type { BaseServiceOptions, CallableService } from "@atomservice/core"
2
2
  import type { GatewayInstance } from "@atomservice/gateway"
3
3
 
4
- export interface ConfigOptions {
5
- /**
6
- * 实例标识
7
- *
8
- * @default "default"
9
- */
10
- id?: string
4
+ export interface ConfigOptions extends BaseServiceOptions {
11
5
  /**
12
6
  * 容器对外端口
13
7
  *
@@ -67,6 +67,8 @@ export function config(opts: ConfigOptions = {}): CallableService<ConfigInstance
67
67
  image: imageTag,
68
68
  dataDir,
69
69
  hostPort: opts.hostPort,
70
+ resources: opts.resources,
71
+ restart: opts.restart,
70
72
  }),
71
73
  )
72
74
 
@@ -2,9 +2,13 @@ export type ConfigState = {
2
2
  version: string
3
3
  }
4
4
 
5
+ import type { ServiceResourcesOptions, ServiceRestartPolicy } from "@atomservice/core"
6
+
5
7
  export interface ConfigComposeOptions {
6
8
  id: string
7
9
  image: string
8
10
  dataDir: string
9
11
  hostPort?: number
12
+ resources?: ServiceResourcesOptions
13
+ restart?: ServiceRestartPolicy
10
14
  }