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

remove useless engine check #631

Merged
merged 5 commits into from
Jan 5, 2024
Merged

remove useless engine check #631

merged 5 commits into from
Jan 5, 2024

Conversation

yuyang0
Copy link
Contributor

@yuyang0 yuyang0 commented Dec 30, 2023

No description provided.

}

// NewEngineCache .
func NewEngineCache(config types.Config) *EngineCache {
func NewEngineCache(config types.Config, sto store.Store) *EngineCache {
Copy link
Contributor

Choose a reason for hiding this comment

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

stor 一般缩写用这个

Comment on lines 96 to 103
if _, err := e.sto.GetNodeStatus(ctx, nodename); err != nil && errors.Is(err, types.ErrInvaildCount) {
logger.Warnf(ctx, "node %s is offline, the cache will be removed", nodename)
RemoveEngineFromCache(ctx, params.endpoint, params.ca, params.cert, params.key)
} else {
logger.Errorf(ctx, err, "engine %+v is unavailable, will be replaced and removed", cacheKey)
e.cache.Set(cacheKey, &fake.EngineWithErr{DefaultErr: err})
}
}
Copy link
Contributor

@CMGS CMGS Jan 2, 2024

Choose a reason for hiding this comment

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

if _, err := e.sto.GetNodeStatus(ctx, nodename); err != nil && errors.Is(err, types.ErrInvaildCount) {
    logger.Warnf(ctx, "node %s is offline, the cache will be removed", nodename)
    RemoveEngineFromCache(ctx, params.endpoint, params.ca, params.cert, params.key)
    return
} 
logger.Errorf(ctx, err, "engine %+v is unavailable, will be replaced and removed", cacheKey)
e.cache.Set(cacheKey, &fake.EngineWithErr{DefaultErr: err})

Copy link
Contributor

Choose a reason for hiding this comment

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

还有另外一个小细节是我习惯把 internal 函数后置,放最后……

Copy link
Contributor Author

@yuyang0 yuyang0 Jan 2, 2024

Choose a reason for hiding this comment

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

okay,这里的逻辑其实有点乱,我发现其实现在很多地方隐藏了一个node一个engine的假设,那么确实是这样,代码可以大幅简化,我都怀疑这个checkAlive还有没有用

Copy link
Contributor Author

Choose a reason for hiding this comment

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

本来我是想把engine cache相关的代码从store拆出来的,总觉得这两个搅合到一起不好,但是拆一半拆不动了回滚了,所以给那个metrics调用的接口加了个option,免得一个node挂了,结果因为metrics的定期调用还傻傻的check alive,弄一堆错误日志

@CMGS CMGS merged commit ce65507 into projecteru2:master Jan 5, 2024
3 checks passed
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