-
Notifications
You must be signed in to change notification settings - Fork 368
reader subscribe all partitioned topics #705
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -182,6 +182,15 @@ type ConsumerOptions struct { | |
| // > Notice: the NackBackoffPolicy will not work with `consumer.NackID(MessageID)` | ||
| // > because we are not able to get the redeliveryCount from the message ID. | ||
| NackBackoffPolicy NackBackoffPolicy | ||
|
|
||
| // startMessageID internally used by multitopic-reader | ||
| startMessageID MessageID | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ConsumerOptions is a public interface so I don't think we should add package private fields here. Let's remove these. |
||
|
|
||
| // startMessageIDInclusive internally used by multitopic-reader | ||
| startMessageIDInclusive bool | ||
|
|
||
| // subscriptionMode internally used by multitopic-reader | ||
| subscriptionMode subscriptionMode | ||
| } | ||
|
|
||
| // Consumer is an interface that abstracts behavior of Pulsar's consumer | ||
|
|
@@ -248,4 +257,13 @@ type Consumer interface { | |
|
|
||
| // Name returns the name of consumer. | ||
| Name() string | ||
|
|
||
| // lastDequeuedMsg used for setting last dequeued msg id by internal partition consumers | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should be adding private methods to the public interface. I think these should be removed. Also, it seems these are only relevant to the reader implementation so I think these helper functions should live within the reader files. |
||
| lastDequeuedMsg(MessageID) error | ||
|
|
||
| // hasMessages get if messages are available | ||
| hasMessages() (bool, error) | ||
|
|
||
| // messagesInQueue get the number of messages available in queue | ||
| messagesInQueue() int | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1265,6 +1265,10 @@ func (pc *partitionConsumer) _getConn() internal.Connection { | |
| return pc.conn.Load().(internal.Connection) | ||
| } | ||
|
|
||
| func (pc *partitionConsumer) messagesInQueue() int { | ||
| return len(pc.queueCh) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there are multi go routines consuming and producing to this channel this value might not be useful after being read. |
||
| } | ||
|
|
||
| func convertToMessageIDData(msgID trackingMessageID) *pb.MessageIdData { | ||
| if msgID.Undefined() { | ||
| return nil | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| package pulsar | ||
|
|
||
| import ( | ||
| "context" | ||
| "time" | ||
| ) | ||
|
|
||
| func NewMockConsumer() Consumer { | ||
| return &mockConsumer{} | ||
| } | ||
|
|
||
| type mockConsumer struct { | ||
| } | ||
|
|
||
| func (c *mockConsumer) Subscription() string { | ||
| return "" | ||
| } | ||
|
|
||
| func (c *mockConsumer) Unsubscribe() error { | ||
| return nil | ||
| } | ||
|
|
||
| func (c *mockConsumer) Receive(ctx context.Context) (message Message, err error) { | ||
| return nil, nil | ||
| } | ||
|
|
||
| func (c *mockConsumer) Chan() <-chan ConsumerMessage { | ||
| return nil | ||
| } | ||
|
|
||
| func (c *mockConsumer) Ack(msg Message) {} | ||
|
|
||
| func (c *mockConsumer) AckID(msgID MessageID) {} | ||
|
|
||
| func (c *mockConsumer) ReconsumeLater(msg Message, delay time.Duration) {} | ||
|
|
||
| func (c *mockConsumer) Nack(msg Message) {} | ||
|
|
||
| func (c *mockConsumer) NackID(msgID MessageID) {} | ||
|
|
||
| func (c *mockConsumer) Close() {} | ||
|
|
||
| func (c *mockConsumer) Seek(msgID MessageID) error { | ||
| return nil | ||
| } | ||
|
|
||
| func (c *mockConsumer) SeekByTime(time time.Time) error { | ||
| return nil | ||
| } | ||
|
|
||
| func (c *mockConsumer) Name() string { | ||
| return "" | ||
| } | ||
|
|
||
| func (c *mockConsumer) lastDequeuedMsg(msgID MessageID) error { | ||
| return nil | ||
| } | ||
|
|
||
| func (c *mockConsumer) messagesInQueue() int { | ||
| return 0 | ||
| } | ||
|
|
||
| func (c *mockConsumer) hasMessages() (bool, error) { | ||
| return false, nil | ||
| } |
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.
What's the different between a reader and a multi reader? It seems like they should be the same but just consume a different number of partitions?