Files
open-im-server/pkg/rpcclient/push.go
T

31 lines
801 B
Go
Raw Normal View History

2023-05-25 20:57:19 +08:00
package rpcclient
import (
"context"
2023-05-26 16:22:03 +08:00
2023-05-25 20:57:19 +08:00
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/push"
2023-05-30 16:15:11 +08:00
"google.golang.org/grpc"
2023-05-25 20:57:19 +08:00
)
type PushClient struct {
2023-05-30 16:15:11 +08:00
conn *grpc.ClientConn
2023-05-25 20:57:19 +08:00
}
2023-05-30 16:15:11 +08:00
func NewPushClient(discov discoveryregistry.SvcDiscoveryRegistry) *PushClient {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImPushName)
if err != nil {
panic(err)
2023-05-25 20:57:19 +08:00
}
2023-05-30 16:15:11 +08:00
return &PushClient{conn: conn}
2023-05-25 20:57:19 +08:00
}
2023-05-26 16:22:03 +08:00
func (p *PushClient) DelUserPushToken(ctx context.Context, req *push.DelUserPushTokenReq) (*push.DelUserPushTokenResp, error) {
2023-05-30 16:15:11 +08:00
resp, err := push.NewPushMsgServiceClient(p.conn).DelUserPushToken(ctx, req)
2023-05-25 20:57:19 +08:00
if err != nil {
return nil, err
}
return resp, nil
}