@axiom-lattice/queue-redis 1.0.3 → 1.0.4
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/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +8 -0
- package/README.md +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/tsconfig.json +1 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @axiom-lattice/queue-redis@1.0.
|
|
2
|
+
> @axiom-lattice/queue-redis@1.0.4 build /home/runner/work/agentic/agentic/packages/queue-redis
|
|
3
3
|
> tsup src/index.ts --format cjs,esm --dts --sourcemap
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
[34mESM[39m Build start
|
|
11
11
|
[32mCJS[39m [1mdist/index.js [22m[32m3.72 KB[39m
|
|
12
12
|
[32mCJS[39m [1mdist/index.js.map [22m[32m5.58 KB[39m
|
|
13
|
-
[32mCJS[39m ⚡️ Build success in
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 82ms
|
|
14
14
|
[32mESM[39m [1mdist/index.mjs [22m[32m2.69 KB[39m
|
|
15
15
|
[32mESM[39m [1mdist/index.mjs.map [22m[32m5.48 KB[39m
|
|
16
|
-
[32mESM[39m ⚡️ Build success in
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 81ms
|
|
17
17
|
[34mDTS[39m Build start
|
|
18
|
-
[32mDTS[39m ⚡️ Build success in
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 27790ms
|
|
19
19
|
[32mDTS[39m [1mdist/index.d.ts [22m[32m1.14 KB[39m
|
|
20
20
|
[32mDTS[39m [1mdist/index.d.mts [22m[32m1.14 KB[39m
|
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/RedisQueueClient.ts"],"sourcesContent":["export * from \"./RedisQueueClient\";\n\n","/**\n * RedisQueueClient\n *\n * Redis-based queue service implementation\n */\n\nimport { createClient, RedisClientType } from \"redis\";\nimport { QueueClient, QueueResult } from \"@axiom-lattice/protocols\";\n\n/**\n * Redis queue client options\n */\nexport interface RedisQueueClientOptions {\n redisUrl?: string;\n redisPassword?: string;\n}\n\n/**\n * Redis-based queue client implementation\n */\nexport class RedisQueueClient implements QueueClient {\n private queueName: string;\n private redisUrl?: string;\n private redisPassword?: string;\n private redisClient: RedisClientType | null = null;\n private isConnecting = false;\n private connectionPromise: Promise<void> | null = null;\n\n constructor(queueName: string = \"tasks\", options?: RedisQueueClientOptions) {\n this.queueName = queueName;\n this.redisUrl =\n options?.redisUrl || process.env.REDIS_URL || \"redis://localhost:6379\";\n this.redisPassword = options?.redisPassword || process.env.REDIS_PASSWORD;\n }\n\n /**\n * Lazy initialization of Redis client\n */\n private async getRedisClient(): Promise<RedisClientType> {\n // If client is already connected, return it\n if (this.redisClient?.isOpen) {\n return this.redisClient;\n }\n\n // If connection is in progress, wait for it\n if (this.isConnecting && this.connectionPromise) {\n await this.connectionPromise;\n if (this.redisClient?.isOpen) {\n return this.redisClient;\n }\n }\n\n // Create and connect to Redis client\n this.isConnecting = true;\n this.connectionPromise = (async () => {\n try {\n const redisOptions: any = {\n url: this.redisUrl,\n password: this.redisPassword,\n };\n\n this.redisClient = createClient(redisOptions) as RedisClientType;\n\n this.redisClient.on(\"error\", (err: Error) =>\n console.error(\"Redis Client Error\", err)\n );\n\n await this.redisClient.connect();\n console.log(\"Redis connection successful\");\n this.isConnecting = false;\n } catch (error) {\n console.error(\"Redis connection failed:\", error);\n this.isConnecting = false;\n throw error;\n }\n })();\n\n await this.connectionPromise;\n return this.redisClient!;\n }\n\n /**\n * Enqueue message\n */\n async push(item: any): Promise<QueueResult<number>> {\n try {\n const client = await this.getRedisClient();\n // Push message to queue\n const result = await client.lPush(this.queueName, JSON.stringify(item));\n console.log(\"lPush\", result);\n return { data: result, error: null };\n } catch (error) {\n console.error(error);\n return { data: null, error };\n }\n }\n\n /**\n * Dequeue message\n */\n async pop(): Promise<QueueResult<any>> {\n try {\n const client = await this.getRedisClient();\n // Get message from queue\n const message = await client.rPop(this.queueName);\n if (message) {\n return { data: JSON.parse(message), error: null };\n }\n return { data: null, error: null };\n } catch (error) {\n console.error(error);\n return { data: null, error };\n }\n }\n\n /**\n * Create queue (Redis doesn't need explicit queue creation, but we keep this function for API compatibility)\n */\n async createQueue(): Promise<{\n success: boolean;\n queue_name?: string;\n error?: any;\n }> {\n try {\n const client = await this.getRedisClient();\n const exists = await client.exists(this.queueName);\n return { success: true, queue_name: this.queueName };\n } catch (error) {\n console.error(error);\n return { success: false, error };\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,mBAA8C;AAcvC,IAAM,mBAAN,MAA8C;AAAA,EAQnD,YAAY,YAAoB,SAAS,SAAmC;AAJ5E,SAAQ,cAAsC;AAC9C,SAAQ,eAAe;AACvB,SAAQ,oBAA0C;AAGhD,SAAK,YAAY;AACjB,SAAK,WACH,SAAS,YAAY,QAAQ,IAAI,aAAa;AAChD,SAAK,gBAAgB,SAAS,iBAAiB,QAAQ,IAAI;AAAA,EAC7D;AAAA;AAAA;AAAA;AAAA,EAKA,MAAc,iBAA2C;AAEvD,QAAI,KAAK,aAAa,QAAQ;AAC5B,aAAO,KAAK;AAAA,IACd;AAGA,QAAI,KAAK,gBAAgB,KAAK,mBAAmB;AAC/C,YAAM,KAAK;AACX,UAAI,KAAK,aAAa,QAAQ;AAC5B,eAAO,KAAK;AAAA,MACd;AAAA,IACF;AAGA,SAAK,eAAe;AACpB,SAAK,qBAAqB,YAAY;AACpC,UAAI;AACF,cAAM,eAAoB;AAAA,UACxB,KAAK,KAAK;AAAA,UACV,UAAU,KAAK;AAAA,QACj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K,SAAS;AACjD,aAAO,EAAE,SAAS,MAAM,YAAY,KAAK,UAAU;AAAA,IACrD,SAAS,OAAO;AACd,cAAQ,MAAM,KAAK;AACnB,aAAO,EAAE,SAAS,OAAO,MAAM;AAAA,IACjC;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/RedisQueueClient.ts"],"sourcesContent":["export * from \"./RedisQueueClient\";\n\n\n","/**\n * RedisQueueClient\n *\n * Redis-based queue service implementation\n */\n\nimport { createClient, RedisClientType } from \"redis\";\nimport { QueueClient, QueueResult } from \"@axiom-lattice/protocols\";\n\n/**\n * Redis queue client options\n */\nexport interface RedisQueueClientOptions {\n redisUrl?: string;\n redisPassword?: string;\n}\n\n/**\n * Redis-based queue client implementation\n */\nexport class RedisQueueClient implements QueueClient {\n private queueName: string;\n private redisUrl?: string;\n private redisPassword?: string;\n private redisClient: RedisClientType | null = null;\n private isConnecting = false;\n private connectionPromise: Promise<void> | null = null;\n\n constructor(queueName: string = \"tasks\", options?: RedisQueueClientOptions) {\n this.queueName = queueName;\n this.redisUrl =\n options?.redisUrl || process.env.REDIS_URL || \"redis://localhost:6379\";\n this.redisPassword = options?.redisPassword || process.env.REDIS_PASSWORD;\n }\n\n /**\n * Lazy initialization of Redis client\n */\n private async getRedisClient(): Promise<RedisClientType> {\n // If client is already connected, return it\n if (this.redisClient?.isOpen) {\n return this.redisClient;\n }\n\n // If connection is in progress, wait for it\n if (this.isConnecting && this.connectionPromise) {\n await this.connectionPromise;\n if (this.redisClient?.isOpen) {\n return this.redisClient;\n }\n }\n\n // Create and connect to Redis client\n this.isConnecting = true;\n this.connectionPromise = (async () => {\n try {\n const redisOptions: any = {\n url: this.redisUrl,\n password: this.redisPassword,\n };\n\n this.redisClient = createClient(redisOptions) as RedisClientType;\n\n this.redisClient.on(\"error\", (err: Error) =>\n console.error(\"Redis Client Error\", err)\n );\n\n await this.redisClient.connect();\n console.log(\"Redis connection successful\");\n this.isConnecting = false;\n } catch (error) {\n console.error(\"Redis connection failed:\", error);\n this.isConnecting = false;\n throw error;\n }\n })();\n\n await this.connectionPromise;\n return this.redisClient!;\n }\n\n /**\n * Enqueue message\n */\n async push(item: any): Promise<QueueResult<number>> {\n try {\n const client = await this.getRedisClient();\n // Push message to queue\n const result = await client.lPush(this.queueName, JSON.stringify(item));\n console.log(\"lPush\", result);\n return { data: result, error: null };\n } catch (error) {\n console.error(error);\n return { data: null, error };\n }\n }\n\n /**\n * Dequeue message\n */\n async pop(): Promise<QueueResult<any>> {\n try {\n const client = await this.getRedisClient();\n // Get message from queue\n const message = await client.rPop(this.queueName);\n if (message) {\n return { data: JSON.parse(message), error: null };\n }\n return { data: null, error: null };\n } catch (error) {\n console.error(error);\n return { data: null, error };\n }\n }\n\n /**\n * Create queue (Redis doesn't need explicit queue creation, but we keep this function for API compatibility)\n */\n async createQueue(): Promise<{\n success: boolean;\n queue_name?: string;\n error?: any;\n }> {\n try {\n const client = await this.getRedisClient();\n const exists = await client.exists(this.queueName);\n return { success: true, queue_name: this.queueName };\n } catch (error) {\n console.error(error);\n return { success: false, error };\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,mBAA8C;AAcvC,IAAM,mBAAN,MAA8C;AAAA,EAQnD,YAAY,YAAoB,SAAS,SAAmC;AAJ5E,SAAQ,cAAsC;AAC9C,SAAQ,eAAe;AACvB,SAAQ,oBAA0C;AAGhD,SAAK,YAAY;AACjB,SAAK,WACH,SAAS,YAAY,QAAQ,IAAI,aAAa;AAChD,SAAK,gBAAgB,SAAS,iBAAiB,QAAQ,IAAI;AAAA,EAC7D;AAAA;AAAA;AAAA;AAAA,EAKA,MAAc,iBAA2C;AAEvD,QAAI,KAAK,aAAa,QAAQ;AAC5B,aAAO,KAAK;AAAA,IACd;AAGA,QAAI,KAAK,gBAAgB,KAAK,mBAAmB;AAC/C,YAAM,KAAK;AACX,UAAI,KAAK,aAAa,QAA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EAAE,MAAM,MAAM,MAAM;AAAA,IAC7B;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,cAIH;AACD,QAAI;AACF,YAAM,SAAS,MAAM,KAAK,eAAe;AACzC,YAAM,SAAS,MAAM,OAAO,OAAO,KAAK,SAAS;AACjD,aAAO,EAAE,SAAS,MAAM,YAAY,KAAK,UAAU;AAAA,IACrD,SAAS,OAAO;AACd,cAAQ,MAAM,KAAK;AACnB,aAAO,EAAE,SAAS,OAAO,MAAM;AAAA,IACjC;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axiom-lattice/queue-redis",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Redis queue client implementation for Axiom Lattice framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"redis": "^5.0.1",
|
|
25
|
-
"@axiom-lattice/protocols": "2.1.
|
|
25
|
+
"@axiom-lattice/protocols": "2.1.5"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^20.11.24",
|
package/src/index.ts
CHANGED
package/tsconfig.json
CHANGED