chyezh c725416288
enhance: move streaming proto into pkg (#35284)
issue: #33285

- move streaming related proto into pkg.
- add v2 message type and change flush message into v2 message.

Signed-off-by: chyezh <chyezh@outlook.com>
2024-08-07 10:34:16 +08:00

37 lines
1.1 KiB
Go

package producer
import (
"github.com/milvus-io/milvus/pkg/streaming/proto/messagespb"
"github.com/milvus-io/milvus/pkg/streaming/proto/streamingpb"
"github.com/milvus-io/milvus/pkg/streaming/util/message"
)
// produceGrpcClient is a wrapped producer server of log messages.
type produceGrpcClient struct {
streamingpb.StreamingNodeHandlerService_ProduceClient
}
// SendProduceMessage sends the produce message to server.
func (p *produceGrpcClient) SendProduceMessage(requestID int64, msg message.MutableMessage) error {
return p.Send(&streamingpb.ProduceRequest{
Request: &streamingpb.ProduceRequest_Produce{
Produce: &streamingpb.ProduceMessageRequest{
RequestId: requestID,
Message: &messagespb.Message{
Payload: msg.Payload(),
Properties: msg.Properties().ToRawMap(),
},
},
},
})
}
// SendClose sends the close request to server.
func (p *produceGrpcClient) SendClose() error {
return p.Send(&streamingpb.ProduceRequest{
Request: &streamingpb.ProduceRequest_Close{
Close: &streamingpb.CloseProducerRequest{},
},
})
}