-
Notifications
You must be signed in to change notification settings - Fork 24
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
define buffer api #28
Conversation
use editorconfig based on https://github.com/dotnet/aspnetcore/blob/main/.editorconfig
… buffer_queue_api # Conflicts: # src/Mocha.Core/Mocha.Core.csproj
{ | ||
IAsyncEnumerable<T> ConsumeAsync(CancellationToken cancellationToken = default); | ||
|
||
ValueTask CommitAsync(); |
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.
commit 和 close 也需要传递CancellationToken吧?
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.
使用场景上,commit是在业务逻辑处理完后。如果没有没有正确的commit会导致重复消费,不太会有需要需要取消的场景。Close是表示当前Consumer被弃用了,如果存在取消close的场景,重新创建一个consumer会更清晰
|
||
public interface IBufferQueue<T> | ||
{ | ||
IBufferProducer<T> CreateProducer(); |
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.
producer 也需要一些参数,比如在队列溢出时是等待还是忽略
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.
目前的设计,队列不会溢出,只会扩容
|
||
namespace Mocha.Core.Buffer; | ||
|
||
public class BufferOptionsBuilder |
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.
文件名和类名对齐一下
public MemoryBufferOptions AddTopic<T>(int partitionNumber) | ||
{ | ||
_services.AddSingleton<IBufferQueue<T>>(new MemoryBufferQueue<T>(partitionNumber)); | ||
return this; |
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.
可以考虑加一个 MemoryBufferQueueProvider
接口,MemoryBufferQueue
也可以使用 DI 来创建
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.
使用泛型的话,这里的 topic 和 数据类型绑定的吗?
如果Span
有创建N个Topic的场景就不能实现了
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 ☂️ |
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.
LGTM
No description provided.