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

feat(platform): api service change to stateless #140

Closed
wants to merge 3 commits into from

Conversation

StellarisW
Copy link
Member

@StellarisW StellarisW commented Dec 28, 2023

What type of PR is this?

feat

What this PR does / why we need it (en: English/zh: Chinese):

en: api service change to stateless
zh: 将 api 服务变成无状态的

进行的改动:

  • 重构 redis registry, 去除 builtin registry
  • 修复 log calller 位置错误的问题
  • 调整代码结构

Which issue(s) this PR fixes:

#136


type Registry struct {
agentCache *cache.Cache
rdb redis.UniversalClient
Copy link
Member

Choose a reason for hiding this comment

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

rdb 似乎没有用到

Copy link
Member

Choose a reason for hiding this comment

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

仔细看了一段时间,感觉这里定义是重复的?

Copy link
Member Author

Choose a reason for hiding this comment

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

已删除无用代码

continue
}
case *redis.Client:
err := r.scanServiceKeysAndUpdate(rdb)
Copy link
Member

@li-jin-gou li-jin-gou Dec 28, 2023

Choose a reason for hiding this comment

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

扫全表 redis,一般 redis 的运维会禁用这个操作

Copy link
Member

Choose a reason for hiding this comment

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

  1. 这里需要调整实现.
  2. 另外这里实现的注册和发现都是给 API 用的嘛.

Copy link
Member Author

Choose a reason for hiding this comment

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

已更改redis的更新方式,
通过监控一个hash key和一个redis channel实现

@@ -47,6 +47,8 @@ type ConsistentHashDispatcher struct {
hasher *consistent.Consistent
Tasks map[string]*model.Task
ServiceWithTasks map[string]map[string]*model.Task

IdlIdToTaskIdMap map[int64]string
Copy link
Member

Choose a reason for hiding this comment

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

这里添加这个map的作用是什么

Copy link
Member Author

Choose a reason for hiding this comment

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

目前想通过 idl id 删除 task,只有加这个map才能实现

"github.com/redis/go-redis/v9"
)

func NewRedisRegistry(rdb redis.UniversalClient) *redisregistry.Registry {
Copy link
Member

Choose a reason for hiding this comment

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

builin 和 redis 的实现区别,目前看没区别

Copy link
Member Author

Choose a reason for hiding this comment

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

builtin是只将 agent 服务信息存储在内存,redis是将 agent 服务信息保存在redis中

@Skyenought Skyenought force-pushed the feat-platform-stateless branch 3 times, most recently from ba490d2 to 3d106a2 Compare January 8, 2024 08:04
@Skyenought Skyenought marked this pull request as draft January 8, 2024 08:07
@Skyenought Skyenought force-pushed the feat-platform-stateless branch 2 times, most recently from 344611e to 3f54952 Compare January 8, 2024 08:30
@Skyenought Skyenought force-pushed the feat-platform-stateless branch from 3f54952 to 2f04e17 Compare January 8, 2024 08:34
@Skyenought Skyenought changed the title WIP: feat(platform): api service change to stateless feat(platform): api service change to stateless Jan 8, 2024
@Skyenought Skyenought marked this pull request as ready for review January 8, 2024 08:35
@Skyenought Skyenought marked this pull request as draft January 13, 2024 08:22
@li-jin-gou li-jin-gou closed this Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants