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

[Feature] Discussion on the definition and usage of event interface #1201

Open
shenqidebaozi opened this issue Jul 17, 2021 · 14 comments
Open
Assignees
Labels

Comments

@shenqidebaozi
Copy link
Sponsor Member

shenqidebaozi commented Jul 17, 2021

背景

在实际业务场景中,框架需要接入消息队列,消息队列的接入方式有很多种,框架中应提供抽象接口,并提供一些默认实现,如 kafka 等

相关资料

@shenqidebaozi shenqidebaozi added this to the v2.2.0 milestone Jul 17, 2021
@tonybase
Copy link
Member

tonybase commented Jul 19, 2021

type Message interface {
    Key() string
    Value() []byte
    Header() map[string]string
    Ack() error
    Nack() error
}

type Handler func(context.Context, Message) error

type Event interface {
    Send(ctx context.Context, key string, value []byte]) error
    Receive(ctx context.Context, handler Handler) error
    Close() error
}

可以通过 ctx 结合 metadata 进行传递调用信息

@shenqidebaozi
Copy link
Sponsor Member Author

shenqidebaozi commented Jul 19, 2021

@ymh199478

优化的格式,已在下方评论

@ymh199478
Copy link
Member

type Sender interface {
   Send(ctx context.Context, msg Message) error
}
type Receiver interface {
   Get(ctx context.Context) (Message, error)
   Ack(msg Message) error
   Nack(msg Message) error
}

@Windfarer
Copy link
Member

可不可以有BatchSend和BatchGet

@kagaya85
Copy link
Member

kagaya85 commented Jul 19, 2021

@shenqidebaozi
Copy link
Sponsor Member Author

shenqidebaozi commented Jul 19, 2021

可不可以有BatchSend和BatchGet

@Windfarer 接口应该不包含把,实现的时候自己加上。接口保证最小粒度。

@Windfarer
Copy link
Member

用单个请求拼成batch,和直接调batch,性能是有差别的

可不可以有BatchSend和BatchGet

@Windfarer 接口应该不包含把,实现的时候自己加上。接口保证最小粒度。

@che-io
Copy link

che-io commented Jul 21, 2021

有没有可能考虑像pulsar 这样的mq 结构,如shcema等

@MarsonShine
Copy link

事件接口的方法中的 Receive 语义上应该是有返回结构的,这里应该是 publish - subscribe / send - receive 互相匹配

@tonybase tonybase mentioned this issue Jul 25, 2021
16 tasks
@Reasno
Copy link

Reasno commented Jul 25, 2021

用单个请求拼成batch,和直接调batch,性能是有差别的

可不可以有BatchSend和BatchGet

@Windfarer 接口应该不包含把,实现的时候自己加上。接口保证最小粒度。

提醒一下,大多数MQ实现不能保证Batch的原子性,即可能会出现batch中部分成功,部分失败的后果。

@Reasno
Copy link

Reasno commented Jul 25, 2021

event接口可以考虑支持async API: https://www.asyncapi.com/

CloudEvent这种标准,对serverless场景做了太多倾斜。相比较下,AsyncAPI更符合实际工业场景。

@gozelus
Copy link

gozelus commented Aug 24, 2021

这个有计划吗?

@letian0805
Copy link
Contributor

type Sender interface {
   Send(ctx context.Context, msg Message) error
}
type Receiver interface {
   Get(ctx context.Context) (Message, error)
   Ack(msg Message) error
   Nack(msg Message) error
}
type Receiver interface {
   Receive(ctx context.Context) (Message, error)
   Ack(msg Message) error
   Nack(msg Message) error
}

@shenqidebaozi shenqidebaozi changed the title [Feature] Event 接口的定义及使用方式的讨论 [Feature] Discussion on the definition and usage of event interface Jan 19, 2022
@shenqidebaozi shenqidebaozi modified the milestones: v2.2.0, v2.3.0 Feb 21, 2022
@Casper-Mars
Copy link
Contributor

@shenqidebaozi shenqidebaozi removed this from the v2.3.0 milestone May 24, 2022
@shenqidebaozi shenqidebaozi reopened this Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests