231 lines
6.2 KiB
Go
231 lines
6.2 KiB
Go
// Code generated by Kitex v0.9.0. DO NOT EDIT.
|
|
|
|
package pushservice
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
config "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
|
|
push "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
|
|
client "github.com/cloudwego/kitex/client"
|
|
kitex "github.com/cloudwego/kitex/pkg/serviceinfo"
|
|
)
|
|
|
|
var errInvalidMessageType = errors.New("invalid message type for service method handler")
|
|
|
|
var serviceMethods = map[string]kitex.MethodInfo{
|
|
"Push": kitex.NewMethodInfo(
|
|
pushHandler,
|
|
newPushServicePushArgs,
|
|
newPushServicePushResult,
|
|
false,
|
|
kitex.WithStreamingMode(kitex.StreamingNone),
|
|
),
|
|
"Add": kitex.NewMethodInfo(
|
|
addHandler,
|
|
newPushServiceAddArgs,
|
|
newPushServiceAddResult,
|
|
false,
|
|
kitex.WithStreamingMode(kitex.StreamingNone),
|
|
),
|
|
"List": kitex.NewMethodInfo(
|
|
listHandler,
|
|
newPushServiceListArgs,
|
|
newPushServiceListResult,
|
|
false,
|
|
kitex.WithStreamingMode(kitex.StreamingNone),
|
|
),
|
|
"GetPusherOptions": kitex.NewMethodInfo(
|
|
getPusherOptionsHandler,
|
|
newPushServiceGetPusherOptionsArgs,
|
|
newPushServiceGetPusherOptionsResult,
|
|
false,
|
|
kitex.WithStreamingMode(kitex.StreamingNone),
|
|
),
|
|
}
|
|
|
|
var (
|
|
pushServiceServiceInfo = NewServiceInfo()
|
|
pushServiceServiceInfoForClient = NewServiceInfoForClient()
|
|
pushServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient()
|
|
)
|
|
|
|
// for server
|
|
func serviceInfo() *kitex.ServiceInfo {
|
|
return pushServiceServiceInfo
|
|
}
|
|
|
|
// for client
|
|
func serviceInfoForStreamClient() *kitex.ServiceInfo {
|
|
return pushServiceServiceInfoForStreamClient
|
|
}
|
|
|
|
// for stream client
|
|
func serviceInfoForClient() *kitex.ServiceInfo {
|
|
return pushServiceServiceInfoForClient
|
|
}
|
|
|
|
// NewServiceInfo creates a new ServiceInfo containing all methods
|
|
func NewServiceInfo() *kitex.ServiceInfo {
|
|
return newServiceInfo(false, true, true)
|
|
}
|
|
|
|
// NewServiceInfo creates a new ServiceInfo containing non-streaming methods
|
|
func NewServiceInfoForClient() *kitex.ServiceInfo {
|
|
return newServiceInfo(false, false, true)
|
|
}
|
|
func NewServiceInfoForStreamClient() *kitex.ServiceInfo {
|
|
return newServiceInfo(true, true, false)
|
|
}
|
|
|
|
func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo {
|
|
serviceName := "PushService"
|
|
handlerType := (*push.PushService)(nil)
|
|
methods := map[string]kitex.MethodInfo{}
|
|
for name, m := range serviceMethods {
|
|
if m.IsStreaming() && !keepStreamingMethods {
|
|
continue
|
|
}
|
|
if !m.IsStreaming() && !keepNonStreamingMethods {
|
|
continue
|
|
}
|
|
methods[name] = m
|
|
}
|
|
extra := map[string]interface{}{
|
|
"PackageName": "push",
|
|
}
|
|
if hasStreaming {
|
|
extra["streaming"] = hasStreaming
|
|
}
|
|
svcInfo := &kitex.ServiceInfo{
|
|
ServiceName: serviceName,
|
|
HandlerType: handlerType,
|
|
Methods: methods,
|
|
PayloadCodec: kitex.Thrift,
|
|
KiteXGenVersion: "v0.9.0",
|
|
Extra: extra,
|
|
}
|
|
return svcInfo
|
|
}
|
|
|
|
func pushHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
|
|
realArg := arg.(*push.PushServicePushArgs)
|
|
realResult := result.(*push.PushServicePushResult)
|
|
success, err := handler.(push.PushService).Push(ctx, realArg.Req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
realResult.Success = success
|
|
return nil
|
|
}
|
|
func newPushServicePushArgs() interface{} {
|
|
return push.NewPushServicePushArgs()
|
|
}
|
|
|
|
func newPushServicePushResult() interface{} {
|
|
return push.NewPushServicePushResult()
|
|
}
|
|
|
|
func addHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
|
|
realArg := arg.(*push.PushServiceAddArgs)
|
|
realResult := result.(*push.PushServiceAddResult)
|
|
success, err := handler.(push.PushService).Add(ctx, realArg.Req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
realResult.Success = success
|
|
return nil
|
|
}
|
|
func newPushServiceAddArgs() interface{} {
|
|
return push.NewPushServiceAddArgs()
|
|
}
|
|
|
|
func newPushServiceAddResult() interface{} {
|
|
return push.NewPushServiceAddResult()
|
|
}
|
|
|
|
func listHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
|
|
realArg := arg.(*push.PushServiceListArgs)
|
|
realResult := result.(*push.PushServiceListResult)
|
|
success, err := handler.(push.PushService).List(ctx, realArg.Req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
realResult.Success = success
|
|
return nil
|
|
}
|
|
func newPushServiceListArgs() interface{} {
|
|
return push.NewPushServiceListArgs()
|
|
}
|
|
|
|
func newPushServiceListResult() interface{} {
|
|
return push.NewPushServiceListResult()
|
|
}
|
|
|
|
func getPusherOptionsHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
|
|
_ = arg.(*push.PushServiceGetPusherOptionsArgs)
|
|
realResult := result.(*push.PushServiceGetPusherOptionsResult)
|
|
success, err := handler.(push.PushService).GetPusherOptions(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
realResult.Success = success
|
|
return nil
|
|
}
|
|
func newPushServiceGetPusherOptionsArgs() interface{} {
|
|
return push.NewPushServiceGetPusherOptionsArgs()
|
|
}
|
|
|
|
func newPushServiceGetPusherOptionsResult() interface{} {
|
|
return push.NewPushServiceGetPusherOptionsResult()
|
|
}
|
|
|
|
type kClient struct {
|
|
c client.Client
|
|
}
|
|
|
|
func newServiceClient(c client.Client) *kClient {
|
|
return &kClient{
|
|
c: c,
|
|
}
|
|
}
|
|
|
|
func (p *kClient) Push(ctx context.Context, req *push.PushReq) (r *push.Resp, err error) {
|
|
var _args push.PushServicePushArgs
|
|
_args.Req = req
|
|
var _result push.PushServicePushResult
|
|
if err = p.c.Call(ctx, "Push", &_args, &_result); err != nil {
|
|
return
|
|
}
|
|
return _result.GetSuccess(), nil
|
|
}
|
|
|
|
func (p *kClient) Add(ctx context.Context, req *config.PusherConfig) (r *push.Resp, err error) {
|
|
var _args push.PushServiceAddArgs
|
|
_args.Req = req
|
|
var _result push.PushServiceAddResult
|
|
if err = p.c.Call(ctx, "Add", &_args, &_result); err != nil {
|
|
return
|
|
}
|
|
return _result.GetSuccess(), nil
|
|
}
|
|
|
|
func (p *kClient) List(ctx context.Context, req *push.ListPusherRequest) (r *push.ListPusherResponse, err error) {
|
|
var _args push.PushServiceListArgs
|
|
_args.Req = req
|
|
var _result push.PushServiceListResult
|
|
if err = p.c.Call(ctx, "List", &_args, &_result); err != nil {
|
|
return
|
|
}
|
|
return _result.GetSuccess(), nil
|
|
}
|
|
|
|
func (p *kClient) GetPusherOptions(ctx context.Context) (r *push.GetPusherOptionsResponse, err error) {
|
|
var _args push.PushServiceGetPusherOptionsArgs
|
|
var _result push.PushServiceGetPusherOptionsResult
|
|
if err = p.c.Call(ctx, "GetPusherOptions", &_args, &_result); err != nil {
|
|
return
|
|
}
|
|
return _result.GetSuccess(), nil
|
|
}
|