@vibesdotdev/integrations-redis 0.0.0-stage → 1.0.0-rc.2
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/LICENSE +126 -0
- package/README.md +21 -2
- package/dist/client.d.ts +10 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +12 -0
- package/dist/client.js.map +1 -0
- package/dist/client.node.d.ts +7 -0
- package/dist/client.node.d.ts.map +1 -0
- package/dist/client.node.js +8 -0
- package/dist/client.node.js.map +1 -0
- package/dist/config.d.ts +141 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +39 -0
- package/dist/config.js.map +1 -0
- package/dist/connections.d.ts +56 -0
- package/dist/connections.d.ts.map +1 -0
- package/dist/connections.js +166 -0
- package/dist/connections.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/instrumented.d.ts +8 -0
- package/dist/instrumented.d.ts.map +1 -0
- package/dist/instrumented.js +41 -0
- package/dist/instrumented.js.map +1 -0
- package/dist/manager.d.ts +79 -0
- package/dist/manager.d.ts.map +1 -0
- package/dist/manager.js +321 -0
- package/dist/manager.js.map +1 -0
- package/dist/redis.consumer.plugin.d.ts +10 -0
- package/dist/redis.consumer.plugin.d.ts.map +1 -0
- package/dist/redis.consumer.plugin.js +30 -0
- package/dist/redis.consumer.plugin.js.map +1 -0
- package/dist/redis.plugin.d.ts +3 -0
- package/dist/redis.plugin.d.ts.map +1 -0
- package/dist/redis.plugin.js +12 -0
- package/dist/redis.plugin.js.map +1 -0
- package/dist/scheduler-lock.d.ts +20 -0
- package/dist/scheduler-lock.d.ts.map +1 -0
- package/dist/scheduler-lock.js +43 -0
- package/dist/scheduler-lock.js.map +1 -0
- package/dist/schemas/connection.d.ts +10 -0
- package/dist/schemas/connection.d.ts.map +1 -0
- package/dist/schemas/connection.js +8 -0
- package/dist/schemas/connection.js.map +1 -0
- package/dist/schemas/lock.d.ts +10 -0
- package/dist/schemas/lock.d.ts.map +1 -0
- package/dist/schemas/lock.js +4 -0
- package/dist/schemas/lock.js.map +1 -0
- package/dist/schemas/settings.d.ts +46 -0
- package/dist/schemas/settings.d.ts.map +1 -0
- package/dist/schemas/settings.js +23 -0
- package/dist/schemas/settings.js.map +1 -0
- package/dist/telemetry-ioredis.impl.d.ts +4 -0
- package/dist/telemetry-ioredis.impl.d.ts.map +1 -0
- package/dist/telemetry-ioredis.impl.js +6 -0
- package/dist/telemetry-ioredis.impl.js.map +1 -0
- package/dist/telemetry-redis.impl.d.ts +4 -0
- package/dist/telemetry-redis.impl.d.ts.map +1 -0
- package/dist/telemetry-redis.impl.js +6 -0
- package/dist/telemetry-redis.impl.js.map +1 -0
- package/dist/telemetry.d.ts +34 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +29 -0
- package/dist/telemetry.js.map +1 -0
- package/package.json +101 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
Parameters
|
|
4
|
+
|
|
5
|
+
Licensor: VIBES DEV LLC
|
|
6
|
+
Licensed Work: @vibesdotdev/integrations-kafka
|
|
7
|
+
The Licensed Work is (c) 2026 VIBES DEV LLC.
|
|
8
|
+
Additional Use Grant: In this grant, "Vibes Platform" means the hosted services VIBES DEV LLC
|
|
9
|
+
operates at vibes.dev and its subdomains.
|
|
10
|
+
|
|
11
|
+
You may make production use of the Licensed Work, including commercial
|
|
12
|
+
use, subject to the limits below. Permitted production use includes:
|
|
13
|
+
building, operating and selling your own applications, agents and services
|
|
14
|
+
on or with the Vibes Platform; self-hosting the Licensed Work for use inside
|
|
15
|
+
your own organization; and providing consulting, integration or development
|
|
16
|
+
services to clients who build on the Vibes Platform.
|
|
17
|
+
|
|
18
|
+
The production use permitted above does not include use that:
|
|
19
|
+
|
|
20
|
+
(a) offers third parties a hosted, managed or embedded service that
|
|
21
|
+
substitutes for the Vibes Platform or a material part of it (including
|
|
22
|
+
agent hosting; fleet, sandbox or container provisioning; package
|
|
23
|
+
registry; source hosting and continuous integration; and managed AI,
|
|
24
|
+
storage, secrets or messaging), where the Licensed Work provides a
|
|
25
|
+
material part of that service's value and that service earns more than
|
|
26
|
+
US$1,000,000 in gross revenue in any twelve-month period;
|
|
27
|
+
(b) sells, rents, sublicenses or white-labels the Licensed Work, or access
|
|
28
|
+
to Vibes Platform functionality, as a product in its own right;
|
|
29
|
+
(c) removes, disables or works around entitlement checks, usage metering,
|
|
30
|
+
quotas or plan limits, or reaches Vibes Platform features the user's
|
|
31
|
+
account is not entitled to;
|
|
32
|
+
(d) scrapes, bulk-exports or harvests data or content from the Vibes
|
|
33
|
+
Platform or its users other than through documented interfaces and
|
|
34
|
+
within their terms, or uses outputs or data obtained from the Vibes
|
|
35
|
+
Platform to train or improve a product that competes with it;
|
|
36
|
+
(e) violates applicable law, infringes anyone's rights, commits fraud or
|
|
37
|
+
deception, conducts unlawful surveillance or harassment, distributes
|
|
38
|
+
malware, or accesses systems without authorization; or
|
|
39
|
+
(f) violates applicable antitrust or competition law.
|
|
40
|
+
|
|
41
|
+
A written permission from the Licensor extends this grant.
|
|
42
|
+
Change Date: Four years from the date the Licensed Work is published.
|
|
43
|
+
Change License: MIT
|
|
44
|
+
|
|
45
|
+
For information about alternative licensing arrangements for the Licensed Work,
|
|
46
|
+
contact VIBES DEV LLC through https://vibes.dev.
|
|
47
|
+
|
|
48
|
+
Notice
|
|
49
|
+
|
|
50
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
51
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
52
|
+
under an Open Source License, as stated in this License.
|
|
53
|
+
|
|
54
|
+
-----------------------------------------------------------------------------
|
|
55
|
+
|
|
56
|
+
Business Source License 1.1
|
|
57
|
+
|
|
58
|
+
License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
59
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
60
|
+
|
|
61
|
+
Terms
|
|
62
|
+
|
|
63
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
64
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
65
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
66
|
+
production use.
|
|
67
|
+
|
|
68
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
69
|
+
available distribution of a specific version of the Licensed Work under this
|
|
70
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
71
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
72
|
+
above terminate.
|
|
73
|
+
|
|
74
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
75
|
+
currently in effect as described in this License, you must purchase a
|
|
76
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
77
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
78
|
+
|
|
79
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
80
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
81
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
82
|
+
for each version of the Licensed Work released by Licensor.
|
|
83
|
+
|
|
84
|
+
You must conspicuously display this License on each original or modified copy
|
|
85
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
86
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
87
|
+
License apply to your use of that work.
|
|
88
|
+
|
|
89
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
90
|
+
terminate your rights under this License for the current and all other
|
|
91
|
+
versions of the Licensed Work.
|
|
92
|
+
|
|
93
|
+
This License does not grant you any right in any trademark or logo of
|
|
94
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
95
|
+
Licensor as expressly required by this License).
|
|
96
|
+
|
|
97
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
98
|
+
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
99
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
100
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
101
|
+
TITLE.
|
|
102
|
+
|
|
103
|
+
MariaDB hereby grants you permission to use this License’s text to license
|
|
104
|
+
your works, and to refer to it using the trademark “Business Source License”,
|
|
105
|
+
as long as you comply with the Covenants of Licensor below.
|
|
106
|
+
|
|
107
|
+
Covenants of Licensor
|
|
108
|
+
|
|
109
|
+
In consideration of the right to use this License’s text and the “Business
|
|
110
|
+
Source License” name and trademark, Licensor covenants to MariaDB, and to all
|
|
111
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
112
|
+
|
|
113
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
114
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
115
|
+
where “compatible” means that software provided under the Change License can
|
|
116
|
+
be included in a program with software provided under GPL Version 2.0 or a
|
|
117
|
+
later version. Licensor may specify additional Change Licenses without
|
|
118
|
+
limitation.
|
|
119
|
+
|
|
120
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
121
|
+
impose any additional restriction on the right granted in this License, as
|
|
122
|
+
the Additional Use Grant; or (b) insert the text “None”.
|
|
123
|
+
|
|
124
|
+
3. To specify a Change Date.
|
|
125
|
+
|
|
126
|
+
4. Not to modify this License in any other way.
|
package/README.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @vibesdotdev/integrations-redis
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Redis connections, command spans and the Workers scheduler lock (moved from `@vibesdotdev/logging` and `@vibesdotdev/workers`). The root and `./plugin` are isomorphic, with no static Redis SDK import; `redisPlugin` registers the `integrations.redis` config manifest and the `redis` runtime client.
|
|
4
|
+
|
|
5
|
+
## Entrypoints
|
|
6
|
+
|
|
7
|
+
| Import |
|
|
8
|
+
|---|
|
|
9
|
+
| `@vibesdotdev/integrations-redis` |
|
|
10
|
+
| `@vibesdotdev/integrations-redis/plugin` |
|
|
11
|
+
| `@vibesdotdev/integrations-redis/manager` |
|
|
12
|
+
| `@vibesdotdev/integrations-redis/connections` |
|
|
13
|
+
| `@vibesdotdev/integrations-redis/instrumented` |
|
|
14
|
+
| `@vibesdotdev/integrations-redis/scheduler-lock` |
|
|
15
|
+
| `@vibesdotdev/integrations-redis/client` |
|
|
16
|
+
| `@vibesdotdev/integrations-redis/consumer-plugin` |
|
|
17
|
+
|
|
18
|
+
`SPEC.md` in this directory is the package contract.
|
|
19
|
+
|
|
20
|
+
## License
|
|
21
|
+
|
|
22
|
+
BUSL-1.1. See `LICENSE`.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseRuntimeClient } from '@vibesdotdev/kernel/client';
|
|
2
|
+
import { RedisConnectionManager } from './manager.ts';
|
|
3
|
+
import { RedisConnections } from './connections.ts';
|
|
4
|
+
export declare class RedisClient extends BaseRuntimeClient {
|
|
5
|
+
readonly manager: RedisConnectionManager;
|
|
6
|
+
readonly purposes: RedisConnections;
|
|
7
|
+
protected onDispose(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export { getVibesClient, tryGetVibesClient } from '@vibesdotdev/kernel/client';
|
|
10
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,qBAAa,WAAY,SAAQ,iBAAiB;IACjD,QAAQ,CAAC,OAAO,yBAA4C;IAC5D,QAAQ,CAAC,QAAQ,mBAA0D;cAElD,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAGnD;AACD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseRuntimeClient } from '@vibesdotdev/kernel/client';
|
|
2
|
+
import { RedisConnectionManager } from "./manager.js";
|
|
3
|
+
import { RedisConnections } from "./connections.js";
|
|
4
|
+
export class RedisClient extends BaseRuntimeClient {
|
|
5
|
+
manager = new RedisConnectionManager(this.runtime);
|
|
6
|
+
purposes = new RedisConnections(this.runtime, () => this.manager);
|
|
7
|
+
async onDispose() {
|
|
8
|
+
await this.purposes.dispose(this.manager);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export { getVibesClient, tryGetVibesClient } from '@vibesdotdev/kernel/client';
|
|
12
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IACxC,OAAO,GAAG,IAAI,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnD,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAExD,KAAK,CAAC,SAAS;QACjC,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;CACD;AACD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RedisClient } from './client.ts';
|
|
2
|
+
import { RedisConnectionManager } from './manager.ts';
|
|
3
|
+
export declare class NodeRedisClient extends RedisClient {
|
|
4
|
+
readonly manager: RedisConnectionManager;
|
|
5
|
+
}
|
|
6
|
+
export declare const impl: typeof NodeRedisClient;
|
|
7
|
+
//# sourceMappingURL=client.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.node.d.ts","sourceRoot":"","sources":["../src/client.node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,qBAAa,eAAgB,SAAQ,WAAW;IAC/C,SAAkB,OAAO,yBACgC;CACzD;AACD,eAAO,MAAM,IAAI,wBAAkB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import IORedis from 'ioredis';
|
|
2
|
+
import { RedisClient } from "./client.js";
|
|
3
|
+
import { RedisConnectionManager } from "./manager.js";
|
|
4
|
+
export class NodeRedisClient extends RedisClient {
|
|
5
|
+
manager = new RedisConnectionManager(this.runtime, (url, options) => url ? new IORedis(url, options) : new IORedis(options));
|
|
6
|
+
}
|
|
7
|
+
export const impl = NodeRedisClient;
|
|
8
|
+
//# sourceMappingURL=client.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.node.js","sourceRoot":"","sources":["../src/client.node.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAC7B,OAAO,GAAG,IAAI,sBAAsB,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CACrF,GAAG,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;CACzD;AACD,MAAM,CAAC,MAAM,IAAI,GAAG,eAAe,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redis settings — the `integrations.redis` config manifest.
|
|
3
|
+
*
|
|
4
|
+
* Non-secret connection settings only; the URL (which carries the password)
|
|
5
|
+
* is the `REDIS_URL` credential, or a purpose's own `REDIS_<PURPOSE>_URL`.
|
|
6
|
+
* Declared as data with `createRuntimeAsset`; the runtime holds it until
|
|
7
|
+
* `config/manifest` registers.
|
|
8
|
+
*/
|
|
9
|
+
export { RedisSettingsSchema, type RedisSettings } from './schemas/settings.ts';
|
|
10
|
+
export declare const REDIS_SETTINGS_MANIFEST_ID = "integrations.redis";
|
|
11
|
+
/** The config owner's typed read contract for these settings. */
|
|
12
|
+
export declare const redisSettingsManifest: {
|
|
13
|
+
id: string;
|
|
14
|
+
schema: import("zod/v4").ZodObject<{
|
|
15
|
+
maxRetriesPerRequest: import("zod/v4").ZodDefault<import("zod/v4").ZodNumber>;
|
|
16
|
+
enableReadyCheck: import("zod/v4").ZodDefault<import("zod/v4").ZodBoolean>;
|
|
17
|
+
readinessTimeoutMs: import("zod/v4").ZodDefault<import("zod/v4").ZodNumber>;
|
|
18
|
+
purposes: import("zod/v4").ZodPrefault<import("zod/v4").ZodObject<{
|
|
19
|
+
cache: import("zod/v4").ZodDefault<import("zod/v4").ZodObject<{
|
|
20
|
+
enableReadyCheck: import("zod/v4").ZodDefault<import("zod/v4").ZodBoolean>;
|
|
21
|
+
connectTimeout: import("zod/v4").ZodDefault<import("zod/v4").ZodNumber>;
|
|
22
|
+
maxRetriesPerRequest: import("zod/v4").ZodOptional<import("zod/v4").ZodNullable<import("zod/v4").ZodNumber>>;
|
|
23
|
+
autoResendUnfulfilledCommands: import("zod/v4").ZodOptional<import("zod/v4").ZodBoolean>;
|
|
24
|
+
}, import("zod/v4/core").$strip>>;
|
|
25
|
+
sessions: import("zod/v4").ZodDefault<import("zod/v4").ZodObject<{
|
|
26
|
+
enableReadyCheck: import("zod/v4").ZodDefault<import("zod/v4").ZodBoolean>;
|
|
27
|
+
connectTimeout: import("zod/v4").ZodDefault<import("zod/v4").ZodNumber>;
|
|
28
|
+
maxRetriesPerRequest: import("zod/v4").ZodOptional<import("zod/v4").ZodNullable<import("zod/v4").ZodNumber>>;
|
|
29
|
+
autoResendUnfulfilledCommands: import("zod/v4").ZodOptional<import("zod/v4").ZodBoolean>;
|
|
30
|
+
}, import("zod/v4/core").$strip>>;
|
|
31
|
+
workers: import("zod/v4").ZodDefault<import("zod/v4").ZodObject<{
|
|
32
|
+
enableReadyCheck: import("zod/v4").ZodDefault<import("zod/v4").ZodBoolean>;
|
|
33
|
+
connectTimeout: import("zod/v4").ZodDefault<import("zod/v4").ZodNumber>;
|
|
34
|
+
maxRetriesPerRequest: import("zod/v4").ZodOptional<import("zod/v4").ZodNullable<import("zod/v4").ZodNumber>>;
|
|
35
|
+
autoResendUnfulfilledCommands: import("zod/v4").ZodOptional<import("zod/v4").ZodBoolean>;
|
|
36
|
+
}, import("zod/v4/core").$strip>>;
|
|
37
|
+
pubsub: import("zod/v4").ZodDefault<import("zod/v4").ZodObject<{
|
|
38
|
+
enableReadyCheck: import("zod/v4").ZodDefault<import("zod/v4").ZodBoolean>;
|
|
39
|
+
connectTimeout: import("zod/v4").ZodDefault<import("zod/v4").ZodNumber>;
|
|
40
|
+
maxRetriesPerRequest: import("zod/v4").ZodOptional<import("zod/v4").ZodNullable<import("zod/v4").ZodNumber>>;
|
|
41
|
+
autoResendUnfulfilledCommands: import("zod/v4").ZodOptional<import("zod/v4").ZodBoolean>;
|
|
42
|
+
}, import("zod/v4/core").$strip>>;
|
|
43
|
+
gpu_queue: import("zod/v4").ZodDefault<import("zod/v4").ZodObject<{
|
|
44
|
+
enableReadyCheck: import("zod/v4").ZodDefault<import("zod/v4").ZodBoolean>;
|
|
45
|
+
connectTimeout: import("zod/v4").ZodDefault<import("zod/v4").ZodNumber>;
|
|
46
|
+
maxRetriesPerRequest: import("zod/v4").ZodOptional<import("zod/v4").ZodNullable<import("zod/v4").ZodNumber>>;
|
|
47
|
+
autoResendUnfulfilledCommands: import("zod/v4").ZodOptional<import("zod/v4").ZodBoolean>;
|
|
48
|
+
}, import("zod/v4/core").$strip>>;
|
|
49
|
+
model_registry: import("zod/v4").ZodDefault<import("zod/v4").ZodObject<{
|
|
50
|
+
enableReadyCheck: import("zod/v4").ZodDefault<import("zod/v4").ZodBoolean>;
|
|
51
|
+
connectTimeout: import("zod/v4").ZodDefault<import("zod/v4").ZodNumber>;
|
|
52
|
+
maxRetriesPerRequest: import("zod/v4").ZodOptional<import("zod/v4").ZodNullable<import("zod/v4").ZodNumber>>;
|
|
53
|
+
autoResendUnfulfilledCommands: import("zod/v4").ZodOptional<import("zod/v4").ZodBoolean>;
|
|
54
|
+
}, import("zod/v4/core").$strip>>;
|
|
55
|
+
}, import("zod/v4/core").$strip>>;
|
|
56
|
+
}, import("zod/v4/core").$strip>;
|
|
57
|
+
};
|
|
58
|
+
export declare const redisSettingsDescriptor: {
|
|
59
|
+
kind: "config/manifest";
|
|
60
|
+
id: string;
|
|
61
|
+
name: string;
|
|
62
|
+
namespace: string;
|
|
63
|
+
description: string;
|
|
64
|
+
tier: string;
|
|
65
|
+
category: string;
|
|
66
|
+
schema: import("zod/v4").ZodObject<{
|
|
67
|
+
maxRetriesPerRequest: import("zod/v4").ZodDefault<import("zod/v4").ZodNumber>;
|
|
68
|
+
enableReadyCheck: import("zod/v4").ZodDefault<import("zod/v4").ZodBoolean>;
|
|
69
|
+
readinessTimeoutMs: import("zod/v4").ZodDefault<import("zod/v4").ZodNumber>;
|
|
70
|
+
purposes: import("zod/v4").ZodPrefault<import("zod/v4").ZodObject<{
|
|
71
|
+
cache: import("zod/v4").ZodDefault<import("zod/v4").ZodObject<{
|
|
72
|
+
enableReadyCheck: import("zod/v4").ZodDefault<import("zod/v4").ZodBoolean>;
|
|
73
|
+
connectTimeout: import("zod/v4").ZodDefault<import("zod/v4").ZodNumber>;
|
|
74
|
+
maxRetriesPerRequest: import("zod/v4").ZodOptional<import("zod/v4").ZodNullable<import("zod/v4").ZodNumber>>;
|
|
75
|
+
autoResendUnfulfilledCommands: import("zod/v4").ZodOptional<import("zod/v4").ZodBoolean>;
|
|
76
|
+
}, import("zod/v4/core").$strip>>;
|
|
77
|
+
sessions: import("zod/v4").ZodDefault<import("zod/v4").ZodObject<{
|
|
78
|
+
enableReadyCheck: import("zod/v4").ZodDefault<import("zod/v4").ZodBoolean>;
|
|
79
|
+
connectTimeout: import("zod/v4").ZodDefault<import("zod/v4").ZodNumber>;
|
|
80
|
+
maxRetriesPerRequest: import("zod/v4").ZodOptional<import("zod/v4").ZodNullable<import("zod/v4").ZodNumber>>;
|
|
81
|
+
autoResendUnfulfilledCommands: import("zod/v4").ZodOptional<import("zod/v4").ZodBoolean>;
|
|
82
|
+
}, import("zod/v4/core").$strip>>;
|
|
83
|
+
workers: import("zod/v4").ZodDefault<import("zod/v4").ZodObject<{
|
|
84
|
+
enableReadyCheck: import("zod/v4").ZodDefault<import("zod/v4").ZodBoolean>;
|
|
85
|
+
connectTimeout: import("zod/v4").ZodDefault<import("zod/v4").ZodNumber>;
|
|
86
|
+
maxRetriesPerRequest: import("zod/v4").ZodOptional<import("zod/v4").ZodNullable<import("zod/v4").ZodNumber>>;
|
|
87
|
+
autoResendUnfulfilledCommands: import("zod/v4").ZodOptional<import("zod/v4").ZodBoolean>;
|
|
88
|
+
}, import("zod/v4/core").$strip>>;
|
|
89
|
+
pubsub: import("zod/v4").ZodDefault<import("zod/v4").ZodObject<{
|
|
90
|
+
enableReadyCheck: import("zod/v4").ZodDefault<import("zod/v4").ZodBoolean>;
|
|
91
|
+
connectTimeout: import("zod/v4").ZodDefault<import("zod/v4").ZodNumber>;
|
|
92
|
+
maxRetriesPerRequest: import("zod/v4").ZodOptional<import("zod/v4").ZodNullable<import("zod/v4").ZodNumber>>;
|
|
93
|
+
autoResendUnfulfilledCommands: import("zod/v4").ZodOptional<import("zod/v4").ZodBoolean>;
|
|
94
|
+
}, import("zod/v4/core").$strip>>;
|
|
95
|
+
gpu_queue: import("zod/v4").ZodDefault<import("zod/v4").ZodObject<{
|
|
96
|
+
enableReadyCheck: import("zod/v4").ZodDefault<import("zod/v4").ZodBoolean>;
|
|
97
|
+
connectTimeout: import("zod/v4").ZodDefault<import("zod/v4").ZodNumber>;
|
|
98
|
+
maxRetriesPerRequest: import("zod/v4").ZodOptional<import("zod/v4").ZodNullable<import("zod/v4").ZodNumber>>;
|
|
99
|
+
autoResendUnfulfilledCommands: import("zod/v4").ZodOptional<import("zod/v4").ZodBoolean>;
|
|
100
|
+
}, import("zod/v4/core").$strip>>;
|
|
101
|
+
model_registry: import("zod/v4").ZodDefault<import("zod/v4").ZodObject<{
|
|
102
|
+
enableReadyCheck: import("zod/v4").ZodDefault<import("zod/v4").ZodBoolean>;
|
|
103
|
+
connectTimeout: import("zod/v4").ZodDefault<import("zod/v4").ZodNumber>;
|
|
104
|
+
maxRetriesPerRequest: import("zod/v4").ZodOptional<import("zod/v4").ZodNullable<import("zod/v4").ZodNumber>>;
|
|
105
|
+
autoResendUnfulfilledCommands: import("zod/v4").ZodOptional<import("zod/v4").ZodBoolean>;
|
|
106
|
+
}, import("zod/v4/core").$strip>>;
|
|
107
|
+
}, import("zod/v4/core").$strip>>;
|
|
108
|
+
}, import("zod/v4/core").$strip>;
|
|
109
|
+
fields: {
|
|
110
|
+
maxRetriesPerRequest: {
|
|
111
|
+
ui: {
|
|
112
|
+
label: string;
|
|
113
|
+
component: string;
|
|
114
|
+
group: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
enableReadyCheck: {
|
|
118
|
+
ui: {
|
|
119
|
+
label: string;
|
|
120
|
+
component: string;
|
|
121
|
+
group: string;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
groups: {
|
|
126
|
+
id: string;
|
|
127
|
+
label: string;
|
|
128
|
+
}[];
|
|
129
|
+
allowedAdapters: string[];
|
|
130
|
+
defaultAdapter: string;
|
|
131
|
+
scope: string;
|
|
132
|
+
customTables: boolean;
|
|
133
|
+
version: number;
|
|
134
|
+
internal: boolean;
|
|
135
|
+
context: {
|
|
136
|
+
surfaces: string[];
|
|
137
|
+
};
|
|
138
|
+
enabled: true;
|
|
139
|
+
};
|
|
140
|
+
export default redisSettingsDescriptor;
|
|
141
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGhF,eAAO,MAAM,0BAA0B,uBAAuB,CAAC;AAE/D,iEAAiE;AACjE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAkE,CAAC;AAErG,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBlC,CAAC;AAEH,eAAe,uBAAuB,CAAC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redis settings — the `integrations.redis` config manifest.
|
|
3
|
+
*
|
|
4
|
+
* Non-secret connection settings only; the URL (which carries the password)
|
|
5
|
+
* is the `REDIS_URL` credential, or a purpose's own `REDIS_<PURPOSE>_URL`.
|
|
6
|
+
* Declared as data with `createRuntimeAsset`; the runtime holds it until
|
|
7
|
+
* `config/manifest` registers.
|
|
8
|
+
*/
|
|
9
|
+
import { RedisSettingsSchema } from "./schemas/settings.js";
|
|
10
|
+
export { RedisSettingsSchema } from "./schemas/settings.js";
|
|
11
|
+
import { createRuntimeAsset } from '@vibesdotdev/kernel';
|
|
12
|
+
export const REDIS_SETTINGS_MANIFEST_ID = 'integrations.redis';
|
|
13
|
+
/** The config owner's typed read contract for these settings. */
|
|
14
|
+
export const redisSettingsManifest = { id: REDIS_SETTINGS_MANIFEST_ID, schema: RedisSettingsSchema };
|
|
15
|
+
export const redisSettingsDescriptor = createRuntimeAsset({
|
|
16
|
+
kind: 'config/manifest',
|
|
17
|
+
id: REDIS_SETTINGS_MANIFEST_ID,
|
|
18
|
+
name: 'Redis',
|
|
19
|
+
namespace: 'integrations',
|
|
20
|
+
description: 'Redis client settings (the connection URL is the REDIS_URL secret)',
|
|
21
|
+
tier: 'user',
|
|
22
|
+
category: 'integrations',
|
|
23
|
+
schema: RedisSettingsSchema,
|
|
24
|
+
fields: {
|
|
25
|
+
maxRetriesPerRequest: { ui: { label: 'Retries per request', component: 'number', group: 'redis' } },
|
|
26
|
+
enableReadyCheck: { ui: { label: 'Ready check', component: 'switch', group: 'redis' } }
|
|
27
|
+
},
|
|
28
|
+
groups: [{ id: 'redis', label: 'Redis' }],
|
|
29
|
+
allowedAdapters: ['storage.localdb', 'storage.json'],
|
|
30
|
+
defaultAdapter: 'storage.localdb',
|
|
31
|
+
scope: 'auto',
|
|
32
|
+
customTables: false,
|
|
33
|
+
version: 1,
|
|
34
|
+
internal: false,
|
|
35
|
+
context: { surfaces: ['cli', 'tui'] },
|
|
36
|
+
enabled: true
|
|
37
|
+
});
|
|
38
|
+
export default redisSettingsDescriptor;
|
|
39
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAsB,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,CAAC,MAAM,0BAA0B,GAAG,oBAAoB,CAAC;AAE/D,iEAAiE;AACjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,EAAE,EAAE,0BAA0B,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;AAErG,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;IACzD,IAAI,EAAE,iBAAiB;IACvB,EAAE,EAAE,0BAA0B;IAC9B,IAAI,EAAE,OAAO;IACb,SAAS,EAAE,cAAc;IACzB,WAAW,EAAE,oEAAoE;IACjF,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,cAAc;IACxB,MAAM,EAAE,mBAAmB;IAC3B,MAAM,EAAE;QACP,oBAAoB,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QACnG,gBAAgB,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;KACvF;IACD,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IACzC,eAAe,EAAE,CAAC,iBAAiB,EAAE,cAAc,CAAC;IACpD,cAAc,EAAE,iBAAiB;IACjC,KAAK,EAAE,MAAM;IACb,YAAY,EAAE,KAAK;IACnB,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE;IACrC,OAAO,EAAE,IAAI;CACb,CAAC,CAAC;AAEH,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type Redis from 'ioredis';
|
|
2
|
+
import { type RedisConnectionManager } from './manager.ts';
|
|
3
|
+
import type { RuntimeRef } from '@vibesdotdev/kernel';
|
|
4
|
+
import { type RedisConnectionConfig } from './schemas/connection.ts';
|
|
5
|
+
export type { RedisConnectionConfig } from './schemas/connection.ts';
|
|
6
|
+
export { REDIS_URL, redisPurposeUrlKey, resolveRedisUrl } from './manager.ts';
|
|
7
|
+
export declare enum RedisConnectionPurpose {
|
|
8
|
+
CACHE = "cache",
|
|
9
|
+
SESSIONS = "sessions",
|
|
10
|
+
WORKERS = "workers",
|
|
11
|
+
PUBSUB = "pubsub",
|
|
12
|
+
GPU_QUEUE = "gpu_queue",
|
|
13
|
+
MODEL_REGISTRY = "model_registry"
|
|
14
|
+
}
|
|
15
|
+
/** The Redis connections of one runtime, one per purpose. */
|
|
16
|
+
export declare class RedisConnections {
|
|
17
|
+
private readonly runtime;
|
|
18
|
+
private readonly ownedManager?;
|
|
19
|
+
private readonly pending;
|
|
20
|
+
private closing;
|
|
21
|
+
private connections;
|
|
22
|
+
private connectionConfigs;
|
|
23
|
+
constructor(runtime: RuntimeRef, ownedManager?: (() => RedisConnectionManager) | undefined);
|
|
24
|
+
private get manager();
|
|
25
|
+
/** Resolve `purpose`'s connection config on first use (its URL is a credential), never at import. */
|
|
26
|
+
private configFor;
|
|
27
|
+
/**
|
|
28
|
+
* Get or create a Redis connection for a specific purpose
|
|
29
|
+
* Returns null only on a declared build host, which never connects. A
|
|
30
|
+
* missing URL, a credential-store failure, or a Redis that refuses the
|
|
31
|
+
* connection rejects with a typed `UNAVAILABLE` error.
|
|
32
|
+
*/
|
|
33
|
+
getConnection(purpose: RedisConnectionPurpose): Promise<Redis | null>;
|
|
34
|
+
private acquire;
|
|
35
|
+
/**
|
|
36
|
+
* Get configuration for a specific purpose
|
|
37
|
+
*/
|
|
38
|
+
getConfig(purpose: RedisConnectionPurpose): Promise<RedisConnectionConfig>;
|
|
39
|
+
/**
|
|
40
|
+
* Close a specific connection
|
|
41
|
+
*/
|
|
42
|
+
closeConnection(purpose: RedisConnectionPurpose): Promise<void>;
|
|
43
|
+
dispose(manager: RedisConnectionManager): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Close all connections
|
|
46
|
+
*/
|
|
47
|
+
closeAll(): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
export declare function redisConnectionsFor(runtime: RuntimeRef): RedisConnections;
|
|
50
|
+
export declare function getCacheConnection(runtime: RuntimeRef): Promise<Redis | null>;
|
|
51
|
+
export declare function getSessionsConnection(runtime: RuntimeRef): Promise<Redis | null>;
|
|
52
|
+
export declare function getWorkersConnection(runtime: RuntimeRef): Promise<Redis | null>;
|
|
53
|
+
export declare function getPubSubConnection(runtime: RuntimeRef): Promise<Redis | null>;
|
|
54
|
+
export declare function getGPUQueueConnection(runtime: RuntimeRef): Promise<Redis | null>;
|
|
55
|
+
export declare function getModelRegistryConnection(runtime: RuntimeRef): Promise<Redis | null>;
|
|
56
|
+
//# sourceMappingURL=connections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../src/connections.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAyE,KAAK,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAClI,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAA+B,KAAK,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAClG,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAErE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE9E,oBAAY,sBAAsB;IACjC,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,cAAc,mBAAmB;CACjC;AAED,6DAA6D;AAC7D,qBAAa,gBAAgB;IAMhB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAAc,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IALhF,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4D;IACpF,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAwD;IAC3E,OAAO,CAAC,iBAAiB,CAAiE;gBAE7D,OAAO,EAAE,UAAU,EAAmB,YAAY,CAAC,GAAE,MAAM,sBAAsB,aAAA;IAE9G,OAAO,KAAK,OAAO,GAA6F;IAEhH,qGAAqG;YACvF,SAAS;IAcvB;;;;;OAKG;IACH,aAAa,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;YAWvD,OAAO;IAkDrB;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIhF;;OAEG;IACG,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ/D,OAAO,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAa7D;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAM/B;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,UAAU,GAAG,gBAAgB,CAEzE;AAGD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAE7E;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAEhF;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAE/E;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAE9E;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAEhF;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAErF"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { getVibesClient } from '@vibesdotdev/kernel/client';
|
|
2
|
+
import { RedisSettingsSchema, redisSettingsManifest } from "./config.js";
|
|
3
|
+
import { CapabilityError, valueFreeFailure, settle, settleNow } from '@vibesdotdev/kernel';
|
|
4
|
+
import { redisManagerFor, redisClientFor, resolveRedisUrl, isDeclaredBuildHost } from "./manager.js";
|
|
5
|
+
import { RedisConnectionConfigSchema } from "./schemas/connection.js";
|
|
6
|
+
export { REDIS_URL, redisPurposeUrlKey, resolveRedisUrl } from "./manager.js";
|
|
7
|
+
export var RedisConnectionPurpose;
|
|
8
|
+
(function (RedisConnectionPurpose) {
|
|
9
|
+
RedisConnectionPurpose["CACHE"] = "cache";
|
|
10
|
+
RedisConnectionPurpose["SESSIONS"] = "sessions";
|
|
11
|
+
RedisConnectionPurpose["WORKERS"] = "workers";
|
|
12
|
+
RedisConnectionPurpose["PUBSUB"] = "pubsub";
|
|
13
|
+
RedisConnectionPurpose["GPU_QUEUE"] = "gpu_queue";
|
|
14
|
+
RedisConnectionPurpose["MODEL_REGISTRY"] = "model_registry";
|
|
15
|
+
})(RedisConnectionPurpose || (RedisConnectionPurpose = {}));
|
|
16
|
+
/** The Redis connections of one runtime, one per purpose. */
|
|
17
|
+
export class RedisConnections {
|
|
18
|
+
runtime;
|
|
19
|
+
ownedManager;
|
|
20
|
+
pending = new Map();
|
|
21
|
+
closing = false;
|
|
22
|
+
connections = new Map();
|
|
23
|
+
connectionConfigs = new Map();
|
|
24
|
+
constructor(runtime, ownedManager) {
|
|
25
|
+
this.runtime = runtime;
|
|
26
|
+
this.ownedManager = ownedManager;
|
|
27
|
+
}
|
|
28
|
+
get manager() { return this.ownedManager?.() ?? redisManagerFor(this.runtime); }
|
|
29
|
+
/** Resolve `purpose`'s connection config on first use (its URL is a credential), never at import. */
|
|
30
|
+
async configFor(purpose) {
|
|
31
|
+
const known = this.connectionConfigs.get(purpose);
|
|
32
|
+
if (known)
|
|
33
|
+
return known;
|
|
34
|
+
const url = await resolveRedisUrl(this.runtime, purpose);
|
|
35
|
+
const settings = await (await getVibesClient('config', this.runtime)).read(redisSettingsManifest);
|
|
36
|
+
const config = RedisConnectionConfigSchema.parse({
|
|
37
|
+
url,
|
|
38
|
+
options: settings.purposes[purpose],
|
|
39
|
+
readinessTimeoutMs: settings.readinessTimeoutMs
|
|
40
|
+
});
|
|
41
|
+
this.connectionConfigs.set(purpose, config);
|
|
42
|
+
return config;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get or create a Redis connection for a specific purpose
|
|
46
|
+
* Returns null only on a declared build host, which never connects. A
|
|
47
|
+
* missing URL, a credential-store failure, or a Redis that refuses the
|
|
48
|
+
* connection rejects with a typed `UNAVAILABLE` error.
|
|
49
|
+
*/
|
|
50
|
+
getConnection(purpose) {
|
|
51
|
+
if (this.closing)
|
|
52
|
+
return Promise.reject(new CapabilityError('Redis is disposing', 'CANCELLED', { reason: 'redis-disposing' }));
|
|
53
|
+
const pending = this.pending.get(purpose);
|
|
54
|
+
if (pending)
|
|
55
|
+
return pending;
|
|
56
|
+
const attempt = this.acquire(purpose).finally(() => {
|
|
57
|
+
if (this.pending.get(purpose) === attempt)
|
|
58
|
+
this.pending.delete(purpose);
|
|
59
|
+
});
|
|
60
|
+
this.pending.set(purpose, attempt);
|
|
61
|
+
return attempt;
|
|
62
|
+
}
|
|
63
|
+
async acquire(purpose) {
|
|
64
|
+
// A declared finite build (prerender) never connects.
|
|
65
|
+
if (isDeclaredBuildHost(this.runtime)) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
const existing = this.connections.get(purpose);
|
|
69
|
+
if (existing && existing.status !== 'end') {
|
|
70
|
+
await this.manager.waitForConnection(existing, this.runtime.lifecycle, this.connectionConfigs.get(purpose)?.readinessTimeoutMs);
|
|
71
|
+
return existing;
|
|
72
|
+
}
|
|
73
|
+
// A missing URL or a credential store failure propagates, typed.
|
|
74
|
+
const config = await this.configFor(purpose);
|
|
75
|
+
let connection;
|
|
76
|
+
const acquired = await settle(async () => {
|
|
77
|
+
// Create the connection through the manager this runtime owns
|
|
78
|
+
connection = this.manager.createConnection(this.runtime, config.url, config.options);
|
|
79
|
+
// Store in our map
|
|
80
|
+
this.connections.set(purpose, connection);
|
|
81
|
+
await this.manager.waitForConnection(connection, this.runtime.lifecycle, config.readinessTimeoutMs);
|
|
82
|
+
const readyConnection = connection;
|
|
83
|
+
await this.runtime.lifecycle.wait(signal => new Promise((resolve, reject) => {
|
|
84
|
+
const abort = () => reject(signal.reason);
|
|
85
|
+
if (signal.aborted) {
|
|
86
|
+
abort();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
90
|
+
readyConnection.ping().then(resolve, reject).finally(() => signal.removeEventListener('abort', abort));
|
|
91
|
+
}), { timeoutMs: config.readinessTimeoutMs ?? RedisSettingsSchema.parse({}).readinessTimeoutMs, reason: 'redis-ping' });
|
|
92
|
+
return connection;
|
|
93
|
+
});
|
|
94
|
+
if (acquired.ok)
|
|
95
|
+
return acquired.value;
|
|
96
|
+
if (this.connections.get(purpose) === connection)
|
|
97
|
+
this.connections.delete(purpose);
|
|
98
|
+
const failedConnection = connection;
|
|
99
|
+
const cleanup = failedConnection ? settleNow(() => failedConnection.disconnect()) : null;
|
|
100
|
+
const failure = valueFreeFailure(acquired.cause);
|
|
101
|
+
const cause = cleanup && !cleanup.ok
|
|
102
|
+
? new AggregateError([failure, valueFreeFailure(cleanup.cause)], 'Redis acquisition and cleanup failed')
|
|
103
|
+
: failure;
|
|
104
|
+
throw new CapabilityError(`Redis connection for '${purpose}' failed`, 'UNAVAILABLE', { reason: 'redis-connection-failed', retryable: true, details: { purpose, disconnectFailure: cleanup !== null && !cleanup.ok }, cause });
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get configuration for a specific purpose
|
|
108
|
+
*/
|
|
109
|
+
async getConfig(purpose) {
|
|
110
|
+
return this.configFor(purpose);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Close a specific connection
|
|
114
|
+
*/
|
|
115
|
+
async closeConnection(purpose) {
|
|
116
|
+
const connection = this.connections.get(purpose);
|
|
117
|
+
if (connection) {
|
|
118
|
+
await connection.quit();
|
|
119
|
+
if (this.connections.get(purpose) === connection)
|
|
120
|
+
this.connections.delete(purpose);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async dispose(manager) {
|
|
124
|
+
this.closing = true;
|
|
125
|
+
this.connectionConfigs.clear();
|
|
126
|
+
await Promise.allSettled(this.pending.values());
|
|
127
|
+
try {
|
|
128
|
+
await manager.closeAllConnections();
|
|
129
|
+
this.connections.clear();
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
this.connectionConfigs.clear();
|
|
133
|
+
this.closing = false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Close all connections
|
|
138
|
+
*/
|
|
139
|
+
async closeAll() {
|
|
140
|
+
const closePromises = Array.from(this.connections.keys()).map((purpose) => this.closeConnection(purpose));
|
|
141
|
+
await Promise.all(closePromises);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export function redisConnectionsFor(runtime) {
|
|
145
|
+
return redisClientFor(runtime).purposes;
|
|
146
|
+
}
|
|
147
|
+
// Convenience functions for each purpose, on the runtime the caller was handed.
|
|
148
|
+
export function getCacheConnection(runtime) {
|
|
149
|
+
return redisConnectionsFor(runtime).getConnection(RedisConnectionPurpose.CACHE);
|
|
150
|
+
}
|
|
151
|
+
export function getSessionsConnection(runtime) {
|
|
152
|
+
return redisConnectionsFor(runtime).getConnection(RedisConnectionPurpose.SESSIONS);
|
|
153
|
+
}
|
|
154
|
+
export function getWorkersConnection(runtime) {
|
|
155
|
+
return redisConnectionsFor(runtime).getConnection(RedisConnectionPurpose.WORKERS);
|
|
156
|
+
}
|
|
157
|
+
export function getPubSubConnection(runtime) {
|
|
158
|
+
return redisConnectionsFor(runtime).getConnection(RedisConnectionPurpose.PUBSUB);
|
|
159
|
+
}
|
|
160
|
+
export function getGPUQueueConnection(runtime) {
|
|
161
|
+
return redisConnectionsFor(runtime).getConnection(RedisConnectionPurpose.GPU_QUEUE);
|
|
162
|
+
}
|
|
163
|
+
export function getModelRegistryConnection(runtime) {
|
|
164
|
+
return redisConnectionsFor(runtime).getConnection(RedisConnectionPurpose.MODEL_REGISTRY);
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=connections.js.map
|