@grest-ts/discovery 0.0.14 → 0.0.17
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/README.md +60 -0
- package/package.json +4 -5
package/README.md
CHANGED
|
@@ -3,3 +3,63 @@
|
|
|
3
3
|
> [Documentation](https://github.com/grest-ts/grest-ts#readme) | [All packages](https://github.com/grest-ts/grest-ts#package-reference)
|
|
4
4
|
<!-- GREST-TS-BANNER-END -->
|
|
5
5
|
|
|
6
|
+
# @grest-ts/discovery
|
|
7
|
+
|
|
8
|
+
Base package for service discovery in grest-ts. Provides the abstract class, types, and locator key that all discovery implementations build on.
|
|
9
|
+
|
|
10
|
+
For a full overview of how discovery works and available implementations, see the [Discovery guide](@guide/discovery).
|
|
11
|
+
|
|
12
|
+
## Exports
|
|
13
|
+
|
|
14
|
+
### `GGDiscoveryClient` (abstract class)
|
|
15
|
+
|
|
16
|
+
The base class all discovery implementations extend:
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
abstract class GGDiscoveryClient {
|
|
20
|
+
readonly isLocal: boolean = false;
|
|
21
|
+
|
|
22
|
+
abstract registerRoutes(registrations: GGServiceRegistration[]): void;
|
|
23
|
+
abstract register(): Promise<void>;
|
|
24
|
+
abstract unregister(): Promise<void>;
|
|
25
|
+
abstract discoverApi(apiName: string): Promise<string>;
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
| Method | Purpose |
|
|
30
|
+
|---|---|
|
|
31
|
+
| `registerRoutes()` | Called when an HTTP server starts. Tells discovery what APIs this service provides. |
|
|
32
|
+
| `register()` | Registers the service with the discovery backend. |
|
|
33
|
+
| `unregister()` | Cleans up on shutdown. |
|
|
34
|
+
| `discoverApi()` | Returns the full URL for a given API name. This is what clients call. |
|
|
35
|
+
|
|
36
|
+
The `isLocal` flag indicates local development mode. When `true`, cloud resources (AWS SNS, etc.) should use local adapters instead.
|
|
37
|
+
|
|
38
|
+
### `GG_DISCOVERY` (locator key)
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
const GG_DISCOVERY = new GGLocatorKey<GGDiscoveryClient>("GGDiscovery");
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Service locator key for registering and accessing the active discovery client.
|
|
45
|
+
|
|
46
|
+
### `GGServiceRegistration` (interface)
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
interface GGServiceRegistration {
|
|
50
|
+
runtime: string; // Service name
|
|
51
|
+
api: string; // API name, e.g. "UserApi"
|
|
52
|
+
protocol: "http" | "ws";
|
|
53
|
+
port: number;
|
|
54
|
+
pathPrefix: string; // e.g. "/api/users/"
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Implementations
|
|
59
|
+
|
|
60
|
+
| Package | Use case |
|
|
61
|
+
|---|---|
|
|
62
|
+
| [`@grest-ts/discovery-static`](@pkg/discovery-static) | Production deployments with known URLs |
|
|
63
|
+
| [`@grest-ts/discovery-local`](@pkg/discovery-local) | Local development and testing |
|
|
64
|
+
| [`@grest-ts/discovery-kubernetes`](@pkg/discovery-kubernetes) | Kubernetes deployments |
|
|
65
|
+
| [`@grest-ts/discovery-migration`](@pkg/discovery-migration) | Zero-downtime migration between strategies |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grest-ts/discovery",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Service discovery implementations for Grest Framework",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"url": "https://github.com/grest-ts/grest-ts.git",
|
|
30
30
|
"directory": "packages/discovery/discovery"
|
|
31
31
|
},
|
|
32
|
-
"homepage": "https://
|
|
32
|
+
"homepage": "https://grest-ts.com/packages/discovery",
|
|
33
33
|
"bugs": {
|
|
34
34
|
"url": "https://github.com/grest-ts/grest-ts/issues"
|
|
35
35
|
},
|
|
@@ -47,10 +47,9 @@
|
|
|
47
47
|
"node": ">=25"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@grest-ts/locator": "0.0.
|
|
50
|
+
"@grest-ts/locator": "0.0.17"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@grest-ts/testkit": "0.0.
|
|
54
|
-
"@grest-ts/x-packager": "0.0.14"
|
|
53
|
+
"@grest-ts/testkit": "0.0.17"
|
|
55
54
|
}
|
|
56
55
|
}
|