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

define buffer api #28

Merged
merged 18 commits into from
Nov 24, 2023
Merged

Conversation

eventhorizon-cli
Copy link
Contributor

No description provided.

{
IAsyncEnumerable<T> ConsumeAsync(CancellationToken cancellationToken = default);

ValueTask CommitAsync();
Copy link
Member

Choose a reason for hiding this comment

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

commit 和 close 也需要传递CancellationToken吧?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

使用场景上,commit是在业务逻辑处理完后。如果没有没有正确的commit会导致重复消费,不太会有需要需要取消的场景。Close是表示当前Consumer被弃用了,如果存在取消close的场景,重新创建一个consumer会更清晰


public interface IBufferQueue<T>
{
IBufferProducer<T> CreateProducer();
Copy link
Member

Choose a reason for hiding this comment

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

producer 也需要一些参数,比如在队列溢出时是等待还是忽略

Copy link
Contributor Author

Choose a reason for hiding this comment

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

目前的设计,队列不会溢出,只会扩容


namespace Mocha.Core.Buffer;

public class BufferOptionsBuilder
Copy link
Member

Choose a reason for hiding this comment

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

文件名和类名对齐一下

public MemoryBufferOptions AddTopic<T>(int partitionNumber)
{
_services.AddSingleton<IBufferQueue<T>>(new MemoryBufferQueue<T>(partitionNumber));
return this;
Copy link
Member

Choose a reason for hiding this comment

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

可以考虑加一个 MemoryBufferQueueProvider 接口,MemoryBufferQueue 也可以使用 DI 来创建

Copy link
Member

Choose a reason for hiding this comment

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

使用泛型的话,这里的 topic 和 数据类型绑定的吗?
如果Span 有创建N个Topic的场景就不能实现了

Copy link

codecov bot commented Nov 19, 2023

Welcome to Codecov 🎉

Once merged to your default branch, Codecov will compare your coverage reports and display the results in this comment.

Thanks for integrating Codecov - We've got you covered ☂️

Copy link
Member

@liuhaoyang liuhaoyang left a comment

Choose a reason for hiding this comment

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

LGTM

@liuhaoyang liuhaoyang merged commit 5d25923 into dotnetcore:main Nov 24, 2023
4 checks passed
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