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

ETCD/Redis supports "BatchPut" #527

Merged
merged 1 commit into from
Jan 2, 2022

Conversation

DuodenumL
Copy link
Contributor

之前store/meta/meta.go中的KV有BatchCreate / BatchUpdate,但是没有能支持upsert操作的方法,这在一些情况下可能会造成问题(要求所有key必须全部存在/不存在,否则就报错)。所以这次加了个BatchPut方法,语义就是upsert。

@DuodenumL
Copy link
Contributor Author

用了这个之后UpdateNodes就不能在ETCD事务层面上保证这个node存在了。

但是其实Calcium里SetNode是加了个锁的,所以不会存在“SetNode过程中这个node突然被删了”的问题,除非有人手动操作。

@@ -52,12 +53,15 @@ func GetEngineFromCache(ctx context.Context, config types.Config, endpoint, ca,
RemoveEngineFromCache(endpoint, ca, cert, key)
return nil
}
log.Debugf(ctx, "[GetEngineFromCache] %v success, key %v", endpoint, cacheKey)
Copy link
Member

@jschwinger233 jschwinger233 Dec 29, 2021

Choose a reason for hiding this comment

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

感觉这条日志会暴多 要不在创建 client 的时候打日志 这样可以反过来知道被 cache 了

return client
}

// RemoveEngineFromCache .
func RemoveEngineFromCache(endpoint, ca, cert, key string) {
engineCache.Delete(getEngineCacheKey(endpoint, ca, cert, key))
cacheKey := getEngineCacheKey(endpoint, ca, cert, key)
log.Debugf(context.TODO(), "[RemoveEngineFromCache] remove %v, key %v", endpoint, cacheKey)
Copy link
Member

Choose a reason for hiding this comment

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

cache 发生变化的时候可以有日志 因为不会很多

Copy link
Contributor Author

Choose a reason for hiding this comment

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

那这里不打debug,打info?

Copy link
Member

Choose a reason for hiding this comment

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

不是业务日志 还是 debug 算了 反而我们都设置的 debug 级别

@DuodenumL DuodenumL force-pushed the feature/endpoint branch 2 times, most recently from 4cbfbf4 to c3c6b81 Compare December 29, 2021 09:55
@jschwinger233 jschwinger233 merged commit e547199 into projecteru2:master Jan 2, 2022
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