Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update troubleshooting.md #29

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,25 @@
在 `sqlc.NewNodeConn` 的时候可以通过可选参数 `cache.WithExpiry` 传递,如缓存时间控制为1天,代码如下:
```go
sqlc.NewNodeConn(conn,redis,cache.WithExpiry(24*time.Hour))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有了下文的更新,这个最好删掉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已更改


// 默认生成的
func NewMembersModel(conn sqlx.SqlConn, c cache.CacheConf) MembersModel {
return &customMembersModel{
defaultMembersModel: newMembersModel(conn, c),
}
}


// 修改后的
func NewMembersModel(conn sqlx.SqlConn, c cache.CacheConf) MembersModel {
return &customMembersModel{
defaultMembersModel: &defaultMembersModel{
// 这里设置命中缓存和未命中缓存的过期时间
CachedConn: sqlc.NewConn(conn, c, cache.WithExpiry(time.Minute*2), cache.WithNotFoundExpiry(time.Minute)),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time.Minute2应该替换为 time.Minute24,因为上文举例说的是1天

table: "`members`",
},
}
}
```

### 6. jwt鉴权怎么实现
Expand All @@ -46,4 +65,18 @@ logx.DisableStat()
// client, _ := zrpc.NewClientWithTarget("127.0.0.1:8888")
```

### 10. rpc 服务互相依赖启动挂掉问题
错误详情: rpc dial: discov://127.0.0.1:2379/user.rpc, error: context deadline exceeded, make sure rpc service "user.r
pc" is already started

解决方法: 在`yaml`配置文件配置增加`NonBlock`
```
UserRpc:
NonBlock: true
Etcd:
Hosts:
- 127.0.0.1:2379
Key: user.rpc
```

faq会不定期更新大家遇到的问题,也欢迎大家把常见问题通过pr写在这里。