eggjs / eggjs/egg

egg-redis 无法使用path方式创建redis客户端

Open
#4,452 0 comments 0 reactions 0 assignees View on GitHub
Inactive
Dominant language
TypeScript
Stars
19k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

## What happens?
egg-redis 在检查配置参数时如果没有host、port等配置会直接报错([代码](https://github.com/eggjs/egg-redis/blob/master/lib/redis.js#L38)),但实际上ioredis是可以通过path方式来创建redis客户端的:

![image](https://user-images.githubusercontent.com/1436694/92196338-a2ff3100-eea1-11ea-8ed3-6486bf18fc7e.png)

## 最小可复现仓库
> 请使用 `npm init egg --type=simple bug` 创建,并上传到你的 GitHub 仓库

## 复现步骤,错误日志以及相关配置

```sh
/Users/zhaozhiming/projects/xxx/node_modules/egg-redis/lib/redis.js:38
assert(config.host && config.port && config.password !== undefined && config.db !== undefined,
^
AssertionError [ERR_ASSERTION]: [egg-redis] 'host: ', 'port: 6379', 'password: ', 'db: 0' are required on config
```

#### 配置信息
```js
config.redis = {
client: {
path: '/my/sock/path',
db: 0,
},
};
```

## 相关环境信息
- **操作系统**:
linux ubuntu 18
- **Node 版本**:
13.14.0
- **Egg 版本**:
2.6.1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.