You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.4 KiB
50 lines
1.4 KiB
2 years ago
|
package check
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
2 years ago
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||
|
discoveryRegistry "github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
|
||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
|
||
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||
2 years ago
|
"google.golang.org/grpc"
|
||
|
)
|
||
|
|
||
|
type MsgCheck struct {
|
||
|
zk discoveryRegistry.SvcDiscoveryRegistry
|
||
|
}
|
||
|
|
||
2 years ago
|
func NewMsgCheck(zk discoveryRegistry.SvcDiscoveryRegistry) *MsgCheck {
|
||
|
return &MsgCheck{zk: zk}
|
||
|
}
|
||
|
|
||
2 years ago
|
func (m *MsgCheck) getConn() (*grpc.ClientConn, error) {
|
||
|
return m.zk.GetConn(config.Config.RpcRegisterName.OpenImMsgName)
|
||
|
}
|
||
|
|
||
|
func (m *MsgCheck) SendMsg(ctx context.Context, req *msg.SendMsgReq) (*msg.SendMsgResp, error) {
|
||
|
cc, err := m.getConn()
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
resp, err := msg.NewMsgClient(cc).SendMsg(ctx, req)
|
||
|
return resp, err
|
||
|
}
|
||
2 years ago
|
|
||
|
func (m *MsgCheck) GetMaxAndMinSeq(ctx context.Context, req *sdkws.GetMaxAndMinSeqReq) (*sdkws.GetMaxAndMinSeqResp, error) {
|
||
|
cc, err := m.getConn()
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
resp, err := msg.NewMsgClient(cc).GetMaxAndMinSeq(ctx, req)
|
||
|
return resp, err
|
||
|
}
|
||
|
|
||
2 years ago
|
func (m *MsgCheck) PullMessageBySeqList(ctx context.Context, req *sdkws.PullMessageBySeqsReq) (*sdkws.PullMessageBySeqsResp, error) {
|
||
2 years ago
|
cc, err := m.getConn()
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
2 years ago
|
resp, err := msg.NewMsgClient(cc).PullMessageBySeqs(ctx, req)
|
||
2 years ago
|
return resp, err
|
||
|
}
|