Browse Source

go fmt

pull/5890/head
chrislu 8 months ago
parent
commit
3622196881
  1. 1
      weed/mq/broker/broker_grpc_sub_follow.go
  2. 1
      weed/mq/broker/broker_server.go
  3. 2
      weed/mq/client/cmd/weed_sub_kv/subscriber_kv.go
  4. 2
      weed/mq/client/cmd/weed_sub_record/subscriber_record.go
  5. 8
      weed/mq/client/sub_client/connect_to_sub_coordinator.go
  6. 1
      weed/mq/client/sub_client/subscribe.go
  7. 5
      weed/mq/sub_coordinator/inflight_message_tracker.go

1
weed/mq/broker/broker_grpc_sub_follow.go

@ -12,7 +12,6 @@ import (
"time"
)
func (b *MessageQueueBroker) SubscribeFollowMe(stream mq_pb.SeaweedMessaging_SubscribeFollowMeServer) (err error) {
var req *mq_pb.SubscribeFollowMeRequest
req, err = stream.Recv()

1
weed/mq/broker/broker_server.go

@ -130,7 +130,6 @@ func (b *MessageQueueBroker) GetGrpcDialOption() grpc.DialOption {
return b.grpcDialOption
}
func (b *MessageQueueBroker) GetFiler() pb.ServerAddress {
return b.currentFiler
}

2
weed/mq/client/cmd/weed_sub_kv/subscriber_kv.go

@ -44,7 +44,7 @@ func main() {
subscriber := sub_client.NewTopicSubscriber(brokers, subscriberConfig, contentConfig, processorConfig)
counter := 0
subscriber.SetEachMessageFunc(func(key, value []byte) (error) {
subscriber.SetEachMessageFunc(func(key, value []byte) error {
counter++
println(string(key), "=>", string(value), counter)
return nil

2
weed/mq/client/cmd/weed_sub_record/subscriber_record.go

@ -71,7 +71,7 @@ func main() {
subscriber := sub_client.NewTopicSubscriber(brokers, subscriberConfig, contentConfig, processorConfig)
counter := 0
subscriber.SetEachMessageFunc(func(key, value []byte) (error) {
subscriber.SetEachMessageFunc(func(key, value []byte) error {
counter++
record := &schema_pb.RecordValue{}
proto.Unmarshal(value, record)

8
weed/mq/client/sub_client/connect_to_sub_coordinator.go

@ -125,11 +125,11 @@ func (sub *TopicSubscriber) onEachPartition(assigned *mq_pb.BrokerPartitionAssig
close(partitionOffsetChan)
}()
concurrentPartitionLimit := int(sub.ProcessorConfig.MaxPartitionCount)
if concurrentPartitionLimit <= 0 {
concurrentPartitionLimit = 1
perPartitionConcurrency := int(sub.ProcessorConfig.PerPartitionConcurrency)
if perPartitionConcurrency <= 0 {
perPartitionConcurrency = 1
}
executors := util.NewLimitedConcurrentExecutor(concurrentPartitionLimit)
executors := util.NewLimitedConcurrentExecutor(perPartitionConcurrency)
go func() {
for ack := range partitionOffsetChan {

1
weed/mq/client/sub_client/subscribe.go

@ -9,7 +9,6 @@ import (
)
type ProcessorState struct {
}
// Subscribe subscribes to a topic's specified partitions.

5
weed/mq/sub_coordinator/inflight_message_tracker.go

@ -26,6 +26,7 @@ func (imt *InflightMessageTracker) InflightMessage(key []byte, tsNs int64) {
imt.messages[string(key)] = tsNs
imt.timestamps.Add(tsNs)
}
// IsMessageAcknowledged returns true if the message has been acknowledged.
// If the message is older than the oldest inflight messages, returns false.
// returns false if the message is inflight.
@ -47,6 +48,7 @@ func (imt *InflightMessageTracker) IsMessageAcknowledged(key []byte, tsNs int64)
return true
}
// AcknowledgeMessage acknowledges the message with the key and timestamp.
func (imt *InflightMessageTracker) AcknowledgeMessage(key []byte, tsNs int64) bool {
imt.mu.Lock()
@ -71,12 +73,14 @@ type RingBuffer struct {
head int
size int
}
// NewRingBuffer creates a new RingBuffer of the given capacity.
func NewRingBuffer(capacity int) *RingBuffer {
return &RingBuffer{
buffer: make([]int64, capacity),
}
}
// Add adds a new timestamp to the ring buffer.
func (rb *RingBuffer) Add(timestamp int64) {
rb.buffer[rb.head] = timestamp
@ -85,6 +89,7 @@ func (rb *RingBuffer) Add(timestamp int64) {
rb.size++
}
}
// Remove removes the specified timestamp from the ring buffer.
func (rb *RingBuffer) Remove(timestamp int64) {
// Perform binary search

Loading…
Cancel
Save