Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[fix] use string and []byte to store resource #49

Merged
merged 1 commit into from
Dec 27, 2021

Conversation

robotLJW
Copy link
Contributor

@robotLJW robotLJW commented Dec 27, 2021

【issue】:#47
【修改内容】:
1、将原先 task 中的datatype和data修改成resource和resourceType,将原先的 interface 修改成[]byte
2、将service、schema、account、role都实现了上诉的 resource 接口
3、修改了task中的task_id字段为id(因为task有点多余),还有就是换了下 task 中几个字段的位置,按重要性拍了个序
【修改原因】:因为struct里面含有interface,marshal后再unmarshal回来,相应的结构体无法解析,有好几种解决方案。还是转换为[]byte,后unmarshal后再次unmarshal对应的资源类型就可以了
【影响范围】:无

sync/task.go Outdated
// NewTask return task with action and datatype
func NewTask(domain, project, action, dataType string) (*Task, error) {
type Resource interface {
GetType() string
Copy link
Member

Choose a reason for hiding this comment

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

没必要接口,这有什么用

@@ -379,6 +382,14 @@ type ConsumerDependency struct {
Override bool `protobuf:"varint,3,opt,name=override" json:"override,omitempty"`
}

func (c *ConsumerDependency) GetType() string {
Copy link
Member

Choose a reason for hiding this comment

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

不能这么搞,考虑关注点分离,业务领域模型怎么可能理解同步任务机制?

sync/task.go Outdated
}

// NewTask return task with domain, project action and resource
func NewTask(domain, project, action string, resource Resource) (*Task, error) {
Copy link
Member

Choose a reason for hiding this comment

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

用这个函数签名

func NewTask(ctx context.Context, action string, resourceType string, resource interface{})

@tianxiaoliang tianxiaoliang merged commit 53aa20c into go-chassis:main Dec 27, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants