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.
276 lines
6.3 KiB
276 lines
6.3 KiB
// Code generated by Kitex v0.3.4. DO NOT EDIT.
|
|
|
|
package feedservice
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/TremblingV5/DouTok/kitex_gen/feed"
|
|
"github.com/cloudwego/kitex/client"
|
|
kitex "github.com/cloudwego/kitex/pkg/serviceinfo"
|
|
"github.com/cloudwego/kitex/pkg/streaming"
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
func serviceInfo() *kitex.ServiceInfo {
|
|
return feedServiceServiceInfo
|
|
}
|
|
|
|
var feedServiceServiceInfo = NewServiceInfo()
|
|
|
|
func NewServiceInfo() *kitex.ServiceInfo {
|
|
serviceName := "FeedService"
|
|
handlerType := (*feed.FeedService)(nil)
|
|
methods := map[string]kitex.MethodInfo{
|
|
"GetUserFeed": kitex.NewMethodInfo(getUserFeedHandler, newGetUserFeedArgs, newGetUserFeedResult, false),
|
|
"GetVideoById": kitex.NewMethodInfo(getVideoByIdHandler, newGetVideoByIdArgs, newGetVideoByIdResult, false),
|
|
}
|
|
extra := map[string]interface{}{
|
|
"PackageName": "feed",
|
|
}
|
|
svcInfo := &kitex.ServiceInfo{
|
|
ServiceName: serviceName,
|
|
HandlerType: handlerType,
|
|
Methods: methods,
|
|
PayloadCodec: kitex.Protobuf,
|
|
KiteXGenVersion: "v0.3.4",
|
|
Extra: extra,
|
|
}
|
|
return svcInfo
|
|
}
|
|
|
|
func getUserFeedHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
|
|
switch s := arg.(type) {
|
|
case *streaming.Args:
|
|
st := s.Stream
|
|
req := new(feed.DouyinFeedRequest)
|
|
if err := st.RecvMsg(req); err != nil {
|
|
return err
|
|
}
|
|
resp, err := handler.(feed.FeedService).GetUserFeed(ctx, req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := st.SendMsg(resp); err != nil {
|
|
return err
|
|
}
|
|
case *GetUserFeedArgs:
|
|
success, err := handler.(feed.FeedService).GetUserFeed(ctx, s.Req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
realResult := result.(*GetUserFeedResult)
|
|
realResult.Success = success
|
|
}
|
|
return nil
|
|
}
|
|
func newGetUserFeedArgs() interface{} {
|
|
return &GetUserFeedArgs{}
|
|
}
|
|
|
|
func newGetUserFeedResult() interface{} {
|
|
return &GetUserFeedResult{}
|
|
}
|
|
|
|
type GetUserFeedArgs struct {
|
|
Req *feed.DouyinFeedRequest
|
|
}
|
|
|
|
func (p *GetUserFeedArgs) Marshal(out []byte) ([]byte, error) {
|
|
if !p.IsSetReq() {
|
|
return out, fmt.Errorf("No req in GetUserFeedArgs")
|
|
}
|
|
return proto.Marshal(p.Req)
|
|
}
|
|
|
|
func (p *GetUserFeedArgs) Unmarshal(in []byte) error {
|
|
msg := new(feed.DouyinFeedRequest)
|
|
if err := proto.Unmarshal(in, msg); err != nil {
|
|
return err
|
|
}
|
|
p.Req = msg
|
|
return nil
|
|
}
|
|
|
|
var GetUserFeedArgs_Req_DEFAULT *feed.DouyinFeedRequest
|
|
|
|
func (p *GetUserFeedArgs) GetReq() *feed.DouyinFeedRequest {
|
|
if !p.IsSetReq() {
|
|
return GetUserFeedArgs_Req_DEFAULT
|
|
}
|
|
return p.Req
|
|
}
|
|
|
|
func (p *GetUserFeedArgs) IsSetReq() bool {
|
|
return p.Req != nil
|
|
}
|
|
|
|
type GetUserFeedResult struct {
|
|
Success *feed.DouyinFeedResponse
|
|
}
|
|
|
|
var GetUserFeedResult_Success_DEFAULT *feed.DouyinFeedResponse
|
|
|
|
func (p *GetUserFeedResult) Marshal(out []byte) ([]byte, error) {
|
|
if !p.IsSetSuccess() {
|
|
return out, fmt.Errorf("No req in GetUserFeedResult")
|
|
}
|
|
return proto.Marshal(p.Success)
|
|
}
|
|
|
|
func (p *GetUserFeedResult) Unmarshal(in []byte) error {
|
|
msg := new(feed.DouyinFeedResponse)
|
|
if err := proto.Unmarshal(in, msg); err != nil {
|
|
return err
|
|
}
|
|
p.Success = msg
|
|
return nil
|
|
}
|
|
|
|
func (p *GetUserFeedResult) GetSuccess() *feed.DouyinFeedResponse {
|
|
if !p.IsSetSuccess() {
|
|
return GetUserFeedResult_Success_DEFAULT
|
|
}
|
|
return p.Success
|
|
}
|
|
|
|
func (p *GetUserFeedResult) SetSuccess(x interface{}) {
|
|
p.Success = x.(*feed.DouyinFeedResponse)
|
|
}
|
|
|
|
func (p *GetUserFeedResult) IsSetSuccess() bool {
|
|
return p.Success != nil
|
|
}
|
|
|
|
func getVideoByIdHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
|
|
switch s := arg.(type) {
|
|
case *streaming.Args:
|
|
st := s.Stream
|
|
req := new(feed.VideoIdRequest)
|
|
if err := st.RecvMsg(req); err != nil {
|
|
return err
|
|
}
|
|
resp, err := handler.(feed.FeedService).GetVideoById(ctx, req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := st.SendMsg(resp); err != nil {
|
|
return err
|
|
}
|
|
case *GetVideoByIdArgs:
|
|
success, err := handler.(feed.FeedService).GetVideoById(ctx, s.Req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
realResult := result.(*GetVideoByIdResult)
|
|
realResult.Success = success
|
|
}
|
|
return nil
|
|
}
|
|
func newGetVideoByIdArgs() interface{} {
|
|
return &GetVideoByIdArgs{}
|
|
}
|
|
|
|
func newGetVideoByIdResult() interface{} {
|
|
return &GetVideoByIdResult{}
|
|
}
|
|
|
|
type GetVideoByIdArgs struct {
|
|
Req *feed.VideoIdRequest
|
|
}
|
|
|
|
func (p *GetVideoByIdArgs) Marshal(out []byte) ([]byte, error) {
|
|
if !p.IsSetReq() {
|
|
return out, fmt.Errorf("No req in GetVideoByIdArgs")
|
|
}
|
|
return proto.Marshal(p.Req)
|
|
}
|
|
|
|
func (p *GetVideoByIdArgs) Unmarshal(in []byte) error {
|
|
msg := new(feed.VideoIdRequest)
|
|
if err := proto.Unmarshal(in, msg); err != nil {
|
|
return err
|
|
}
|
|
p.Req = msg
|
|
return nil
|
|
}
|
|
|
|
var GetVideoByIdArgs_Req_DEFAULT *feed.VideoIdRequest
|
|
|
|
func (p *GetVideoByIdArgs) GetReq() *feed.VideoIdRequest {
|
|
if !p.IsSetReq() {
|
|
return GetVideoByIdArgs_Req_DEFAULT
|
|
}
|
|
return p.Req
|
|
}
|
|
|
|
func (p *GetVideoByIdArgs) IsSetReq() bool {
|
|
return p.Req != nil
|
|
}
|
|
|
|
type GetVideoByIdResult struct {
|
|
Success *feed.Video
|
|
}
|
|
|
|
var GetVideoByIdResult_Success_DEFAULT *feed.Video
|
|
|
|
func (p *GetVideoByIdResult) Marshal(out []byte) ([]byte, error) {
|
|
if !p.IsSetSuccess() {
|
|
return out, fmt.Errorf("No req in GetVideoByIdResult")
|
|
}
|
|
return proto.Marshal(p.Success)
|
|
}
|
|
|
|
func (p *GetVideoByIdResult) Unmarshal(in []byte) error {
|
|
msg := new(feed.Video)
|
|
if err := proto.Unmarshal(in, msg); err != nil {
|
|
return err
|
|
}
|
|
p.Success = msg
|
|
return nil
|
|
}
|
|
|
|
func (p *GetVideoByIdResult) GetSuccess() *feed.Video {
|
|
if !p.IsSetSuccess() {
|
|
return GetVideoByIdResult_Success_DEFAULT
|
|
}
|
|
return p.Success
|
|
}
|
|
|
|
func (p *GetVideoByIdResult) SetSuccess(x interface{}) {
|
|
p.Success = x.(*feed.Video)
|
|
}
|
|
|
|
func (p *GetVideoByIdResult) IsSetSuccess() bool {
|
|
return p.Success != nil
|
|
}
|
|
|
|
type kClient struct {
|
|
c client.Client
|
|
}
|
|
|
|
func newServiceClient(c client.Client) *kClient {
|
|
return &kClient{
|
|
c: c,
|
|
}
|
|
}
|
|
|
|
func (p *kClient) GetUserFeed(ctx context.Context, Req *feed.DouyinFeedRequest) (r *feed.DouyinFeedResponse, err error) {
|
|
var _args GetUserFeedArgs
|
|
_args.Req = Req
|
|
var _result GetUserFeedResult
|
|
if err = p.c.Call(ctx, "GetUserFeed", &_args, &_result); err != nil {
|
|
return
|
|
}
|
|
return _result.GetSuccess(), nil
|
|
}
|
|
|
|
func (p *kClient) GetVideoById(ctx context.Context, Req *feed.VideoIdRequest) (r *feed.Video, err error) {
|
|
var _args GetVideoByIdArgs
|
|
_args.Req = Req
|
|
var _result GetVideoByIdResult
|
|
if err = p.c.Call(ctx, "GetVideoById", &_args, &_result); err != nil {
|
|
return
|
|
}
|
|
return _result.GetSuccess(), nil
|
|
}
|
|
|