add publisher shutdown

This commit is contained in:
chrislu
2023-09-07 23:55:19 -07:00
parent 875f562779
commit 39941edc0b
4 changed files with 22 additions and 5 deletions

View File

@@ -2,10 +2,12 @@ package pub_client
import (
"github.com/rdleal/intervalst/interval"
"github.com/seaweedfs/seaweedfs/weed/mq/broker"
"github.com/seaweedfs/seaweedfs/weed/pb/mq_pb"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"sync"
"time"
)
type PublisherConfiguration struct {
@@ -41,3 +43,15 @@ func (p *TopicPublisher) Connect(bootstrapBroker string) error {
}
return nil
}
func (p *TopicPublisher) Shutdown() error {
if clients, found := p.partition2Broker.AllIntersections(0, broker.MaxPartitionCount); found {
for _, client := range clients {
client.CloseSend()
}
}
time.Sleep(1100 * time.Millisecond)
return nil
}