-
Notifications
You must be signed in to change notification settings - Fork 42
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
Conversation
engine/factory/factory.go
Outdated
} | ||
|
||
// NewEngineCache . | ||
func NewEngineCache(config types.Config) *EngineCache { | ||
func NewEngineCache(config types.Config, sto store.Store) *EngineCache { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stor
一般缩写用这个
engine/factory/factory.go
Outdated
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}) | ||
} | ||
} |
There was a problem hiding this comment.
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})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
还有另外一个小细节是我习惯把 internal 函数后置,放最后……
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay,这里的逻辑其实有点乱,我发现其实现在很多地方隐藏了一个node一个engine的假设,那么确实是这样,代码可以大幅简化,我都怀疑这个checkAlive还有没有用
There was a problem hiding this comment.
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,弄一堆错误日志
No description provided.