github.com/milvus-io/milvus-sdk-go/v2@v2.4.1/client/mq_message.go (about)

     1  package client
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
     7  	"github.com/milvus-io/milvus-proto/go-api/v2/msgpb"
     8  	"github.com/milvus-io/milvus-sdk-go/v2/entity"
     9  )
    10  
    11  func (c *GrpcClient) ReplicateMessage(ctx context.Context,
    12  	channelName string, beginTs, endTs uint64,
    13  	msgsBytes [][]byte, startPositions, endPositions []*msgpb.MsgPosition,
    14  	opts ...ReplicateMessageOption) (*entity.MessageInfo, error) {
    15  
    16  	if c.Service == nil {
    17  		return nil, ErrClientNotReady
    18  	}
    19  	req := &milvuspb.ReplicateMessageRequest{
    20  		ChannelName:    channelName,
    21  		BeginTs:        beginTs,
    22  		EndTs:          endTs,
    23  		Msgs:           msgsBytes,
    24  		StartPositions: startPositions,
    25  		EndPositions:   endPositions,
    26  	}
    27  	for _, opt := range opts {
    28  		opt(req)
    29  	}
    30  	resp, err := c.Service.ReplicateMessage(ctx, req)
    31  	if err != nil {
    32  		return nil, err
    33  	}
    34  	err = handleRespStatus(resp.GetStatus())
    35  	if err != nil {
    36  		return nil, err
    37  	}
    38  	return &entity.MessageInfo{
    39  		Position: resp.GetPosition(),
    40  	}, nil
    41  }