-
Notifications
You must be signed in to change notification settings - Fork 21
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
http客户端 #32
base: dev
Are you sure you want to change the base?
http客户端 #32
Conversation
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.
nice,还有一点小问题,你改好后面我切下来写几个 example,重构看看效果
client/http/client.go
Outdated
type HttpClient struct { | ||
registry *Registry | ||
host string // 用户服务器地址,如 http://localhost:8080 | ||
endpoint string // ecron服务器地址,如 http://www.ecron.com:80 |
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.
你不需要这个!!!
client/http/client.go
Outdated
return | ||
} | ||
|
||
t, exist := c.registry.tasks[name] |
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.
这个定义到 registry 上,GetTask 这种方法
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.
尽量避免访问字段的字段,这不是一个好的习惯
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.
其实我就是想把大部分管理任务本身的方法挪过去 registry 里面,这个就只专注暴露为 HTTP 接口
#28 http客户端
Registry 里面我使用map存储用户注册的任务
客户端监听用户指定的 prefix,然后根据任务名去执行相应的Task
用户在注册任务时要保证任务名称不重复,否则会在注册时panic