Skip to content

Commit

Permalink
init crCh for retry topic when start consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
筱瑜 committed Oct 14, 2022
1 parent cbbe49c commit 003b83f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions consumer/push_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func (pc *pushConsumer) Start() error {
return
}

pc.handleRetryTopic()
go func() {
// todo start clean msg expired
for {
Expand Down Expand Up @@ -238,6 +239,13 @@ func (pc *pushConsumer) Start() error {
return err
}

func (pc *pushConsumer) handleRetryTopic() {
retryTopic := internal.GetRetryTopic(pc.consumerGroup)
if _, ok := pc.crCh[retryTopic]; !ok {
pc.crCh[retryTopic] = make(chan struct{}, pc.defaultConsumer.option.ConsumeGoroutineNums)
}
}

func (pc *pushConsumer) Shutdown() error {
var err error
pc.closeOnce.Do(func() {
Expand Down
5 changes: 5 additions & 0 deletions internal/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.

package internal

import "strings"

const (
RetryGroupTopicPrefix = "%RETRY%"
DefaultConsumerGroup = "DEFAULT_CONSUMER"
Expand All @@ -31,5 +33,8 @@ func GetReplyTopic(clusterName string) string {
}

func GetRetryTopic(group string) string {
if strings.HasPrefix(group, RetryGroupTopicPrefix) {
return group
}
return RetryGroupTopicPrefix + group
}

0 comments on commit 003b83f

Please sign in to comment.