Create @chatcops/store-redis for Upstash and other Redis clients
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
On Vercel and Workers each request can land on a different instance, so in-memory conversations and rate limits don't work there. Upstash Redis is the usual answer for those platforms, since it's reached over HTTP and works on every runtime. This package is the store for it, and for any other Redis client through a small interface.
This is a bigger one, for someone who has had a few PRs merged here. The interfaces and the tests it has to pass already exist: packages/core/src/storage/types.ts and runStorageConformance from @chatcops/core/testing. CONTRIBUTING.md has a "Writing a store package" section with the package layout.
What to do
Create packages/store-redis:
import { Redis } from '@upstash/redis';
import { redisStorage, fromIoRedis } from '@chatcops/store-redis';
storage: redisStorage({ redis: Redis.fromEnv() })
storage: redisStorage({ redis: fromIoRedis(new IORedis(url)) })
// options: prefix (default 'chatcops'), conversationTtlMs (default 30 days)
- All four capabilities:
conversations(withappend,updateMessage,removeMessage,list,purge),counters,kv(withsetIfAbsent) andevents(withquery). - Define a small
RedisLikeinterface with the commands you need.@upstash/redisshould fit it as is, andfromIoRedisadapts ioredis (itsevaltakes arguments differently).@upstash/redisis an optional peer dependency, and ioredis isn't a dependency at all. - Layout:
- a hash per conversation (
created_at,updated_at,version,metadata) - a list of JSON messages per conversation
- a sorted set of conversation ids by
updated_at, forlistandpurge PEXPIREon the conversation keys, so idle conversations expire on their own
- a hash per conversation (
- Anything that reads and then writes runs as one Lua script (
EVAL), so it's atomic:appendwith its version check,updateMessage,removeMessage, and counter increments that set the expiry only on a new key. Upstash supportsEVAL. kv:SETwithPX, andNXforsetIfAbsent. Values are JSON.events: a capped stream (XADDwithMAXLEN ~), or a hash of counts per hour bucket if that makesquerysimpler. Explain your choice in the PR."private": trueinpackage.json. A maintainer publishes it for the first time.
Testing
CI runs Redis and the Upstash REST emulator. CHATCOPS_TEST_UPSTASH_URL with CHATCOPS_TEST_UPSTASH_TOKEN is for @upstash/redis, and CHATCOPS_TEST_REDIS_URL is for ioredis. Run the suite against both. Locally, docker run -p 6379:6379 redis:7-alpine is enough for the ioredis side.
Acceptance criteria
-
runStorageConformancepasses with nothing skipped through@upstash/redisand throughfromIoRedis - Two storages with different prefixes on one Redis don't see each other's data
- A short README with the Vercel setup
- Changeset for
@chatcops/store-redis(minor) -
pnpm -r build,pnpm test:coverage(90% lines, 80% branches for store packages),pnpm lintandpnpm publintpass
Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #<this issue number>. Setup notes (pnpm, build before test) are in CONTRIBUTING.md.
- 主要语言
- TypeScript
- 星标
- 13
- 派生
- 7
- 平均合并
- 4 小时 11 分钟
- 30 天内合并 PR
- 122
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
codercops/chatcops 的其他 Issue
-
enhancement hacktoberfest help wanted server
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
Document the pre-chat form可能已有人在做 @masyarakatai 于 4 天前认领。 未关闭documentation good first issue hacktoberfest widget
难度 2/5 1-3 小时 新手友好度 88/100
codercops/chatcops#70 · 3 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
enhancement hacktoberfest help wanted server
难度 5/5 一周以上 新手友好度 25/100
维护者通常 1 天内回复
-
enhancement hacktoberfest help wanted server
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
-
core enhancement hacktoberfest help wanted
难度 3/5 1-2 天 新手友好度 78/100
维护者通常 1 天内回复
查看 codercops/chatcops 的全部 Issue
相似的 Issue
-
frontend
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 86/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
ranxianglei/billion-context#4172 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
awslabs/threat-composer#362 ·
维护者通常 1 天内回复
-
Area/Cloud Needs Triage Type/Bug
难度 1/5 1-3 小时 新手友好度 86/100
wso2/product-integrator#2847 ·
维护者通常 1 天内回复