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

39 lines
997 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-06-21 10:25:17 +08:00
"google.golang.org/grpc"
2023-05-25 20:57:19 +08:00
)
2023-06-20 22:12:01 +08:00
type Push struct {
2023-06-21 10:25:17 +08:00
conn *grpc.ClientConn
Client push.PushMsgServiceClient
discov discoveryregistry.SvcDiscoveryRegistry
2023-05-25 20:57:19 +08:00
}
2023-06-21 10:25:17 +08:00
func NewPush(discov discoveryregistry.SvcDiscoveryRegistry) *Push {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImMsgName)
2023-06-01 21:28:16 +08:00
if err != nil {
2023-06-21 10:25:17 +08:00
panic(err)
2023-06-01 21:28:16 +08:00
}
2023-06-21 10:25:17 +08:00
return &Push{
discov: discov,
conn: conn,
Client: push.NewPushMsgServiceClient(conn),
2023-05-25 20:57:19 +08:00
}
2023-06-21 10:25:17 +08:00
}
type PushRpcClient Push
func NewPushRpcClient(discov discoveryregistry.SvcDiscoveryRegistry) PushRpcClient {
return PushRpcClient(*NewPush(discov))
}
func (p *PushRpcClient) DelUserPushToken(ctx context.Context, req *push.DelUserPushTokenReq) (*push.DelUserPushTokenResp, error) {
return p.Client.DelUserPushToken(ctx, req)
2023-05-25 20:57:19 +08:00
}