Skip to content

Conversation

@dxinli
Copy link
Contributor

@dxinli dxinli commented Nov 21, 2024

Link to an issue

related issue #82

What

etcd config 添加了 timeout 配置, IsHealth 方法在 Get health key 的 context 添加对应的超时设置

How

etcd config 添加属性以及方法,如果配置无效,则方法会返回默认值 3s,在IsHealth客户端调用前获取config,并调用其方法获取 timeout 配置,并最后根据 timeout 创建 context,传入 Get

Screenshots

How to test

config.yaml 添加对应的 timeout 配置,并停止 etcd 服务,程序将出现超时

Checklist

  • [x ] Link to an issue if it really related.
  • At least describe what this PR does.
  • Use rebase to confirm that current branch doesn't conflict with main branch.
  • Unit tests. At least do not reduce the unit test coverage.
  • Checked and updated guidelines.md which used to describe how to build, deploy and use DouTok.

@codecov
Copy link

codecov bot commented Nov 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅


🚨 Try these New Features:

@TremblingV5
Copy link
Contributor

我看到了你在#82那个issue下的回复。抱歉回复有些晚了。

我认为此处没有必要去为每一套配置加一个超时时间,这个超时时间看起来只会在启动时的健康检查去使用。如果只有健康检查在使用,那么一个写死的值就可以了。当一个服务依赖etcd,服务启动时etcd在写死的时间内都没有响应,那么认为这个服务异常,启动失败都是可以的。

如果想加一个配置项,可以在更高的维度去加,例如在整个app配置中,增加一个healthCheckTimeout这样的字段(名字我随便起的),在服务启动时进行健康检查时使用这个配置项作为超时时间即可

@dxinli
Copy link
Contributor Author

dxinli commented Nov 22, 2024

好的,我也认为没必要在每套配置中提供这么一个配置值,在APP中添加的话,从目前的需求来说感觉还没必要,那就直接写死吧,如果后续出现更多各服务需要相关的配置的话,在做调整

@dxinli
Copy link
Contributor Author

dxinli commented Nov 22, 2024

我已经删除了 etcd 的 Config 的timeout配置,并将超时设置为常量3s

Copy link
Contributor

@TremblingV5 TremblingV5 left a comment

Choose a reason for hiding this comment

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

感谢~

@TremblingV5 TremblingV5 merged commit 4f8d959 into cloudzenith:main Nov 23, 2024
TremblingV5 pushed a commit to TremblingV5/DouTokV2 that referenced this pull request Nov 25, 2024
…loudzenith#86)

## Link to an issue

related issue cloudzenith#82

## What

etcd config 添加了 timeout 配置, IsHealth 方法在 Get health key 的 context
添加对应的超时设置

## How

etcd config 添加属性以及方法,如果配置无效,则方法会返回默认值
3s,在IsHealth客户端调用前获取config,并调用其方法获取 timeout 配置,并最后根据 timeout 创建
context,传入 Get

## Screenshots

<!-- Please add screenshots if we need. -->

## How to test

config.yaml 添加对应的 timeout 配置,并停止 etcd 服务,程序将出现超时

## Checklist

- [x ] Link to an issue if it really related.
- [x] At least describe what this PR does.
- [x] Use `rebase` to confirm that current branch doesn't conflict with
main branch.
- [ ] Unit tests. At least do not reduce the unit test coverage.
- [ ] Checked and updated `guidelines.md` which used to describe how to
build, deploy and use DouTok.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants