@uploadista/event-broadcaster-redis 0.0.8 → 0.0.10
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/dist/index.cjs +1 -1
- package/dist/{index.d.ts → index.d.mts} +1 -1
- package/dist/index.d.mts.map +1 -0
- package/dist/{index.js → index.mjs} +1 -1
- package/dist/index.mjs.map +1 -0
- package/package.json +10 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
let e=require(`@uploadista/core/errors`),t=require(`@uploadista/core/types`),n=require(`effect`);function r(t){let{redis:r,subscriberRedis:i}=t;return i.on(`error`,e=>{console.error(`[Redis] Subscriber Error:`,e)}),r.on(`error`,e=>{console.error(`[Redis] Error:`,e)}),{publish:(t,i)=>n.Effect.tryPromise({try:async()=>await r.publish(t,i),catch:n=>(console.error(`[Redis] Failed to publish to ${t}:`,n),e.UploadistaError.fromCode(`UNKNOWN_ERROR`,{cause:n}))}).pipe(n.Effect.asVoid),subscribe:(t,r)=>n.Effect.tryPromise({try:async()=>{await i.subscribe(t,(e,t)=>{r(e)})},catch:n=>(console.error(`[Redis] Failed to subscribe to ${t}:`,n),e.UploadistaError.fromCode(`UNKNOWN_ERROR`,{cause:n}))}).pipe(n.Effect.asVoid),unsubscribe:t=>n.Effect.tryPromise({try:()=>i.unsubscribe(t),catch:t=>e.UploadistaError.fromCode(`UNKNOWN_ERROR`,{cause:t})}).pipe(n.Effect.asVoid)}}const i=e=>n.Layer.succeed(t.EventBroadcasterService,r(e));exports.createRedisEventBroadcaster=r,exports.redisEventBroadcaster=i;
|
|
@@ -30,4 +30,4 @@ declare function createRedisEventBroadcaster(config: RedisEventBroadcasterConfig
|
|
|
30
30
|
declare const redisEventBroadcaster: (config: RedisEventBroadcasterConfig) => Layer.Layer<EventBroadcasterService, never, never>;
|
|
31
31
|
//#endregion
|
|
32
32
|
export { RedisEventBroadcasterConfig, createRedisEventBroadcaster, redisEventBroadcaster };
|
|
33
|
-
//# sourceMappingURL=index.d.
|
|
33
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/redis-event-broadcaster.ts"],"sourcesContent":[],"mappings":";;;;;;;AASA;AAiBA;AAyDa,UA1EI,2BAAA,CA2E4D;EAD/B;;;EAA2B,KAAA,EAtEhE,eAsEgE;;;;;mBAjEtD;;;;;;;iBAQH,2BAAA,SACN,8BACP;;;;cAuDU,gCAAiC,gCAA2B,KAAA,CAAA,MAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{UploadistaError as e}from"@uploadista/core/errors";import{EventBroadcasterService as t}from"@uploadista/core/types";import{Effect as n,Layer as r}from"effect";function i(t){let{redis:r,subscriberRedis:i}=t;return i.on(`error`,e=>{console.error(`[Redis] Subscriber Error:`,e)}),r.on(`error`,e=>{console.error(`[Redis] Error:`,e)}),{publish:(t,i)=>n.tryPromise({try:async()=>await r.publish(t,i),catch:n=>(console.error(`[Redis] Failed to publish to ${t}:`,n),e.fromCode(`UNKNOWN_ERROR`,{cause:n}))}).pipe(n.asVoid),subscribe:(t,r)=>n.tryPromise({try:async()=>{await i.subscribe(t,(e,t)=>{r(e)})},catch:n=>(console.error(`[Redis] Failed to subscribe to ${t}:`,n),e.fromCode(`UNKNOWN_ERROR`,{cause:n}))}).pipe(n.asVoid),unsubscribe:t=>n.tryPromise({try:()=>i.unsubscribe(t),catch:t=>e.fromCode(`UNKNOWN_ERROR`,{cause:t})}).pipe(n.asVoid)}}const a=e=>r.succeed(t,i(e));export{i as createRedisEventBroadcaster,a as redisEventBroadcaster};
|
|
2
|
-
//# sourceMappingURL=index.
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/redis-event-broadcaster.ts"],"sourcesContent":["import type { RedisClientType } from \"@redis/client\";\nimport { UploadistaError } from \"@uploadista/core/errors\";\nimport type { EventBroadcaster } from \"@uploadista/core/types\";\nimport { EventBroadcasterService } from \"@uploadista/core/types\";\nimport { Effect, Layer } from \"effect\";\n\n/**\n * Configuration for Redis event broadcaster\n */\nexport interface RedisEventBroadcasterConfig {\n /**\n * Redis client for publishing messages\n */\n redis: RedisClientType;\n /**\n * Separate Redis client for subscribing to messages\n * (Redis requires a dedicated connection for pub/sub)\n */\n subscriberRedis: RedisClientType;\n}\n\n/**\n * Redis-based event broadcaster for distributed deployments.\n * Uses Redis Pub/Sub to broadcast events across multiple instances.\n * Requires two separate Redis connections (one for pub, one for sub).\n */\nexport function createRedisEventBroadcaster(\n config: RedisEventBroadcasterConfig,\n): EventBroadcaster {\n const { redis, subscriberRedis } = config;\n\n subscriberRedis.on(\"error\", (error) => {\n console.error(`[Redis] Subscriber Error:`, error);\n });\n\n redis.on(\"error\", (error) => {\n console.error(`[Redis] Error:`, error);\n });\n\n return {\n publish: (channel: string, message: string) =>\n Effect.tryPromise({\n try: async () => {\n const result = await redis.publish(channel, message);\n return result;\n },\n catch: (cause) => {\n console.error(`[Redis] Failed to publish to ${channel}:`, cause);\n return UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause,\n });\n },\n }).pipe(Effect.asVoid),\n\n subscribe: (channel: string, handler: (message: string) => void) =>\n Effect.tryPromise({\n try: async () => {\n await subscriberRedis.subscribe(channel, (message, _channel) => {\n handler(message);\n });\n },\n catch: (cause) => {\n console.error(`[Redis] Failed to subscribe to ${channel}:`, cause);\n return UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause,\n });\n },\n }).pipe(Effect.asVoid),\n\n unsubscribe: (channel: string) =>\n Effect.tryPromise({\n try: () => subscriberRedis.unsubscribe(channel),\n catch: (cause) =>\n UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause,\n }),\n }).pipe(Effect.asVoid),\n };\n}\n\n/**\n * Layer factory for Redis event broadcaster\n */\nexport const redisEventBroadcaster = (config: RedisEventBroadcasterConfig) =>\n Layer.succeed(EventBroadcasterService, createRedisEventBroadcaster(config));\n"],"mappings":"sKA0BA,SAAgB,EACd,EACkB,CAClB,GAAM,CAAE,QAAO,mBAAoB,EAUnC,OARA,EAAgB,GAAG,QAAU,GAAU,CACrC,QAAQ,MAAM,4BAA6B,EAAM,EACjD,CAEF,EAAM,GAAG,QAAU,GAAU,CAC3B,QAAQ,MAAM,iBAAkB,EAAM,EACtC,CAEK,CACL,SAAU,EAAiB,IACzB,EAAO,WAAW,CAChB,IAAK,SACY,MAAM,EAAM,QAAQ,EAAS,EAAQ,CAGtD,MAAQ,IACN,QAAQ,MAAM,gCAAgC,EAAQ,GAAI,EAAM,CACzD,EAAgB,SAAS,gBAAiB,CAC/C,QACD,CAAC,EAEL,CAAC,CAAC,KAAK,EAAO,OAAO,CAExB,WAAY,EAAiB,IAC3B,EAAO,WAAW,CAChB,IAAK,SAAY,CACf,MAAM,EAAgB,UAAU,GAAU,EAAS,IAAa,CAC9D,EAAQ,EAAQ,EAChB,EAEJ,MAAQ,IACN,QAAQ,MAAM,kCAAkC,EAAQ,GAAI,EAAM,CAC3D,EAAgB,SAAS,gBAAiB,CAC/C,QACD,CAAC,EAEL,CAAC,CAAC,KAAK,EAAO,OAAO,CAExB,YAAc,GACZ,EAAO,WAAW,CAChB,QAAW,EAAgB,YAAY,EAAQ,CAC/C,MAAQ,GACN,EAAgB,SAAS,gBAAiB,CACxC,QACD,CAAC,CACL,CAAC,CAAC,KAAK,EAAO,OAAO,CACzB,CAMH,MAAa,EAAyB,GACpC,EAAM,QAAQ,EAAyB,EAA4B,EAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uploadista/event-broadcaster-redis",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10",
|
|
5
5
|
"description": "Redis event broadcaster for Uploadista",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Uploadista",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./dist/index.d.
|
|
11
|
-
"import": "./dist/index.
|
|
12
|
-
"
|
|
10
|
+
"types": "./dist/index.d.mts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
13
|
+
"default": "./dist/index.mjs"
|
|
13
14
|
}
|
|
14
15
|
},
|
|
15
16
|
"dependencies": {
|
|
16
17
|
"@redis/client": "5.9.0",
|
|
17
|
-
"effect": "3.
|
|
18
|
-
"@uploadista/core": "0.0.
|
|
18
|
+
"effect": "3.19.0",
|
|
19
|
+
"@uploadista/core": "0.0.10"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
|
-
"@types/node": "24.
|
|
22
|
-
"tsdown": "0.
|
|
23
|
-
"@uploadista/typescript-config": "0.0.
|
|
22
|
+
"@types/node": "24.10.0",
|
|
23
|
+
"tsdown": "0.16.0",
|
|
24
|
+
"@uploadista/typescript-config": "0.0.10"
|
|
24
25
|
},
|
|
25
26
|
"scripts": {
|
|
26
27
|
"build": "tsdown",
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/redis-event-broadcaster.ts"],"sourcesContent":[],"mappings":";;;;;;;AASA;AAiBA;AAyDa,UA1EI,2BAAA,CA2E4D;EAD/B;;;EAA2B,KAAA,EAtEhE,eAsEgE;;;;;mBAjEtD;;;;;;;iBAQH,2BAAA,SACN,8BACP;;;;cAuDU,gCAAiC,gCAA2B,KAAA,CAAA,MAAA"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/redis-event-broadcaster.ts"],"sourcesContent":["import type { RedisClientType } from \"@redis/client\";\nimport { UploadistaError } from \"@uploadista/core/errors\";\nimport type { EventBroadcaster } from \"@uploadista/core/types\";\nimport { EventBroadcasterService } from \"@uploadista/core/types\";\nimport { Effect, Layer } from \"effect\";\n\n/**\n * Configuration for Redis event broadcaster\n */\nexport interface RedisEventBroadcasterConfig {\n /**\n * Redis client for publishing messages\n */\n redis: RedisClientType;\n /**\n * Separate Redis client for subscribing to messages\n * (Redis requires a dedicated connection for pub/sub)\n */\n subscriberRedis: RedisClientType;\n}\n\n/**\n * Redis-based event broadcaster for distributed deployments.\n * Uses Redis Pub/Sub to broadcast events across multiple instances.\n * Requires two separate Redis connections (one for pub, one for sub).\n */\nexport function createRedisEventBroadcaster(\n config: RedisEventBroadcasterConfig,\n): EventBroadcaster {\n const { redis, subscriberRedis } = config;\n\n subscriberRedis.on(\"error\", (error) => {\n console.error(`[Redis] Subscriber Error:`, error);\n });\n\n redis.on(\"error\", (error) => {\n console.error(`[Redis] Error:`, error);\n });\n\n return {\n publish: (channel: string, message: string) =>\n Effect.tryPromise({\n try: async () => {\n const result = await redis.publish(channel, message);\n return result;\n },\n catch: (cause) => {\n console.error(`[Redis] Failed to publish to ${channel}:`, cause);\n return UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause,\n });\n },\n }).pipe(Effect.asVoid),\n\n subscribe: (channel: string, handler: (message: string) => void) =>\n Effect.tryPromise({\n try: async () => {\n await subscriberRedis.subscribe(channel, (message, _channel) => {\n handler(message);\n });\n },\n catch: (cause) => {\n console.error(`[Redis] Failed to subscribe to ${channel}:`, cause);\n return UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause,\n });\n },\n }).pipe(Effect.asVoid),\n\n unsubscribe: (channel: string) =>\n Effect.tryPromise({\n try: () => subscriberRedis.unsubscribe(channel),\n catch: (cause) =>\n UploadistaError.fromCode(\"UNKNOWN_ERROR\", {\n cause,\n }),\n }).pipe(Effect.asVoid),\n };\n}\n\n/**\n * Layer factory for Redis event broadcaster\n */\nexport const redisEventBroadcaster = (config: RedisEventBroadcasterConfig) =>\n Layer.succeed(EventBroadcasterService, createRedisEventBroadcaster(config));\n"],"mappings":"sKA0BA,SAAgB,EACd,EACkB,CAClB,GAAM,CAAE,QAAO,mBAAoB,EAUnC,OARA,EAAgB,GAAG,QAAU,GAAU,CACrC,QAAQ,MAAM,4BAA6B,EAAM,EACjD,CAEF,EAAM,GAAG,QAAU,GAAU,CAC3B,QAAQ,MAAM,iBAAkB,EAAM,EACtC,CAEK,CACL,SAAU,EAAiB,IACzB,EAAO,WAAW,CAChB,IAAK,SACY,MAAM,EAAM,QAAQ,EAAS,EAAQ,CAGtD,MAAQ,IACN,QAAQ,MAAM,gCAAgC,EAAQ,GAAI,EAAM,CACzD,EAAgB,SAAS,gBAAiB,CAC/C,QACD,CAAC,EAEL,CAAC,CAAC,KAAK,EAAO,OAAO,CAExB,WAAY,EAAiB,IAC3B,EAAO,WAAW,CAChB,IAAK,SAAY,CACf,MAAM,EAAgB,UAAU,GAAU,EAAS,IAAa,CAC9D,EAAQ,EAAQ,EAChB,EAEJ,MAAQ,IACN,QAAQ,MAAM,kCAAkC,EAAQ,GAAI,EAAM,CAC3D,EAAgB,SAAS,gBAAiB,CAC/C,QACD,CAAC,EAEL,CAAC,CAAC,KAAK,EAAO,OAAO,CAExB,YAAc,GACZ,EAAO,WAAW,CAChB,QAAW,EAAgB,YAAY,EAAQ,CAC/C,MAAQ,GACN,EAAgB,SAAS,gBAAiB,CACxC,QACD,CAAC,CACL,CAAC,CAAC,KAAK,EAAO,OAAO,CACzB,CAMH,MAAa,EAAyB,GACpC,EAAM,QAAQ,EAAyB,EAA4B,EAAO,CAAC"}
|