forked from JointCloud/pcm-coordinator
call ac-rpc in coordinator to get infer url
Former-commit-id: 87c47b7497
This commit is contained in:
parent
053cba88e8
commit
81b4025e9b
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"gitlink.org.cn/JointCloud/pcm-ac/hpcacclient"
|
||||
hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/config"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/executor"
|
||||
|
|
|
@ -2,7 +2,7 @@ package service
|
|||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"gitlink.org.cn/JointCloud/pcm-ac/hpcacclient"
|
||||
hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/config"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/database"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector"
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"gitlink.org.cn/JointCloud/pcm-ac/hpcAC"
|
||||
"gitlink.org.cn/JointCloud/pcm-ac/hpcacclient"
|
||||
hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
||||
"strconv"
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"gitlink.org.cn/JointCloud/pcm-ac/hpcAC"
|
||||
"gitlink.org.cn/JointCloud/pcm-ac/hpcacclient"
|
||||
hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/common"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers/option"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector"
|
||||
|
@ -98,7 +98,7 @@ type ShuguangAi struct {
|
|||
participantId int64
|
||||
}
|
||||
|
||||
func NewShuguangAi(aCRpc hpcacclient.HpcAC, name string, id int64) *ShuguangAi {
|
||||
func NewShuguangAi(aCRpc hpcAC.HpcACClient, name string, id int64) *ShuguangAi {
|
||||
return &ShuguangAi{aCRpc: aCRpc, platform: name, participantId: id}
|
||||
}
|
||||
|
||||
|
@ -732,9 +732,17 @@ func (s *ShuguangAi) generateParams(option *option.AiOption) error {
|
|||
|
||||
func (s *ShuguangAi) GetImageInferUrl(ctx context.Context, option *option.InferOption) ([]*collector.ImageInferUrl, error) {
|
||||
var imageUrls []*collector.ImageInferUrl
|
||||
|
||||
urlReq := &hpcAC.GetInferUrlReq{
|
||||
ModelName: option.ModelName,
|
||||
Type: option.ModelType,
|
||||
Card: "dcu",
|
||||
}
|
||||
|
||||
urlResp, _ := s.aCRpc.GetInferUrl(ctx, urlReq)
|
||||
imageUrl := &collector.ImageInferUrl{
|
||||
Url: "http://0.0.0.0:8888/image",
|
||||
Card: "dcu",
|
||||
Url: urlResp.Url,
|
||||
Card: option.ComputeCard,
|
||||
}
|
||||
imageUrls = append(imageUrls, imageUrl)
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
"gitlink.org.cn/JointCloud/pcm-ac/hpcAC"
|
||||
"gitlink.org.cn/JointCloud/pcm-ac/hpcacclient"
|
||||
hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/common"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/service/collector"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"github.com/robfig/cron/v3"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"gitlink.org.cn/JointCloud/pcm-ac/hpcacclient"
|
||||
hpcacclient "gitlink.org.cn/JointCloud/pcm-ac/hpcacclient"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/config"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/database"
|
||||
|
|
5
go.mod
5
go.mod
|
@ -20,8 +20,7 @@ require (
|
|||
github.com/prometheus/common v0.52.2
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/zeromicro/go-zero v1.6.3
|
||||
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240426095603-549fefd8bece
|
||||
gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c
|
||||
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240619113316-c0186ee7b60c
|
||||
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240515005224-689bb339a9c9
|
||||
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240510133934-6a5526289b35
|
||||
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203
|
||||
|
@ -30,7 +29,7 @@ require (
|
|||
go.opentelemetry.io/otel/trace v1.25.0
|
||||
gonum.org/v1/gonum v0.11.0
|
||||
google.golang.org/grpc v1.63.0
|
||||
google.golang.org/protobuf v1.33.0
|
||||
google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002
|
||||
gorm.io/datatypes v1.2.0
|
||||
gorm.io/driver/mysql v1.5.2
|
||||
gorm.io/gorm v1.25.5
|
||||
|
|
10
go.sum
10
go.sum
|
@ -466,10 +466,8 @@ github.com/yuin/gopher-lua v1.1.0 h1:BojcDhfyDWgU2f2TOzYK/g5p2gxMrku8oupLDqlnSqE
|
|||
github.com/yuin/gopher-lua v1.1.0/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
|
||||
github.com/zeromicro/go-zero v1.6.3 h1:OL0NnHD5LdRNDolfcK9vUkJt7K8TcBE3RkzfM8poOVw=
|
||||
github.com/zeromicro/go-zero v1.6.3/go.mod h1:XZL435ZxVi9MSXXtw2MRQhHgx6OoX3++MRMOE9xU70c=
|
||||
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240426095603-549fefd8bece h1:W3yBnvAVV8dlRNQKYD6Mf8ySRrYsP0tPk7JjvqZzNHQ=
|
||||
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240426095603-549fefd8bece/go.mod h1:w3Nb5TNymCItQ7K3x4Q0JLuoq9OerwAzAWT2zsPE9Xo=
|
||||
gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c h1:2Wl/hvaSFjh6fmCSIQhjkr9llMRREQeqcXNLZ/HPY18=
|
||||
gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c/go.mod h1:lSRfGs+PxFvw7CcndHWRd6UlLlGrZn0b0hp5cfaMNGw=
|
||||
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240619113316-c0186ee7b60c h1:HrU3GPuHWTAajQxbkDFygsAm/HURJFGT2yckUMdOdGM=
|
||||
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240619113316-c0186ee7b60c/go.mod h1:3eECiw9O2bIFkkePlloKyLNXiqBAhOxNrDoGaaGseGY=
|
||||
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240515005224-689bb339a9c9 h1:FRtOtI9vDFHcyPUdc4PL95CFi/DFk+HXT6JNTf/91d8=
|
||||
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240515005224-689bb339a9c9/go.mod h1:2WC5tDApfQNNIBfDNYwdaQiXhfCsG2n03P3ZxX9p9O4=
|
||||
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240510133934-6a5526289b35 h1:E2QfpS3Y0FjR8Zyv5l2Ti/2NetQFqHG66c8+T/+J1u0=
|
||||
|
@ -851,8 +849,8 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
|
|||
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002 h1:V7Da7qt0MkY3noVANIMVBk28nOnijADeOR3i5Hcvpj4=
|
||||
google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v3.19.4
|
||||
// source: hpcAC.proto
|
||||
|
||||
|
@ -18,44 +18,6 @@ import (
|
|||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
const (
|
||||
HpcAC_ListJob_FullMethodName = "/hpcAC.hpcAC/ListJob"
|
||||
HpcAC_ListHistoryJob_FullMethodName = "/hpcAC.hpcAC/ListHistoryJob"
|
||||
HpcAC_SubmitJob_FullMethodName = "/hpcAC.hpcAC/SubmitJob"
|
||||
HpcAC_ListJobManager_FullMethodName = "/hpcAC.hpcAC/ListJobManager"
|
||||
HpcAC_GetJobDetail_FullMethodName = "/hpcAC.hpcAC/GetJobDetail"
|
||||
HpcAC_DeleteJob_FullMethodName = "/hpcAC.hpcAC/DeleteJob"
|
||||
HpcAC_FileContent_FullMethodName = "/hpcAC.hpcAC/FileContent"
|
||||
HpcAC_SelectQueueByUser_FullMethodName = "/hpcAC.hpcAC/SelectQueueByUser"
|
||||
HpcAC_QueryQueueDetails_FullMethodName = "/hpcAC.hpcAC/QueryQueueDetails"
|
||||
HpcAC_QueryUserQuotasLimit_FullMethodName = "/hpcAC.hpcAC/QueryUserQuotasLimit"
|
||||
HpcAC_ParaStorQuota_FullMethodName = "/hpcAC.hpcAC/ParaStorQuota"
|
||||
HpcAC_WallTime_FullMethodName = "/hpcAC.hpcAC/WallTime"
|
||||
HpcAC_QueueJobs_FullMethodName = "/hpcAC.hpcAC/QueueJobs"
|
||||
HpcAC_CpuCore_FullMethodName = "/hpcAC.hpcAC/CpuCore"
|
||||
HpcAC_Jobs_FullMethodName = "/hpcAC.hpcAC/jobs"
|
||||
HpcAC_HistoryJobDetail_FullMethodName = "/hpcAC.hpcAC/HistoryJobDetail"
|
||||
HpcAC_GetACToken_FullMethodName = "/hpcAC.hpcAC/GetACToken"
|
||||
HpcAC_GetACClusterId_FullMethodName = "/hpcAC.hpcAC/GetACClusterId"
|
||||
HpcAC_GetComputingPower_FullMethodName = "/hpcAC.hpcAC/GetComputingPower"
|
||||
HpcAC_GetGeneralInfo_FullMethodName = "/hpcAC.hpcAC/GetGeneralInfo"
|
||||
HpcAC_SubmitPytorchTask_FullMethodName = "/hpcAC.hpcAC/SubmitPytorchTask"
|
||||
HpcAC_SubmitTensorflowTask_FullMethodName = "/hpcAC.hpcAC/SubmitTensorflowTask"
|
||||
HpcAC_GetImageListAi_FullMethodName = "/hpcAC.hpcAC/GetImageListAi"
|
||||
HpcAC_GetImageAiById_FullMethodName = "/hpcAC.hpcAC/GetImageAiById"
|
||||
HpcAC_GetPytorchTask_FullMethodName = "/hpcAC.hpcAC/GetPytorchTask"
|
||||
HpcAC_GetTensorflowTask_FullMethodName = "/hpcAC.hpcAC/GetTensorflowTask"
|
||||
HpcAC_DeleteTaskAi_FullMethodName = "/hpcAC.hpcAC/DeleteTaskAi"
|
||||
HpcAC_GetResourceSpec_FullMethodName = "/hpcAC.hpcAC/GetResourceSpec"
|
||||
HpcAC_GetInstanceLog_FullMethodName = "/hpcAC.hpcAC/GetInstanceLog"
|
||||
HpcAC_GetFileList_FullMethodName = "/hpcAC.hpcAC/GetFileList"
|
||||
HpcAC_GetFile_FullMethodName = "/hpcAC.hpcAC/GetFile"
|
||||
HpcAC_UploadFile_FullMethodName = "/hpcAC.hpcAC/UploadFile"
|
||||
HpcAC_GetUserInfo_FullMethodName = "/hpcAC.hpcAC/GetUserInfo"
|
||||
HpcAC_GetMemberJobs_FullMethodName = "/hpcAC.hpcAC/GetMemberJobs"
|
||||
HpcAC_GetNodeResources_FullMethodName = "/hpcAC.hpcAC/GetNodeResources"
|
||||
)
|
||||
|
||||
// HpcACClient is the client API for HpcAC service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
|
@ -107,6 +69,8 @@ type HpcACClient interface {
|
|||
DeleteTaskAi(ctx context.Context, in *DeleteTaskAiReq, opts ...grpc.CallOption) (*DeleteTaskAiResp, error)
|
||||
GetResourceSpec(ctx context.Context, in *GetResourceSpecReq, opts ...grpc.CallOption) (*GetResourceSpecResp, error)
|
||||
GetInstanceLog(ctx context.Context, in *GetInstanceLogReq, opts ...grpc.CallOption) (*GetInstanceLogResp, error)
|
||||
GetInstanceListAi(ctx context.Context, in *GetInstanceListReq, opts ...grpc.CallOption) (*GetInstanceListResp, error)
|
||||
GetInferUrl(ctx context.Context, in *GetInferUrlReq, opts ...grpc.CallOption) (*GetInferUrlResp, error)
|
||||
// 曙光文件接口
|
||||
GetFileList(ctx context.Context, in *GetFileListReq, opts ...grpc.CallOption) (*GetFileListResp, error)
|
||||
GetFile(ctx context.Context, in *GetFileReq, opts ...grpc.CallOption) (*GetFileResp, error)
|
||||
|
@ -128,7 +92,7 @@ func NewHpcACClient(cc grpc.ClientConnInterface) HpcACClient {
|
|||
|
||||
func (c *hpcACClient) ListJob(ctx context.Context, in *ListJobReq, opts ...grpc.CallOption) (*ListJobResp, error) {
|
||||
out := new(ListJobResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_ListJob_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/ListJob", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -137,7 +101,7 @@ func (c *hpcACClient) ListJob(ctx context.Context, in *ListJobReq, opts ...grpc.
|
|||
|
||||
func (c *hpcACClient) ListHistoryJob(ctx context.Context, in *ListHistoryJobReq, opts ...grpc.CallOption) (*ListHistoryJobResp, error) {
|
||||
out := new(ListHistoryJobResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_ListHistoryJob_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/ListHistoryJob", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -146,7 +110,7 @@ func (c *hpcACClient) ListHistoryJob(ctx context.Context, in *ListHistoryJobReq,
|
|||
|
||||
func (c *hpcACClient) SubmitJob(ctx context.Context, in *SubmitJobReq, opts ...grpc.CallOption) (*SubmitJobResp, error) {
|
||||
out := new(SubmitJobResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_SubmitJob_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/SubmitJob", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -155,7 +119,7 @@ func (c *hpcACClient) SubmitJob(ctx context.Context, in *SubmitJobReq, opts ...g
|
|||
|
||||
func (c *hpcACClient) ListJobManager(ctx context.Context, in *JobManagerReq, opts ...grpc.CallOption) (*ListJobManagerResp, error) {
|
||||
out := new(ListJobManagerResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_ListJobManager_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/ListJobManager", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -164,7 +128,7 @@ func (c *hpcACClient) ListJobManager(ctx context.Context, in *JobManagerReq, opt
|
|||
|
||||
func (c *hpcACClient) GetJobDetail(ctx context.Context, in *JobDetailReq, opts ...grpc.CallOption) (*GetJobDetailResp, error) {
|
||||
out := new(GetJobDetailResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_GetJobDetail_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetJobDetail", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -173,7 +137,7 @@ func (c *hpcACClient) GetJobDetail(ctx context.Context, in *JobDetailReq, opts .
|
|||
|
||||
func (c *hpcACClient) DeleteJob(ctx context.Context, in *DeleteJobReq, opts ...grpc.CallOption) (*DeleteJobResp, error) {
|
||||
out := new(DeleteJobResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_DeleteJob_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/DeleteJob", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -182,7 +146,7 @@ func (c *hpcACClient) DeleteJob(ctx context.Context, in *DeleteJobReq, opts ...g
|
|||
|
||||
func (c *hpcACClient) FileContent(ctx context.Context, in *FileDataReq, opts ...grpc.CallOption) (*FileContentResp, error) {
|
||||
out := new(FileContentResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_FileContent_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/FileContent", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -191,7 +155,7 @@ func (c *hpcACClient) FileContent(ctx context.Context, in *FileDataReq, opts ...
|
|||
|
||||
func (c *hpcACClient) SelectQueueByUser(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*QueueResp, error) {
|
||||
out := new(QueueResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_SelectQueueByUser_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/SelectQueueByUser", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -200,7 +164,7 @@ func (c *hpcACClient) SelectQueueByUser(ctx context.Context, in *QueueReq, opts
|
|||
|
||||
func (c *hpcACClient) QueryQueueDetails(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*QueueDetailsResp, error) {
|
||||
out := new(QueueDetailsResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_QueryQueueDetails_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/QueryQueueDetails", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -209,7 +173,7 @@ func (c *hpcACClient) QueryQueueDetails(ctx context.Context, in *QueueReq, opts
|
|||
|
||||
func (c *hpcACClient) QueryUserQuotasLimit(ctx context.Context, in *QueueReq, opts ...grpc.CallOption) (*UserQuotasLimitResp, error) {
|
||||
out := new(UserQuotasLimitResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_QueryUserQuotasLimit_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/QueryUserQuotasLimit", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -218,7 +182,7 @@ func (c *hpcACClient) QueryUserQuotasLimit(ctx context.Context, in *QueueReq, op
|
|||
|
||||
func (c *hpcACClient) ParaStorQuota(ctx context.Context, in *ParaStorQuotaReq, opts ...grpc.CallOption) (*ParaStorQuotaResp, error) {
|
||||
out := new(ParaStorQuotaResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_ParaStorQuota_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/ParaStorQuota", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -227,7 +191,7 @@ func (c *hpcACClient) ParaStorQuota(ctx context.Context, in *ParaStorQuotaReq, o
|
|||
|
||||
func (c *hpcACClient) WallTime(ctx context.Context, in *WallTimeReq, opts ...grpc.CallOption) (*WallTimeResp, error) {
|
||||
out := new(WallTimeResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_WallTime_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/WallTime", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -236,7 +200,7 @@ func (c *hpcACClient) WallTime(ctx context.Context, in *WallTimeReq, opts ...grp
|
|||
|
||||
func (c *hpcACClient) QueueJobs(ctx context.Context, in *QueueJobsReq, opts ...grpc.CallOption) (*QueueJobsResp, error) {
|
||||
out := new(QueueJobsResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_QueueJobs_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/QueueJobs", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -245,7 +209,7 @@ func (c *hpcACClient) QueueJobs(ctx context.Context, in *QueueJobsReq, opts ...g
|
|||
|
||||
func (c *hpcACClient) CpuCore(ctx context.Context, in *CpuCoreReq, opts ...grpc.CallOption) (*CpuCoreResp, error) {
|
||||
out := new(CpuCoreResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_CpuCore_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/CpuCore", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -254,7 +218,7 @@ func (c *hpcACClient) CpuCore(ctx context.Context, in *CpuCoreReq, opts ...grpc.
|
|||
|
||||
func (c *hpcACClient) Jobs(ctx context.Context, in *JobsReq, opts ...grpc.CallOption) (*JobsResp, error) {
|
||||
out := new(JobsResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_Jobs_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/jobs", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -263,7 +227,7 @@ func (c *hpcACClient) Jobs(ctx context.Context, in *JobsReq, opts ...grpc.CallOp
|
|||
|
||||
func (c *hpcACClient) HistoryJobDetail(ctx context.Context, in *HistoryJobDetailReq, opts ...grpc.CallOption) (*HistoryJobDetailResp, error) {
|
||||
out := new(HistoryJobDetailResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_HistoryJobDetail_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/HistoryJobDetail", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -272,7 +236,7 @@ func (c *hpcACClient) HistoryJobDetail(ctx context.Context, in *HistoryJobDetail
|
|||
|
||||
func (c *hpcACClient) GetACToken(ctx context.Context, in *ACTokenReq, opts ...grpc.CallOption) (*TokenResp, error) {
|
||||
out := new(TokenResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_GetACToken_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetACToken", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -281,7 +245,7 @@ func (c *hpcACClient) GetACToken(ctx context.Context, in *ACTokenReq, opts ...gr
|
|||
|
||||
func (c *hpcACClient) GetACClusterId(ctx context.Context, in *ACClusterReq, opts ...grpc.CallOption) (*ClusterResp, error) {
|
||||
out := new(ClusterResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_GetACClusterId_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetACClusterId", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -290,7 +254,7 @@ func (c *hpcACClient) GetACClusterId(ctx context.Context, in *ACClusterReq, opts
|
|||
|
||||
func (c *hpcACClient) GetComputingPower(ctx context.Context, in *ResourceReq, opts ...grpc.CallOption) (*CpResp, error) {
|
||||
out := new(CpResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_GetComputingPower_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetComputingPower", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -299,7 +263,7 @@ func (c *hpcACClient) GetComputingPower(ctx context.Context, in *ResourceReq, op
|
|||
|
||||
func (c *hpcACClient) GetGeneralInfo(ctx context.Context, in *ResourceReq, opts ...grpc.CallOption) (*GiResp, error) {
|
||||
out := new(GiResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_GetGeneralInfo_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetGeneralInfo", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -308,7 +272,7 @@ func (c *hpcACClient) GetGeneralInfo(ctx context.Context, in *ResourceReq, opts
|
|||
|
||||
func (c *hpcACClient) SubmitPytorchTask(ctx context.Context, in *SubmitPytorchTaskReq, opts ...grpc.CallOption) (*SubmitTaskAiResp, error) {
|
||||
out := new(SubmitTaskAiResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_SubmitPytorchTask_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/SubmitPytorchTask", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -317,7 +281,7 @@ func (c *hpcACClient) SubmitPytorchTask(ctx context.Context, in *SubmitPytorchTa
|
|||
|
||||
func (c *hpcACClient) SubmitTensorflowTask(ctx context.Context, in *SubmitTensorflowTaskReq, opts ...grpc.CallOption) (*SubmitTaskAiResp, error) {
|
||||
out := new(SubmitTaskAiResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_SubmitTensorflowTask_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/SubmitTensorflowTask", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -326,7 +290,7 @@ func (c *hpcACClient) SubmitTensorflowTask(ctx context.Context, in *SubmitTensor
|
|||
|
||||
func (c *hpcACClient) GetImageListAi(ctx context.Context, in *GetImageListAiReq, opts ...grpc.CallOption) (*GetImageListAiResp, error) {
|
||||
out := new(GetImageListAiResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_GetImageListAi_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetImageListAi", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -335,7 +299,7 @@ func (c *hpcACClient) GetImageListAi(ctx context.Context, in *GetImageListAiReq,
|
|||
|
||||
func (c *hpcACClient) GetImageAiById(ctx context.Context, in *GetImageAiByIdReq, opts ...grpc.CallOption) (*GetImageAiByIdResp, error) {
|
||||
out := new(GetImageAiByIdResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_GetImageAiById_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetImageAiById", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -344,7 +308,7 @@ func (c *hpcACClient) GetImageAiById(ctx context.Context, in *GetImageAiByIdReq,
|
|||
|
||||
func (c *hpcACClient) GetPytorchTask(ctx context.Context, in *GetPytorchTaskReq, opts ...grpc.CallOption) (*GetPytorchTaskResp, error) {
|
||||
out := new(GetPytorchTaskResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_GetPytorchTask_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetPytorchTask", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -353,7 +317,7 @@ func (c *hpcACClient) GetPytorchTask(ctx context.Context, in *GetPytorchTaskReq,
|
|||
|
||||
func (c *hpcACClient) GetTensorflowTask(ctx context.Context, in *GetTensorflowTaskReq, opts ...grpc.CallOption) (*GetTensorflowTaskResp, error) {
|
||||
out := new(GetTensorflowTaskResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_GetTensorflowTask_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetTensorflowTask", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -362,7 +326,7 @@ func (c *hpcACClient) GetTensorflowTask(ctx context.Context, in *GetTensorflowTa
|
|||
|
||||
func (c *hpcACClient) DeleteTaskAi(ctx context.Context, in *DeleteTaskAiReq, opts ...grpc.CallOption) (*DeleteTaskAiResp, error) {
|
||||
out := new(DeleteTaskAiResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_DeleteTaskAi_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/DeleteTaskAi", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -371,7 +335,7 @@ func (c *hpcACClient) DeleteTaskAi(ctx context.Context, in *DeleteTaskAiReq, opt
|
|||
|
||||
func (c *hpcACClient) GetResourceSpec(ctx context.Context, in *GetResourceSpecReq, opts ...grpc.CallOption) (*GetResourceSpecResp, error) {
|
||||
out := new(GetResourceSpecResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_GetResourceSpec_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetResourceSpec", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -380,7 +344,25 @@ func (c *hpcACClient) GetResourceSpec(ctx context.Context, in *GetResourceSpecRe
|
|||
|
||||
func (c *hpcACClient) GetInstanceLog(ctx context.Context, in *GetInstanceLogReq, opts ...grpc.CallOption) (*GetInstanceLogResp, error) {
|
||||
out := new(GetInstanceLogResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_GetInstanceLog_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetInstanceLog", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *hpcACClient) GetInstanceListAi(ctx context.Context, in *GetInstanceListReq, opts ...grpc.CallOption) (*GetInstanceListResp, error) {
|
||||
out := new(GetInstanceListResp)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetInstanceListAi", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *hpcACClient) GetInferUrl(ctx context.Context, in *GetInferUrlReq, opts ...grpc.CallOption) (*GetInferUrlResp, error) {
|
||||
out := new(GetInferUrlResp)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetInferUrl", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -389,7 +371,7 @@ func (c *hpcACClient) GetInstanceLog(ctx context.Context, in *GetInstanceLogReq,
|
|||
|
||||
func (c *hpcACClient) GetFileList(ctx context.Context, in *GetFileListReq, opts ...grpc.CallOption) (*GetFileListResp, error) {
|
||||
out := new(GetFileListResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_GetFileList_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetFileList", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -398,7 +380,7 @@ func (c *hpcACClient) GetFileList(ctx context.Context, in *GetFileListReq, opts
|
|||
|
||||
func (c *hpcACClient) GetFile(ctx context.Context, in *GetFileReq, opts ...grpc.CallOption) (*GetFileResp, error) {
|
||||
out := new(GetFileResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_GetFile_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetFile", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -407,7 +389,7 @@ func (c *hpcACClient) GetFile(ctx context.Context, in *GetFileReq, opts ...grpc.
|
|||
|
||||
func (c *hpcACClient) UploadFile(ctx context.Context, in *UploadFileReq, opts ...grpc.CallOption) (*UploadFileResp, error) {
|
||||
out := new(UploadFileResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_UploadFile_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/UploadFile", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -416,7 +398,7 @@ func (c *hpcACClient) UploadFile(ctx context.Context, in *UploadFileReq, opts ..
|
|||
|
||||
func (c *hpcACClient) GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts ...grpc.CallOption) (*GetUserInfoResp, error) {
|
||||
out := new(GetUserInfoResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_GetUserInfo_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetUserInfo", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -425,7 +407,7 @@ func (c *hpcACClient) GetUserInfo(ctx context.Context, in *GetUserInfoReq, opts
|
|||
|
||||
func (c *hpcACClient) GetMemberJobs(ctx context.Context, in *GetMemberJobsReq, opts ...grpc.CallOption) (*GetMemberJobsResp, error) {
|
||||
out := new(GetMemberJobsResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_GetMemberJobs_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetMemberJobs", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -434,7 +416,7 @@ func (c *hpcACClient) GetMemberJobs(ctx context.Context, in *GetMemberJobsReq, o
|
|||
|
||||
func (c *hpcACClient) GetNodeResources(ctx context.Context, in *GetNodeResourcesReq, opts ...grpc.CallOption) (*GetNodeResourcesResp, error) {
|
||||
out := new(GetNodeResourcesResp)
|
||||
err := c.cc.Invoke(ctx, HpcAC_GetNodeResources_FullMethodName, in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/hpcAC.hpcAC/GetNodeResources", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -492,6 +474,8 @@ type HpcACServer interface {
|
|||
DeleteTaskAi(context.Context, *DeleteTaskAiReq) (*DeleteTaskAiResp, error)
|
||||
GetResourceSpec(context.Context, *GetResourceSpecReq) (*GetResourceSpecResp, error)
|
||||
GetInstanceLog(context.Context, *GetInstanceLogReq) (*GetInstanceLogResp, error)
|
||||
GetInstanceListAi(context.Context, *GetInstanceListReq) (*GetInstanceListResp, error)
|
||||
GetInferUrl(context.Context, *GetInferUrlReq) (*GetInferUrlResp, error)
|
||||
// 曙光文件接口
|
||||
GetFileList(context.Context, *GetFileListReq) (*GetFileListResp, error)
|
||||
GetFile(context.Context, *GetFileReq) (*GetFileResp, error)
|
||||
|
@ -595,6 +579,12 @@ func (UnimplementedHpcACServer) GetResourceSpec(context.Context, *GetResourceSpe
|
|||
func (UnimplementedHpcACServer) GetInstanceLog(context.Context, *GetInstanceLogReq) (*GetInstanceLogResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetInstanceLog not implemented")
|
||||
}
|
||||
func (UnimplementedHpcACServer) GetInstanceListAi(context.Context, *GetInstanceListReq) (*GetInstanceListResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetInstanceListAi not implemented")
|
||||
}
|
||||
func (UnimplementedHpcACServer) GetInferUrl(context.Context, *GetInferUrlReq) (*GetInferUrlResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetInferUrl not implemented")
|
||||
}
|
||||
func (UnimplementedHpcACServer) GetFileList(context.Context, *GetFileListReq) (*GetFileListResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetFileList not implemented")
|
||||
}
|
||||
|
@ -636,7 +626,7 @@ func _HpcAC_ListJob_Handler(srv interface{}, ctx context.Context, dec func(inter
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_ListJob_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/ListJob",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).ListJob(ctx, req.(*ListJobReq))
|
||||
|
@ -654,7 +644,7 @@ func _HpcAC_ListHistoryJob_Handler(srv interface{}, ctx context.Context, dec fun
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_ListHistoryJob_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/ListHistoryJob",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).ListHistoryJob(ctx, req.(*ListHistoryJobReq))
|
||||
|
@ -672,7 +662,7 @@ func _HpcAC_SubmitJob_Handler(srv interface{}, ctx context.Context, dec func(int
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_SubmitJob_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/SubmitJob",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).SubmitJob(ctx, req.(*SubmitJobReq))
|
||||
|
@ -690,7 +680,7 @@ func _HpcAC_ListJobManager_Handler(srv interface{}, ctx context.Context, dec fun
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_ListJobManager_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/ListJobManager",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).ListJobManager(ctx, req.(*JobManagerReq))
|
||||
|
@ -708,7 +698,7 @@ func _HpcAC_GetJobDetail_Handler(srv interface{}, ctx context.Context, dec func(
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_GetJobDetail_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/GetJobDetail",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetJobDetail(ctx, req.(*JobDetailReq))
|
||||
|
@ -726,7 +716,7 @@ func _HpcAC_DeleteJob_Handler(srv interface{}, ctx context.Context, dec func(int
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_DeleteJob_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/DeleteJob",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).DeleteJob(ctx, req.(*DeleteJobReq))
|
||||
|
@ -744,7 +734,7 @@ func _HpcAC_FileContent_Handler(srv interface{}, ctx context.Context, dec func(i
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_FileContent_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/FileContent",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).FileContent(ctx, req.(*FileDataReq))
|
||||
|
@ -762,7 +752,7 @@ func _HpcAC_SelectQueueByUser_Handler(srv interface{}, ctx context.Context, dec
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_SelectQueueByUser_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/SelectQueueByUser",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).SelectQueueByUser(ctx, req.(*QueueReq))
|
||||
|
@ -780,7 +770,7 @@ func _HpcAC_QueryQueueDetails_Handler(srv interface{}, ctx context.Context, dec
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_QueryQueueDetails_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/QueryQueueDetails",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).QueryQueueDetails(ctx, req.(*QueueReq))
|
||||
|
@ -798,7 +788,7 @@ func _HpcAC_QueryUserQuotasLimit_Handler(srv interface{}, ctx context.Context, d
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_QueryUserQuotasLimit_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/QueryUserQuotasLimit",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).QueryUserQuotasLimit(ctx, req.(*QueueReq))
|
||||
|
@ -816,7 +806,7 @@ func _HpcAC_ParaStorQuota_Handler(srv interface{}, ctx context.Context, dec func
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_ParaStorQuota_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/ParaStorQuota",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).ParaStorQuota(ctx, req.(*ParaStorQuotaReq))
|
||||
|
@ -834,7 +824,7 @@ func _HpcAC_WallTime_Handler(srv interface{}, ctx context.Context, dec func(inte
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_WallTime_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/WallTime",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).WallTime(ctx, req.(*WallTimeReq))
|
||||
|
@ -852,7 +842,7 @@ func _HpcAC_QueueJobs_Handler(srv interface{}, ctx context.Context, dec func(int
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_QueueJobs_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/QueueJobs",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).QueueJobs(ctx, req.(*QueueJobsReq))
|
||||
|
@ -870,7 +860,7 @@ func _HpcAC_CpuCore_Handler(srv interface{}, ctx context.Context, dec func(inter
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_CpuCore_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/CpuCore",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).CpuCore(ctx, req.(*CpuCoreReq))
|
||||
|
@ -888,7 +878,7 @@ func _HpcAC_Jobs_Handler(srv interface{}, ctx context.Context, dec func(interfac
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_Jobs_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/jobs",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).Jobs(ctx, req.(*JobsReq))
|
||||
|
@ -906,7 +896,7 @@ func _HpcAC_HistoryJobDetail_Handler(srv interface{}, ctx context.Context, dec f
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_HistoryJobDetail_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/HistoryJobDetail",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).HistoryJobDetail(ctx, req.(*HistoryJobDetailReq))
|
||||
|
@ -924,7 +914,7 @@ func _HpcAC_GetACToken_Handler(srv interface{}, ctx context.Context, dec func(in
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_GetACToken_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/GetACToken",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetACToken(ctx, req.(*ACTokenReq))
|
||||
|
@ -942,7 +932,7 @@ func _HpcAC_GetACClusterId_Handler(srv interface{}, ctx context.Context, dec fun
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_GetACClusterId_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/GetACClusterId",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetACClusterId(ctx, req.(*ACClusterReq))
|
||||
|
@ -960,7 +950,7 @@ func _HpcAC_GetComputingPower_Handler(srv interface{}, ctx context.Context, dec
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_GetComputingPower_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/GetComputingPower",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetComputingPower(ctx, req.(*ResourceReq))
|
||||
|
@ -978,7 +968,7 @@ func _HpcAC_GetGeneralInfo_Handler(srv interface{}, ctx context.Context, dec fun
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_GetGeneralInfo_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/GetGeneralInfo",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetGeneralInfo(ctx, req.(*ResourceReq))
|
||||
|
@ -996,7 +986,7 @@ func _HpcAC_SubmitPytorchTask_Handler(srv interface{}, ctx context.Context, dec
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_SubmitPytorchTask_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/SubmitPytorchTask",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).SubmitPytorchTask(ctx, req.(*SubmitPytorchTaskReq))
|
||||
|
@ -1014,7 +1004,7 @@ func _HpcAC_SubmitTensorflowTask_Handler(srv interface{}, ctx context.Context, d
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_SubmitTensorflowTask_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/SubmitTensorflowTask",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).SubmitTensorflowTask(ctx, req.(*SubmitTensorflowTaskReq))
|
||||
|
@ -1032,7 +1022,7 @@ func _HpcAC_GetImageListAi_Handler(srv interface{}, ctx context.Context, dec fun
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_GetImageListAi_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/GetImageListAi",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetImageListAi(ctx, req.(*GetImageListAiReq))
|
||||
|
@ -1050,7 +1040,7 @@ func _HpcAC_GetImageAiById_Handler(srv interface{}, ctx context.Context, dec fun
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_GetImageAiById_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/GetImageAiById",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetImageAiById(ctx, req.(*GetImageAiByIdReq))
|
||||
|
@ -1068,7 +1058,7 @@ func _HpcAC_GetPytorchTask_Handler(srv interface{}, ctx context.Context, dec fun
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_GetPytorchTask_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/GetPytorchTask",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetPytorchTask(ctx, req.(*GetPytorchTaskReq))
|
||||
|
@ -1086,7 +1076,7 @@ func _HpcAC_GetTensorflowTask_Handler(srv interface{}, ctx context.Context, dec
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_GetTensorflowTask_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/GetTensorflowTask",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetTensorflowTask(ctx, req.(*GetTensorflowTaskReq))
|
||||
|
@ -1104,7 +1094,7 @@ func _HpcAC_DeleteTaskAi_Handler(srv interface{}, ctx context.Context, dec func(
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_DeleteTaskAi_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/DeleteTaskAi",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).DeleteTaskAi(ctx, req.(*DeleteTaskAiReq))
|
||||
|
@ -1122,7 +1112,7 @@ func _HpcAC_GetResourceSpec_Handler(srv interface{}, ctx context.Context, dec fu
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_GetResourceSpec_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/GetResourceSpec",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetResourceSpec(ctx, req.(*GetResourceSpecReq))
|
||||
|
@ -1140,7 +1130,7 @@ func _HpcAC_GetInstanceLog_Handler(srv interface{}, ctx context.Context, dec fun
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_GetInstanceLog_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/GetInstanceLog",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetInstanceLog(ctx, req.(*GetInstanceLogReq))
|
||||
|
@ -1148,6 +1138,42 @@ func _HpcAC_GetInstanceLog_Handler(srv interface{}, ctx context.Context, dec fun
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _HpcAC_GetInstanceListAi_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetInstanceListReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HpcACServer).GetInstanceListAi(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/hpcAC.hpcAC/GetInstanceListAi",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetInstanceListAi(ctx, req.(*GetInstanceListReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _HpcAC_GetInferUrl_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetInferUrlReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HpcACServer).GetInferUrl(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/hpcAC.hpcAC/GetInferUrl",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetInferUrl(ctx, req.(*GetInferUrlReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _HpcAC_GetFileList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetFileListReq)
|
||||
if err := dec(in); err != nil {
|
||||
|
@ -1158,7 +1184,7 @@ func _HpcAC_GetFileList_Handler(srv interface{}, ctx context.Context, dec func(i
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_GetFileList_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/GetFileList",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetFileList(ctx, req.(*GetFileListReq))
|
||||
|
@ -1176,7 +1202,7 @@ func _HpcAC_GetFile_Handler(srv interface{}, ctx context.Context, dec func(inter
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_GetFile_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/GetFile",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetFile(ctx, req.(*GetFileReq))
|
||||
|
@ -1194,7 +1220,7 @@ func _HpcAC_UploadFile_Handler(srv interface{}, ctx context.Context, dec func(in
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_UploadFile_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/UploadFile",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).UploadFile(ctx, req.(*UploadFileReq))
|
||||
|
@ -1212,7 +1238,7 @@ func _HpcAC_GetUserInfo_Handler(srv interface{}, ctx context.Context, dec func(i
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_GetUserInfo_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/GetUserInfo",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetUserInfo(ctx, req.(*GetUserInfoReq))
|
||||
|
@ -1230,7 +1256,7 @@ func _HpcAC_GetMemberJobs_Handler(srv interface{}, ctx context.Context, dec func
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_GetMemberJobs_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/GetMemberJobs",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetMemberJobs(ctx, req.(*GetMemberJobsReq))
|
||||
|
@ -1248,7 +1274,7 @@ func _HpcAC_GetNodeResources_Handler(srv interface{}, ctx context.Context, dec f
|
|||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: HpcAC_GetNodeResources_FullMethodName,
|
||||
FullMethod: "/hpcAC.hpcAC/GetNodeResources",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HpcACServer).GetNodeResources(ctx, req.(*GetNodeResourcesReq))
|
||||
|
@ -1379,6 +1405,14 @@ var HpcAC_ServiceDesc = grpc.ServiceDesc{
|
|||
MethodName: "GetInstanceLog",
|
||||
Handler: _HpcAC_GetInstanceLog_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetInstanceListAi",
|
||||
Handler: _HpcAC_GetInstanceListAi_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetInferUrl",
|
||||
Handler: _HpcAC_GetInferUrl_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetFileList",
|
||||
Handler: _HpcAC_GetFileList_Handler,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
// Source: hpcAC.proto
|
||||
|
||||
package hpcacclient
|
||||
package hpcACClient
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
@ -22,6 +22,7 @@ type (
|
|||
ACTokenState = hpcAC.ACTokenState
|
||||
Children = hpcAC.Children
|
||||
ClusterResp = hpcAC.ClusterResp
|
||||
ContainerPortInfo = hpcAC.ContainerPortInfo
|
||||
CpResp = hpcAC.CpResp
|
||||
CpuCore = hpcAC.CpuCore
|
||||
CpuCoreReq = hpcAC.CpuCoreReq
|
||||
|
@ -43,6 +44,13 @@ type (
|
|||
GetImageAiByIdResp = hpcAC.GetImageAiByIdResp
|
||||
GetImageListAiReq = hpcAC.GetImageListAiReq
|
||||
GetImageListAiResp = hpcAC.GetImageListAiResp
|
||||
GetInferUrlReq = hpcAC.GetInferUrlReq
|
||||
GetInferUrlResp = hpcAC.GetInferUrlResp
|
||||
GetInstanceDetailParams = hpcAC.GetInstanceDetailParams
|
||||
GetInstanceDetailResp = hpcAC.GetInstanceDetailResp
|
||||
GetInstanceListParams = hpcAC.GetInstanceListParams
|
||||
GetInstanceListReq = hpcAC.GetInstanceListReq
|
||||
GetInstanceListResp = hpcAC.GetInstanceListResp
|
||||
GetInstanceLogReq = hpcAC.GetInstanceLogReq
|
||||
GetInstanceLogResp = hpcAC.GetInstanceLogResp
|
||||
GetJobDetailResp = hpcAC.GetJobDetailResp
|
||||
|
@ -166,6 +174,8 @@ type (
|
|||
DeleteTaskAi(ctx context.Context, in *DeleteTaskAiReq, opts ...grpc.CallOption) (*DeleteTaskAiResp, error)
|
||||
GetResourceSpec(ctx context.Context, in *GetResourceSpecReq, opts ...grpc.CallOption) (*GetResourceSpecResp, error)
|
||||
GetInstanceLog(ctx context.Context, in *GetInstanceLogReq, opts ...grpc.CallOption) (*GetInstanceLogResp, error)
|
||||
GetInstanceListAi(ctx context.Context, in *GetInstanceListReq, opts ...grpc.CallOption) (*GetInstanceListResp, error)
|
||||
GetInferUrl(ctx context.Context, in *GetInferUrlReq, opts ...grpc.CallOption) (*GetInferUrlResp, error)
|
||||
// 曙光文件接口
|
||||
GetFileList(ctx context.Context, in *GetFileListReq, opts ...grpc.CallOption) (*GetFileListResp, error)
|
||||
GetFile(ctx context.Context, in *GetFileReq, opts ...grpc.CallOption) (*GetFileResp, error)
|
||||
|
@ -351,6 +361,16 @@ func (m *defaultHpcAC) GetInstanceLog(ctx context.Context, in *GetInstanceLogReq
|
|||
return client.GetInstanceLog(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultHpcAC) GetInstanceListAi(ctx context.Context, in *GetInstanceListReq, opts ...grpc.CallOption) (*GetInstanceListResp, error) {
|
||||
client := hpcAC.NewHpcACClient(m.cli.Conn())
|
||||
return client.GetInstanceListAi(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultHpcAC) GetInferUrl(ctx context.Context, in *GetInferUrlReq, opts ...grpc.CallOption) (*GetInferUrlResp, error) {
|
||||
client := hpcAC.NewHpcACClient(m.cli.Conn())
|
||||
return client.GetInferUrl(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// 曙光文件接口
|
||||
func (m *defaultHpcAC) GetFileList(ctx context.Context, in *GetFileListReq, opts ...grpc.CallOption) (*GetFileListResp, error) {
|
||||
client := hpcAC.NewHpcACClient(m.cli.Conn())
|
||||
|
|
|
@ -252,6 +252,7 @@ func formatDescOpt(t protoreflect.Descriptor, isRoot, allowMulti bool, record fu
|
|||
{rv.MethodByName("Values"), "Values"},
|
||||
{rv.MethodByName("ReservedNames"), "ReservedNames"},
|
||||
{rv.MethodByName("ReservedRanges"), "ReservedRanges"},
|
||||
{rv.MethodByName("IsClosed"), "IsClosed"},
|
||||
}...)
|
||||
|
||||
case protoreflect.EnumValueDescriptor:
|
||||
|
|
BIN
vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb
generated
vendored
BIN
vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb
generated
vendored
Binary file not shown.
13
vendor/google.golang.org/protobuf/internal/editionssupport/editions.go
generated
vendored
Normal file
13
vendor/google.golang.org/protobuf/internal/editionssupport/editions.go
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Copyright 2024 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package editionssupport defines constants for editions that are supported.
|
||||
package editionssupport
|
||||
|
||||
import descriptorpb "google.golang.org/protobuf/types/descriptorpb"
|
||||
|
||||
const (
|
||||
Minimum = descriptorpb.Edition_EDITION_PROTO2
|
||||
Maximum = descriptorpb.Edition_EDITION_2023
|
||||
)
|
|
@ -32,6 +32,7 @@ var byteType = reflect.TypeOf(byte(0))
|
|||
func Unmarshal(tag string, goType reflect.Type, evs protoreflect.EnumValueDescriptors) protoreflect.FieldDescriptor {
|
||||
f := new(filedesc.Field)
|
||||
f.L0.ParentFile = filedesc.SurrogateProto2
|
||||
f.L1.EditionFeatures = f.L0.ParentFile.L1.EditionFeatures
|
||||
for len(tag) > 0 {
|
||||
i := strings.IndexByte(tag, ',')
|
||||
if i < 0 {
|
||||
|
@ -107,8 +108,7 @@ func Unmarshal(tag string, goType reflect.Type, evs protoreflect.EnumValueDescri
|
|||
f.L1.StringName.InitJSON(jsonName)
|
||||
}
|
||||
case s == "packed":
|
||||
f.L1.HasPacked = true
|
||||
f.L1.IsPacked = true
|
||||
f.L1.EditionFeatures.IsPacked = true
|
||||
case strings.HasPrefix(s, "weak="):
|
||||
f.L1.IsWeak = true
|
||||
f.L1.Message = filedesc.PlaceholderMessage(protoreflect.FullName(s[len("weak="):]))
|
||||
|
|
|
@ -7,6 +7,7 @@ package filedesc
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
|
@ -108,9 +109,12 @@ func (fd *File) ParentFile() protoreflect.FileDescriptor { return fd }
|
|||
func (fd *File) Parent() protoreflect.Descriptor { return nil }
|
||||
func (fd *File) Index() int { return 0 }
|
||||
func (fd *File) Syntax() protoreflect.Syntax { return fd.L1.Syntax }
|
||||
func (fd *File) Name() protoreflect.Name { return fd.L1.Package.Name() }
|
||||
func (fd *File) FullName() protoreflect.FullName { return fd.L1.Package }
|
||||
func (fd *File) IsPlaceholder() bool { return false }
|
||||
|
||||
// Not exported and just used to reconstruct the original FileDescriptor proto
|
||||
func (fd *File) Edition() int32 { return int32(fd.L1.Edition) }
|
||||
func (fd *File) Name() protoreflect.Name { return fd.L1.Package.Name() }
|
||||
func (fd *File) FullName() protoreflect.FullName { return fd.L1.Package }
|
||||
func (fd *File) IsPlaceholder() bool { return false }
|
||||
func (fd *File) Options() protoreflect.ProtoMessage {
|
||||
if f := fd.lazyInit().Options; f != nil {
|
||||
return f()
|
||||
|
@ -202,6 +206,9 @@ func (ed *Enum) lazyInit() *EnumL2 {
|
|||
ed.L0.ParentFile.lazyInit() // implicitly initializes L2
|
||||
return ed.L2
|
||||
}
|
||||
func (ed *Enum) IsClosed() bool {
|
||||
return !ed.L1.EditionFeatures.IsOpenEnum
|
||||
}
|
||||
|
||||
func (ed *EnumValue) Options() protoreflect.ProtoMessage {
|
||||
if f := ed.L1.Options; f != nil {
|
||||
|
@ -251,10 +258,6 @@ type (
|
|||
StringName stringName
|
||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||
IsWeak bool // promoted from google.protobuf.FieldOptions
|
||||
HasPacked bool // promoted from google.protobuf.FieldOptions
|
||||
IsPacked bool // promoted from google.protobuf.FieldOptions
|
||||
HasEnforceUTF8 bool // promoted from google.protobuf.FieldOptions
|
||||
EnforceUTF8 bool // promoted from google.protobuf.FieldOptions
|
||||
Default defaultValue
|
||||
ContainingOneof protoreflect.OneofDescriptor // must be consistent with Message.Oneofs.Fields
|
||||
Enum protoreflect.EnumDescriptor
|
||||
|
@ -331,8 +334,7 @@ func (fd *Field) HasPresence() bool {
|
|||
if fd.L1.Cardinality == protoreflect.Repeated {
|
||||
return false
|
||||
}
|
||||
explicitFieldPresence := fd.Syntax() == protoreflect.Editions && fd.L1.EditionFeatures.IsFieldPresence
|
||||
return fd.Syntax() == protoreflect.Proto2 || explicitFieldPresence || fd.L1.Message != nil || fd.L1.ContainingOneof != nil
|
||||
return fd.IsExtension() || fd.L1.EditionFeatures.IsFieldPresence || fd.L1.Message != nil || fd.L1.ContainingOneof != nil
|
||||
}
|
||||
func (fd *Field) HasOptionalKeyword() bool {
|
||||
return (fd.L0.ParentFile.L1.Syntax == protoreflect.Proto2 && fd.L1.Cardinality == protoreflect.Optional && fd.L1.ContainingOneof == nil) || fd.L1.IsProto3Optional
|
||||
|
@ -345,14 +347,7 @@ func (fd *Field) IsPacked() bool {
|
|||
case protoreflect.StringKind, protoreflect.BytesKind, protoreflect.MessageKind, protoreflect.GroupKind:
|
||||
return false
|
||||
}
|
||||
if fd.L0.ParentFile.L1.Syntax == protoreflect.Editions {
|
||||
return fd.L1.EditionFeatures.IsPacked
|
||||
}
|
||||
if fd.L0.ParentFile.L1.Syntax == protoreflect.Proto3 {
|
||||
// proto3 repeated fields are packed by default.
|
||||
return !fd.L1.HasPacked || fd.L1.IsPacked
|
||||
}
|
||||
return fd.L1.IsPacked
|
||||
return fd.L1.EditionFeatures.IsPacked
|
||||
}
|
||||
func (fd *Field) IsExtension() bool { return false }
|
||||
func (fd *Field) IsWeak() bool { return fd.L1.IsWeak }
|
||||
|
@ -399,13 +394,7 @@ func (fd *Field) ProtoType(protoreflect.FieldDescriptor) {}
|
|||
// WARNING: This method is exempt from the compatibility promise and may be
|
||||
// removed in the future without warning.
|
||||
func (fd *Field) EnforceUTF8() bool {
|
||||
if fd.L0.ParentFile.L1.Syntax == protoreflect.Editions {
|
||||
return fd.L1.EditionFeatures.IsUTF8Validated
|
||||
}
|
||||
if fd.L1.HasEnforceUTF8 {
|
||||
return fd.L1.EnforceUTF8
|
||||
}
|
||||
return fd.L0.ParentFile.L1.Syntax == protoreflect.Proto3
|
||||
return fd.L1.EditionFeatures.IsUTF8Validated
|
||||
}
|
||||
|
||||
func (od *Oneof) IsSynthetic() bool {
|
||||
|
@ -433,12 +422,19 @@ type (
|
|||
Cardinality protoreflect.Cardinality
|
||||
Kind protoreflect.Kind
|
||||
EditionFeatures EditionFeatures
|
||||
// To resolve the EditionFeatures we need to resolve the Extendee which
|
||||
// happens at the end of the initialization of L1. Thus, we need to buffer
|
||||
// the unresolved features (which are parsed when starting to initialize
|
||||
// L1). We cannot move this to L2 because it is required to initialize
|
||||
// Kind properly. Because some of the options (i.e. packed) affect the
|
||||
// EditionFeatures we need to unmarshal the full options after resolving
|
||||
// the Extendee.
|
||||
rawOptions []byte
|
||||
}
|
||||
ExtensionL2 struct {
|
||||
Options func() protoreflect.ProtoMessage
|
||||
StringName stringName
|
||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||
IsPacked bool // promoted from google.protobuf.FieldOptions
|
||||
Default defaultValue
|
||||
Enum protoreflect.EnumDescriptor
|
||||
Message protoreflect.MessageDescriptor
|
||||
|
@ -461,7 +457,7 @@ func (xd *Extension) HasPresence() bool { return xd.L1.Cardi
|
|||
func (xd *Extension) HasOptionalKeyword() bool {
|
||||
return (xd.L0.ParentFile.L1.Syntax == protoreflect.Proto2 && xd.L1.Cardinality == protoreflect.Optional) || xd.lazyInit().IsProto3Optional
|
||||
}
|
||||
func (xd *Extension) IsPacked() bool { return xd.lazyInit().IsPacked }
|
||||
func (xd *Extension) IsPacked() bool { return xd.L1.EditionFeatures.IsPacked }
|
||||
func (xd *Extension) IsExtension() bool { return true }
|
||||
func (xd *Extension) IsWeak() bool { return false }
|
||||
func (xd *Extension) IsList() bool { return xd.Cardinality() == protoreflect.Repeated }
|
||||
|
@ -542,8 +538,9 @@ func (md *Method) ProtoInternal(pragma.DoNotImplement) {}
|
|||
// Surrogate files are can be used to create standalone descriptors
|
||||
// where the syntax is only information derived from the parent file.
|
||||
var (
|
||||
SurrogateProto2 = &File{L1: FileL1{Syntax: protoreflect.Proto2}, L2: &FileL2{}}
|
||||
SurrogateProto3 = &File{L1: FileL1{Syntax: protoreflect.Proto3}, L2: &FileL2{}}
|
||||
SurrogateProto2 = &File{L1: FileL1{Syntax: protoreflect.Proto2}, L2: &FileL2{}}
|
||||
SurrogateProto3 = &File{L1: FileL1{Syntax: protoreflect.Proto3}, L2: &FileL2{}}
|
||||
SurrogateEdition2023 = &File{L1: FileL1{Syntax: protoreflect.Editions, Edition: Edition2023}, L2: &FileL2{}}
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -585,6 +582,34 @@ func (s *stringName) InitJSON(name string) {
|
|||
s.nameJSON = name
|
||||
}
|
||||
|
||||
// Returns true if this field is structured like the synthetic field of a proto2
|
||||
// group. This allows us to expand our treatment of delimited fields without
|
||||
// breaking proto2 files that have been upgraded to editions.
|
||||
func isGroupLike(fd protoreflect.FieldDescriptor) bool {
|
||||
// Groups are always group types.
|
||||
if fd.Kind() != protoreflect.GroupKind {
|
||||
return false
|
||||
}
|
||||
|
||||
// Group fields are always the lowercase type name.
|
||||
if strings.ToLower(string(fd.Message().Name())) != string(fd.Name()) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Groups could only be defined in the same file they're used.
|
||||
if fd.Message().ParentFile() != fd.ParentFile() {
|
||||
return false
|
||||
}
|
||||
|
||||
// Group messages are always defined in the same scope as the field. File
|
||||
// level extensions will compare NULL == NULL here, which is why the file
|
||||
// comparison above is necessary to ensure both come from the same file.
|
||||
if fd.IsExtension() {
|
||||
return fd.Parent() == fd.Message().Parent()
|
||||
}
|
||||
return fd.ContainingMessage() == fd.Message().Parent()
|
||||
}
|
||||
|
||||
func (s *stringName) lazyInit(fd protoreflect.FieldDescriptor) *stringName {
|
||||
s.once.Do(func() {
|
||||
if fd.IsExtension() {
|
||||
|
@ -605,7 +630,7 @@ func (s *stringName) lazyInit(fd protoreflect.FieldDescriptor) *stringName {
|
|||
|
||||
// Format the text name.
|
||||
s.nameText = string(fd.Name())
|
||||
if fd.Kind() == protoreflect.GroupKind {
|
||||
if isGroupLike(fd) {
|
||||
s.nameText = string(fd.Message().Name())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,20 @@ func newRawFile(db Builder) *File {
|
|||
for i := range fd.allExtensions {
|
||||
xd := &fd.allExtensions[i]
|
||||
xd.L1.Extendee = fd.resolveMessageDependency(xd.L1.Extendee, listExtTargets, int32(i))
|
||||
|
||||
// If the Extendee is not resolved, we cannot resolve the edition
|
||||
// features of the parent. This should (to my knowledge) only happen
|
||||
// for v1 messages for which we don't support editions. In v2 the
|
||||
// Extendee should be resolved at binary start up time.
|
||||
if _, ok := xd.L1.Extendee.(PlaceholderMessage); !ok {
|
||||
xd.L1.EditionFeatures = featuresFromParentDesc(xd.L1.Extendee)
|
||||
}
|
||||
if xd.L1.rawOptions != nil {
|
||||
xd.unmarshalOptions(xd.L1.rawOptions)
|
||||
}
|
||||
if xd.L1.Kind == protoreflect.MessageKind && xd.L1.EditionFeatures.IsDelimitedEncoded {
|
||||
xd.L1.Kind = protoreflect.GroupKind
|
||||
}
|
||||
}
|
||||
|
||||
fd.checkDecls()
|
||||
|
@ -113,8 +127,10 @@ func (fd *File) unmarshalSeed(b []byte) {
|
|||
switch string(v) {
|
||||
case "proto2":
|
||||
fd.L1.Syntax = protoreflect.Proto2
|
||||
fd.L1.Edition = EditionProto2
|
||||
case "proto3":
|
||||
fd.L1.Syntax = protoreflect.Proto3
|
||||
fd.L1.Edition = EditionProto3
|
||||
case "editions":
|
||||
fd.L1.Syntax = protoreflect.Editions
|
||||
default:
|
||||
|
@ -177,11 +193,10 @@ func (fd *File) unmarshalSeed(b []byte) {
|
|||
// If syntax is missing, it is assumed to be proto2.
|
||||
if fd.L1.Syntax == 0 {
|
||||
fd.L1.Syntax = protoreflect.Proto2
|
||||
fd.L1.Edition = EditionProto2
|
||||
}
|
||||
|
||||
if fd.L1.Syntax == protoreflect.Editions {
|
||||
fd.L1.EditionFeatures = getFeaturesFor(fd.L1.Edition)
|
||||
}
|
||||
fd.L1.EditionFeatures = getFeaturesFor(fd.L1.Edition)
|
||||
|
||||
// Parse editions features from options if any
|
||||
if options != nil {
|
||||
|
@ -267,6 +282,7 @@ func (ed *Enum) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd protorefl
|
|||
ed.L0.ParentFile = pf
|
||||
ed.L0.Parent = pd
|
||||
ed.L0.Index = i
|
||||
ed.L1.EditionFeatures = featuresFromParentDesc(ed.Parent())
|
||||
|
||||
var numValues int
|
||||
for b := b; len(b) > 0; {
|
||||
|
@ -467,6 +483,34 @@ func (xd *Extension) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd prot
|
|||
xd.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
case genid.FieldDescriptorProto_Extendee_field_number:
|
||||
xd.L1.Extendee = PlaceholderMessage(makeFullName(sb, v))
|
||||
case genid.FieldDescriptorProto_Options_field_number:
|
||||
xd.L1.rawOptions = v
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
b = b[m:]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (xd *Extension) unmarshalOptions(b []byte) {
|
||||
for len(b) > 0 {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
switch typ {
|
||||
case protowire.VarintType:
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FieldOptions_Packed_field_number:
|
||||
xd.L1.EditionFeatures.IsPacked = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FieldOptions_Features_field_number:
|
||||
xd.L1.EditionFeatures = unmarshalFeatureSet(v, xd.L1.EditionFeatures)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
|
|
|
@ -466,10 +466,10 @@ func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd protoref
|
|||
b = b[m:]
|
||||
}
|
||||
}
|
||||
if fd.Syntax() == protoreflect.Editions && fd.L1.Kind == protoreflect.MessageKind && fd.L1.EditionFeatures.IsDelimitedEncoded {
|
||||
if fd.L1.Kind == protoreflect.MessageKind && fd.L1.EditionFeatures.IsDelimitedEncoded {
|
||||
fd.L1.Kind = protoreflect.GroupKind
|
||||
}
|
||||
if fd.Syntax() == protoreflect.Editions && fd.L1.EditionFeatures.IsLegacyRequired {
|
||||
if fd.L1.EditionFeatures.IsLegacyRequired {
|
||||
fd.L1.Cardinality = protoreflect.Required
|
||||
}
|
||||
if rawTypeName != nil {
|
||||
|
@ -496,13 +496,11 @@ func (fd *Field) unmarshalOptions(b []byte) {
|
|||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FieldOptions_Packed_field_number:
|
||||
fd.L1.HasPacked = true
|
||||
fd.L1.IsPacked = protowire.DecodeBool(v)
|
||||
fd.L1.EditionFeatures.IsPacked = protowire.DecodeBool(v)
|
||||
case genid.FieldOptions_Weak_field_number:
|
||||
fd.L1.IsWeak = protowire.DecodeBool(v)
|
||||
case FieldOptions_EnforceUTF8:
|
||||
fd.L1.HasEnforceUTF8 = true
|
||||
fd.L1.EnforceUTF8 = protowire.DecodeBool(v)
|
||||
fd.L1.EditionFeatures.IsUTF8Validated = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
|
@ -548,7 +546,6 @@ func (od *Oneof) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd protoref
|
|||
func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
var rawTypeName []byte
|
||||
var rawOptions []byte
|
||||
xd.L1.EditionFeatures = featuresFromParentDesc(xd.L1.Extendee)
|
||||
xd.L2 = new(ExtensionL2)
|
||||
for len(b) > 0 {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
|
@ -572,7 +569,6 @@ func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) {
|
|||
case genid.FieldDescriptorProto_TypeName_field_number:
|
||||
rawTypeName = v
|
||||
case genid.FieldDescriptorProto_Options_field_number:
|
||||
xd.unmarshalOptions(v)
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
default:
|
||||
|
@ -580,12 +576,6 @@ func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) {
|
|||
b = b[m:]
|
||||
}
|
||||
}
|
||||
if xd.Syntax() == protoreflect.Editions && xd.L1.Kind == protoreflect.MessageKind && xd.L1.EditionFeatures.IsDelimitedEncoded {
|
||||
xd.L1.Kind = protoreflect.GroupKind
|
||||
}
|
||||
if xd.Syntax() == protoreflect.Editions && xd.L1.EditionFeatures.IsLegacyRequired {
|
||||
xd.L1.Cardinality = protoreflect.Required
|
||||
}
|
||||
if rawTypeName != nil {
|
||||
name := makeFullName(sb, rawTypeName)
|
||||
switch xd.L1.Kind {
|
||||
|
@ -598,32 +588,6 @@ func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) {
|
|||
xd.L2.Options = xd.L0.ParentFile.builder.optionsUnmarshaler(&descopts.Field, rawOptions)
|
||||
}
|
||||
|
||||
func (xd *Extension) unmarshalOptions(b []byte) {
|
||||
for len(b) > 0 {
|
||||
num, typ, n := protowire.ConsumeTag(b)
|
||||
b = b[n:]
|
||||
switch typ {
|
||||
case protowire.VarintType:
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FieldOptions_Packed_field_number:
|
||||
xd.L2.IsPacked = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case genid.FieldOptions_Features_field_number:
|
||||
xd.L1.EditionFeatures = unmarshalFeatureSet(v, xd.L1.EditionFeatures)
|
||||
}
|
||||
default:
|
||||
m := protowire.ConsumeFieldValue(num, typ, b)
|
||||
b = b[m:]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (sd *Service) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
var rawMethods [][]byte
|
||||
var rawOptions []byte
|
||||
|
|
|
@ -14,9 +14,13 @@ import (
|
|||
)
|
||||
|
||||
var defaultsCache = make(map[Edition]EditionFeatures)
|
||||
var defaultsKeys = []Edition{}
|
||||
|
||||
func init() {
|
||||
unmarshalEditionDefaults(editiondefaults.Defaults)
|
||||
SurrogateProto2.L1.EditionFeatures = getFeaturesFor(EditionProto2)
|
||||
SurrogateProto3.L1.EditionFeatures = getFeaturesFor(EditionProto3)
|
||||
SurrogateEdition2023.L1.EditionFeatures = getFeaturesFor(Edition2023)
|
||||
}
|
||||
|
||||
func unmarshalGoFeature(b []byte, parent EditionFeatures) EditionFeatures {
|
||||
|
@ -110,6 +114,7 @@ func unmarshalEditionDefault(b []byte) {
|
|||
}
|
||||
}
|
||||
defaultsCache[ed] = fs
|
||||
defaultsKeys = append(defaultsKeys, ed)
|
||||
}
|
||||
|
||||
func unmarshalEditionDefaults(b []byte) {
|
||||
|
@ -135,8 +140,15 @@ func unmarshalEditionDefaults(b []byte) {
|
|||
}
|
||||
|
||||
func getFeaturesFor(ed Edition) EditionFeatures {
|
||||
if def, ok := defaultsCache[ed]; ok {
|
||||
return def
|
||||
match := EditionUnknown
|
||||
for _, key := range defaultsKeys {
|
||||
if key > ed {
|
||||
break
|
||||
}
|
||||
match = key
|
||||
}
|
||||
panic(fmt.Sprintf("unsupported edition: %v", ed))
|
||||
if match == EditionUnknown {
|
||||
panic(fmt.Sprintf("unsupported edition: %v", ed))
|
||||
}
|
||||
return defaultsCache[match]
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ func (e PlaceholderEnum) Options() protoreflect.ProtoMessage { return des
|
|||
func (e PlaceholderEnum) Values() protoreflect.EnumValueDescriptors { return emptyEnumValues }
|
||||
func (e PlaceholderEnum) ReservedNames() protoreflect.Names { return emptyNames }
|
||||
func (e PlaceholderEnum) ReservedRanges() protoreflect.EnumRanges { return emptyEnumRanges }
|
||||
func (e PlaceholderEnum) IsClosed() bool { return false }
|
||||
func (e PlaceholderEnum) ProtoType(protoreflect.EnumDescriptor) { return }
|
||||
func (e PlaceholderEnum) ProtoInternal(pragma.DoNotImplement) { return }
|
||||
|
||||
|
|
|
@ -167,6 +167,7 @@ func aberrantLoadEnumDesc(t reflect.Type) protoreflect.EnumDescriptor {
|
|||
ed := &filedesc.Enum{L2: new(filedesc.EnumL2)}
|
||||
ed.L0.FullName = AberrantDeriveFullName(t) // e.g., github_com.user.repo.MyEnum
|
||||
ed.L0.ParentFile = filedesc.SurrogateProto3
|
||||
ed.L1.EditionFeatures = ed.L0.ParentFile.L1.EditionFeatures
|
||||
ed.L2.Values.List = append(ed.L2.Values.List, filedesc.EnumValue{})
|
||||
|
||||
// TODO: Use the presence of a UnmarshalJSON method to determine proto2?
|
||||
|
|
|
@ -118,7 +118,7 @@ func (xi *ExtensionInfo) initFromLegacy() {
|
|||
xd.L1.Number = protoreflect.FieldNumber(xi.Field)
|
||||
xd.L1.Cardinality = fd.L1.Cardinality
|
||||
xd.L1.Kind = fd.L1.Kind
|
||||
xd.L2.IsPacked = fd.L1.IsPacked
|
||||
xd.L1.EditionFeatures = fd.L1.EditionFeatures
|
||||
xd.L2.Default = fd.L1.Default
|
||||
xd.L1.Extendee = Export{}.MessageDescriptorOf(xi.ExtendedType)
|
||||
xd.L2.Enum = ed
|
||||
|
|
|
@ -204,6 +204,7 @@ func aberrantLoadMessageDescReentrant(t reflect.Type, name protoreflect.FullName
|
|||
}
|
||||
}
|
||||
|
||||
md.L1.EditionFeatures = md.L0.ParentFile.L1.EditionFeatures
|
||||
// Obtain a list of oneof wrapper types.
|
||||
var oneofWrappers []reflect.Type
|
||||
methods := make([]reflect.Method, 0, 2)
|
||||
|
@ -250,6 +251,7 @@ func aberrantLoadMessageDescReentrant(t reflect.Type, name protoreflect.FullName
|
|||
od := &md.L2.Oneofs.List[n]
|
||||
od.L0.FullName = md.FullName().Append(protoreflect.Name(tag))
|
||||
od.L0.ParentFile = md.L0.ParentFile
|
||||
od.L1.EditionFeatures = md.L1.EditionFeatures
|
||||
od.L0.Parent = md
|
||||
od.L0.Index = n
|
||||
|
||||
|
@ -260,6 +262,7 @@ func aberrantLoadMessageDescReentrant(t reflect.Type, name protoreflect.FullName
|
|||
aberrantAppendField(md, f.Type, tag, "", "")
|
||||
fd := &md.L2.Fields.List[len(md.L2.Fields.List)-1]
|
||||
fd.L1.ContainingOneof = od
|
||||
fd.L1.EditionFeatures = od.L1.EditionFeatures
|
||||
od.L1.Fields.List = append(od.L1.Fields.List, fd)
|
||||
}
|
||||
}
|
||||
|
@ -307,14 +310,14 @@ func aberrantAppendField(md *filedesc.Message, goType reflect.Type, tag, tagKey,
|
|||
fd.L0.Parent = md
|
||||
fd.L0.Index = n
|
||||
|
||||
if fd.L1.IsWeak || fd.L1.HasPacked {
|
||||
if fd.L1.IsWeak || fd.L1.EditionFeatures.IsPacked {
|
||||
fd.L1.Options = func() protoreflect.ProtoMessage {
|
||||
opts := descopts.Field.ProtoReflect().New()
|
||||
if fd.L1.IsWeak {
|
||||
opts.Set(opts.Descriptor().Fields().ByName("weak"), protoreflect.ValueOfBool(true))
|
||||
}
|
||||
if fd.L1.HasPacked {
|
||||
opts.Set(opts.Descriptor().Fields().ByName("packed"), protoreflect.ValueOfBool(fd.L1.IsPacked))
|
||||
if fd.L1.EditionFeatures.IsPacked {
|
||||
opts.Set(opts.Descriptor().Fields().ByName("packed"), protoreflect.ValueOfBool(fd.L1.EditionFeatures.IsPacked))
|
||||
}
|
||||
return opts.Interface()
|
||||
}
|
||||
|
@ -344,6 +347,7 @@ func aberrantAppendField(md *filedesc.Message, goType reflect.Type, tag, tagKey,
|
|||
md2.L0.ParentFile = md.L0.ParentFile
|
||||
md2.L0.Parent = md
|
||||
md2.L0.Index = n
|
||||
md2.L1.EditionFeatures = md.L1.EditionFeatures
|
||||
|
||||
md2.L1.IsMapEntry = true
|
||||
md2.L2.Options = func() protoreflect.ProtoMessage {
|
||||
|
|
|
@ -247,11 +247,10 @@ func (m *extensionMap) Range(f func(protoreflect.FieldDescriptor, protoreflect.V
|
|||
}
|
||||
}
|
||||
}
|
||||
func (m *extensionMap) Has(xt protoreflect.ExtensionType) (ok bool) {
|
||||
func (m *extensionMap) Has(xd protoreflect.ExtensionTypeDescriptor) (ok bool) {
|
||||
if m == nil {
|
||||
return false
|
||||
}
|
||||
xd := xt.TypeDescriptor()
|
||||
x, ok := (*m)[int32(xd.Number())]
|
||||
if !ok {
|
||||
return false
|
||||
|
@ -261,25 +260,22 @@ func (m *extensionMap) Has(xt protoreflect.ExtensionType) (ok bool) {
|
|||
return x.Value().List().Len() > 0
|
||||
case xd.IsMap():
|
||||
return x.Value().Map().Len() > 0
|
||||
case xd.Message() != nil:
|
||||
return x.Value().Message().IsValid()
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (m *extensionMap) Clear(xt protoreflect.ExtensionType) {
|
||||
delete(*m, int32(xt.TypeDescriptor().Number()))
|
||||
func (m *extensionMap) Clear(xd protoreflect.ExtensionTypeDescriptor) {
|
||||
delete(*m, int32(xd.Number()))
|
||||
}
|
||||
func (m *extensionMap) Get(xt protoreflect.ExtensionType) protoreflect.Value {
|
||||
xd := xt.TypeDescriptor()
|
||||
func (m *extensionMap) Get(xd protoreflect.ExtensionTypeDescriptor) protoreflect.Value {
|
||||
if m != nil {
|
||||
if x, ok := (*m)[int32(xd.Number())]; ok {
|
||||
return x.Value()
|
||||
}
|
||||
}
|
||||
return xt.Zero()
|
||||
return xd.Type().Zero()
|
||||
}
|
||||
func (m *extensionMap) Set(xt protoreflect.ExtensionType, v protoreflect.Value) {
|
||||
xd := xt.TypeDescriptor()
|
||||
func (m *extensionMap) Set(xd protoreflect.ExtensionTypeDescriptor, v protoreflect.Value) {
|
||||
xt := xd.Type()
|
||||
isValid := true
|
||||
switch {
|
||||
case !xt.IsValidValue(v):
|
||||
|
@ -292,7 +288,7 @@ func (m *extensionMap) Set(xt protoreflect.ExtensionType, v protoreflect.Value)
|
|||
isValid = v.Message().IsValid()
|
||||
}
|
||||
if !isValid {
|
||||
panic(fmt.Sprintf("%v: assigning invalid value", xt.TypeDescriptor().FullName()))
|
||||
panic(fmt.Sprintf("%v: assigning invalid value", xd.FullName()))
|
||||
}
|
||||
|
||||
if *m == nil {
|
||||
|
@ -302,16 +298,15 @@ func (m *extensionMap) Set(xt protoreflect.ExtensionType, v protoreflect.Value)
|
|||
x.Set(xt, v)
|
||||
(*m)[int32(xd.Number())] = x
|
||||
}
|
||||
func (m *extensionMap) Mutable(xt protoreflect.ExtensionType) protoreflect.Value {
|
||||
xd := xt.TypeDescriptor()
|
||||
func (m *extensionMap) Mutable(xd protoreflect.ExtensionTypeDescriptor) protoreflect.Value {
|
||||
if xd.Kind() != protoreflect.MessageKind && xd.Kind() != protoreflect.GroupKind && !xd.IsList() && !xd.IsMap() {
|
||||
panic("invalid Mutable on field with non-composite type")
|
||||
}
|
||||
if x, ok := (*m)[int32(xd.Number())]; ok {
|
||||
return x.Value()
|
||||
}
|
||||
v := xt.New()
|
||||
m.Set(xt, v)
|
||||
v := xd.Type().New()
|
||||
m.Set(xd, v)
|
||||
return v
|
||||
}
|
||||
|
||||
|
@ -428,7 +423,7 @@ func (m *messageIfaceWrapper) protoUnwrap() interface{} {
|
|||
|
||||
// checkField verifies that the provided field descriptor is valid.
|
||||
// Exactly one of the returned values is populated.
|
||||
func (mi *MessageInfo) checkField(fd protoreflect.FieldDescriptor) (*fieldInfo, protoreflect.ExtensionType) {
|
||||
func (mi *MessageInfo) checkField(fd protoreflect.FieldDescriptor) (*fieldInfo, protoreflect.ExtensionTypeDescriptor) {
|
||||
var fi *fieldInfo
|
||||
if n := fd.Number(); 0 < n && int(n) < len(mi.denseFields) {
|
||||
fi = mi.denseFields[n]
|
||||
|
@ -457,7 +452,7 @@ func (mi *MessageInfo) checkField(fd protoreflect.FieldDescriptor) (*fieldInfo,
|
|||
if !ok {
|
||||
panic(fmt.Sprintf("extension %v does not implement protoreflect.ExtensionTypeDescriptor", fd.FullName()))
|
||||
}
|
||||
return nil, xtd.Type()
|
||||
return nil, xtd
|
||||
}
|
||||
panic(fmt.Sprintf("field %v is invalid", fd.FullName()))
|
||||
}
|
||||
|
|
|
@ -27,8 +27,9 @@ func (m *messageState) protoUnwrap() interface{} {
|
|||
return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem())
|
||||
}
|
||||
func (m *messageState) ProtoMethods() *protoiface.Methods {
|
||||
m.messageInfo().init()
|
||||
return &m.messageInfo().methods
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
return &mi.methods
|
||||
}
|
||||
|
||||
// ProtoMessageInfo is a pseudo-internal API for allowing the v1 code
|
||||
|
@ -41,8 +42,9 @@ func (m *messageState) ProtoMessageInfo() *MessageInfo {
|
|||
}
|
||||
|
||||
func (m *messageState) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
|
||||
m.messageInfo().init()
|
||||
for _, ri := range m.messageInfo().rangeInfos {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
for _, ri := range mi.rangeInfos {
|
||||
switch ri := ri.(type) {
|
||||
case *fieldInfo:
|
||||
if ri.has(m.pointer()) {
|
||||
|
@ -52,77 +54,86 @@ func (m *messageState) Range(f func(protoreflect.FieldDescriptor, protoreflect.V
|
|||
}
|
||||
case *oneofInfo:
|
||||
if n := ri.which(m.pointer()); n > 0 {
|
||||
fi := m.messageInfo().fields[n]
|
||||
fi := mi.fields[n]
|
||||
if !f(fi.fieldDesc, fi.get(m.pointer())) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m.messageInfo().extensionMap(m.pointer()).Range(f)
|
||||
mi.extensionMap(m.pointer()).Range(f)
|
||||
}
|
||||
func (m *messageState) Has(fd protoreflect.FieldDescriptor) bool {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.has(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Has(xt)
|
||||
return mi.extensionMap(m.pointer()).Has(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageState) Clear(fd protoreflect.FieldDescriptor) {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
fi.clear(m.pointer())
|
||||
} else {
|
||||
m.messageInfo().extensionMap(m.pointer()).Clear(xt)
|
||||
mi.extensionMap(m.pointer()).Clear(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageState) Get(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.get(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Get(xt)
|
||||
return mi.extensionMap(m.pointer()).Get(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageState) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
fi.set(m.pointer(), v)
|
||||
} else {
|
||||
m.messageInfo().extensionMap(m.pointer()).Set(xt, v)
|
||||
mi.extensionMap(m.pointer()).Set(xd, v)
|
||||
}
|
||||
}
|
||||
func (m *messageState) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.mutable(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Mutable(xt)
|
||||
return mi.extensionMap(m.pointer()).Mutable(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageState) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.newField()
|
||||
} else {
|
||||
return xt.New()
|
||||
return xd.Type().New()
|
||||
}
|
||||
}
|
||||
func (m *messageState) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||
m.messageInfo().init()
|
||||
if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if oi := mi.oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
|
||||
return od.Fields().ByNumber(oi.which(m.pointer()))
|
||||
}
|
||||
panic("invalid oneof descriptor " + string(od.FullName()) + " for message " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m *messageState) GetUnknown() protoreflect.RawFields {
|
||||
m.messageInfo().init()
|
||||
return m.messageInfo().getUnknown(m.pointer())
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
return mi.getUnknown(m.pointer())
|
||||
}
|
||||
func (m *messageState) SetUnknown(b protoreflect.RawFields) {
|
||||
m.messageInfo().init()
|
||||
m.messageInfo().setUnknown(m.pointer(), b)
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
mi.setUnknown(m.pointer(), b)
|
||||
}
|
||||
func (m *messageState) IsValid() bool {
|
||||
return !m.pointer().IsNil()
|
||||
|
@ -147,8 +158,9 @@ func (m *messageReflectWrapper) protoUnwrap() interface{} {
|
|||
return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem())
|
||||
}
|
||||
func (m *messageReflectWrapper) ProtoMethods() *protoiface.Methods {
|
||||
m.messageInfo().init()
|
||||
return &m.messageInfo().methods
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
return &mi.methods
|
||||
}
|
||||
|
||||
// ProtoMessageInfo is a pseudo-internal API for allowing the v1 code
|
||||
|
@ -161,8 +173,9 @@ func (m *messageReflectWrapper) ProtoMessageInfo() *MessageInfo {
|
|||
}
|
||||
|
||||
func (m *messageReflectWrapper) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
|
||||
m.messageInfo().init()
|
||||
for _, ri := range m.messageInfo().rangeInfos {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
for _, ri := range mi.rangeInfos {
|
||||
switch ri := ri.(type) {
|
||||
case *fieldInfo:
|
||||
if ri.has(m.pointer()) {
|
||||
|
@ -172,77 +185,86 @@ func (m *messageReflectWrapper) Range(f func(protoreflect.FieldDescriptor, proto
|
|||
}
|
||||
case *oneofInfo:
|
||||
if n := ri.which(m.pointer()); n > 0 {
|
||||
fi := m.messageInfo().fields[n]
|
||||
fi := mi.fields[n]
|
||||
if !f(fi.fieldDesc, fi.get(m.pointer())) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m.messageInfo().extensionMap(m.pointer()).Range(f)
|
||||
mi.extensionMap(m.pointer()).Range(f)
|
||||
}
|
||||
func (m *messageReflectWrapper) Has(fd protoreflect.FieldDescriptor) bool {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.has(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Has(xt)
|
||||
return mi.extensionMap(m.pointer()).Has(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) Clear(fd protoreflect.FieldDescriptor) {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
fi.clear(m.pointer())
|
||||
} else {
|
||||
m.messageInfo().extensionMap(m.pointer()).Clear(xt)
|
||||
mi.extensionMap(m.pointer()).Clear(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) Get(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.get(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Get(xt)
|
||||
return mi.extensionMap(m.pointer()).Get(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
fi.set(m.pointer(), v)
|
||||
} else {
|
||||
m.messageInfo().extensionMap(m.pointer()).Set(xt, v)
|
||||
mi.extensionMap(m.pointer()).Set(xd, v)
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.mutable(m.pointer())
|
||||
} else {
|
||||
return m.messageInfo().extensionMap(m.pointer()).Mutable(xt)
|
||||
return mi.extensionMap(m.pointer()).Mutable(xd)
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||
m.messageInfo().init()
|
||||
if fi, xt := m.messageInfo().checkField(fd); fi != nil {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if fi, xd := mi.checkField(fd); fi != nil {
|
||||
return fi.newField()
|
||||
} else {
|
||||
return xt.New()
|
||||
return xd.Type().New()
|
||||
}
|
||||
}
|
||||
func (m *messageReflectWrapper) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||
m.messageInfo().init()
|
||||
if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
if oi := mi.oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
|
||||
return od.Fields().ByNumber(oi.which(m.pointer()))
|
||||
}
|
||||
panic("invalid oneof descriptor " + string(od.FullName()) + " for message " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m *messageReflectWrapper) GetUnknown() protoreflect.RawFields {
|
||||
m.messageInfo().init()
|
||||
return m.messageInfo().getUnknown(m.pointer())
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
return mi.getUnknown(m.pointer())
|
||||
}
|
||||
func (m *messageReflectWrapper) SetUnknown(b protoreflect.RawFields) {
|
||||
m.messageInfo().init()
|
||||
m.messageInfo().setUnknown(m.pointer(), b)
|
||||
mi := m.messageInfo()
|
||||
mi.init()
|
||||
mi.setUnknown(m.pointer(), b)
|
||||
}
|
||||
func (m *messageReflectWrapper) IsValid() bool {
|
||||
return !m.pointer().IsNil()
|
||||
|
|
|
@ -53,7 +53,7 @@ const (
|
|||
Major = 1
|
||||
Minor = 33
|
||||
Patch = 0
|
||||
PreRelease = ""
|
||||
PreRelease = "devel"
|
||||
)
|
||||
|
||||
// String formats the version string for this module in semver format.
|
||||
|
|
|
@ -51,6 +51,8 @@ type UnmarshalOptions struct {
|
|||
|
||||
// Unmarshal parses the wire-format message in b and places the result in m.
|
||||
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
||||
//
|
||||
// See the [UnmarshalOptions] type if you need more control.
|
||||
func Unmarshal(b []byte, m Message) error {
|
||||
_, err := UnmarshalOptions{RecursionLimit: protowire.DefaultRecursionLimit}.unmarshal(b, m.ProtoReflect())
|
||||
return err
|
||||
|
|
|
@ -71,6 +71,10 @@ type MarshalOptions struct {
|
|||
}
|
||||
|
||||
// Marshal returns the wire-format encoding of m.
|
||||
//
|
||||
// This is the most common entry point for encoding a Protobuf message.
|
||||
//
|
||||
// See the [MarshalOptions] type if you need more control.
|
||||
func Marshal(m Message) ([]byte, error) {
|
||||
// Treat nil message interface as an empty message; nothing to output.
|
||||
if m == nil {
|
||||
|
@ -116,6 +120,9 @@ func emptyBytesForMessage(m Message) []byte {
|
|||
|
||||
// MarshalAppend appends the wire-format encoding of m to b,
|
||||
// returning the result.
|
||||
//
|
||||
// This is a less common entry point than [Marshal], which is only needed if you
|
||||
// need to supply your own buffers for performance reasons.
|
||||
func (o MarshalOptions) MarshalAppend(b []byte, m Message) ([]byte, error) {
|
||||
// Treat nil message interface as an empty message; nothing to append.
|
||||
if m == nil {
|
||||
|
|
|
@ -11,18 +11,21 @@ import (
|
|||
// HasExtension reports whether an extension field is populated.
|
||||
// It returns false if m is invalid or if xt does not extend m.
|
||||
func HasExtension(m Message, xt protoreflect.ExtensionType) bool {
|
||||
// Treat nil message interface as an empty message; no populated fields.
|
||||
if m == nil {
|
||||
// Treat nil message interface or descriptor as an empty message; no populated
|
||||
// fields.
|
||||
if m == nil || xt == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// As a special-case, we reports invalid or mismatching descriptors
|
||||
// as always not being populated (since they aren't).
|
||||
if xt == nil || m.ProtoReflect().Descriptor() != xt.TypeDescriptor().ContainingMessage() {
|
||||
mr := m.ProtoReflect()
|
||||
xd := xt.TypeDescriptor()
|
||||
if mr.Descriptor() != xd.ContainingMessage() {
|
||||
return false
|
||||
}
|
||||
|
||||
return m.ProtoReflect().Has(xt.TypeDescriptor())
|
||||
return mr.Has(xd)
|
||||
}
|
||||
|
||||
// ClearExtension clears an extension field such that subsequent
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
package protodesc
|
||||
|
||||
import (
|
||||
"google.golang.org/protobuf/internal/editionssupport"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/internal/filedesc"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
|
@ -91,15 +92,17 @@ func (o FileOptions) New(fd *descriptorpb.FileDescriptorProto, r Resolver) (prot
|
|||
switch fd.GetSyntax() {
|
||||
case "proto2", "":
|
||||
f.L1.Syntax = protoreflect.Proto2
|
||||
f.L1.Edition = filedesc.EditionProto2
|
||||
case "proto3":
|
||||
f.L1.Syntax = protoreflect.Proto3
|
||||
f.L1.Edition = filedesc.EditionProto3
|
||||
case "editions":
|
||||
f.L1.Syntax = protoreflect.Editions
|
||||
f.L1.Edition = fromEditionProto(fd.GetEdition())
|
||||
default:
|
||||
return nil, errors.New("invalid syntax: %q", fd.GetSyntax())
|
||||
}
|
||||
if f.L1.Syntax == protoreflect.Editions && (fd.GetEdition() < SupportedEditionsMinimum || fd.GetEdition() > SupportedEditionsMaximum) {
|
||||
if f.L1.Syntax == protoreflect.Editions && (fd.GetEdition() < editionssupport.Minimum || fd.GetEdition() > editionssupport.Maximum) {
|
||||
return nil, errors.New("use of edition %v not yet supported by the Go Protobuf runtime", fd.GetEdition())
|
||||
}
|
||||
f.L1.Path = fd.GetName()
|
||||
|
@ -114,9 +117,7 @@ func (o FileOptions) New(fd *descriptorpb.FileDescriptorProto, r Resolver) (prot
|
|||
opts = proto.Clone(opts).(*descriptorpb.FileOptions)
|
||||
f.L2.Options = func() protoreflect.ProtoMessage { return opts }
|
||||
}
|
||||
if f.L1.Syntax == protoreflect.Editions {
|
||||
initFileDescFromFeatureSet(f, fd.GetOptions().GetFeatures())
|
||||
}
|
||||
initFileDescFromFeatureSet(f, fd.GetOptions().GetFeatures())
|
||||
|
||||
f.L2.Imports = make(filedesc.FileImports, len(fd.GetDependency()))
|
||||
for _, i := range fd.GetPublicDependency() {
|
||||
|
@ -219,10 +220,10 @@ func (o FileOptions) New(fd *descriptorpb.FileDescriptorProto, r Resolver) (prot
|
|||
if err := validateEnumDeclarations(f.L1.Enums.List, fd.GetEnumType()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := validateMessageDeclarations(f.L1.Messages.List, fd.GetMessageType()); err != nil {
|
||||
if err := validateMessageDeclarations(f, f.L1.Messages.List, fd.GetMessageType()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := validateExtensionDeclarations(f.L1.Extensions.List, fd.GetExtension()); err != nil {
|
||||
if err := validateExtensionDeclarations(f, f.L1.Extensions.List, fd.GetExtension()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
@ -69,9 +69,7 @@ func (r descsByName) initMessagesDeclarations(mds []*descriptorpb.DescriptorProt
|
|||
if m.L0, err = r.makeBase(m, parent, md.GetName(), i, sb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if m.Base.L0.ParentFile.Syntax() == protoreflect.Editions {
|
||||
m.L1.EditionFeatures = mergeEditionFeatures(parent, md.GetOptions().GetFeatures())
|
||||
}
|
||||
m.L1.EditionFeatures = mergeEditionFeatures(parent, md.GetOptions().GetFeatures())
|
||||
if opts := md.GetOptions(); opts != nil {
|
||||
opts = proto.Clone(opts).(*descriptorpb.MessageOptions)
|
||||
m.L2.Options = func() protoreflect.ProtoMessage { return opts }
|
||||
|
@ -146,13 +144,15 @@ func (r descsByName) initFieldsFromDescriptorProto(fds []*descriptorpb.FieldDesc
|
|||
if f.L0, err = r.makeBase(f, parent, fd.GetName(), i, sb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
f.L1.EditionFeatures = mergeEditionFeatures(parent, fd.GetOptions().GetFeatures())
|
||||
f.L1.IsProto3Optional = fd.GetProto3Optional()
|
||||
if opts := fd.GetOptions(); opts != nil {
|
||||
opts = proto.Clone(opts).(*descriptorpb.FieldOptions)
|
||||
f.L1.Options = func() protoreflect.ProtoMessage { return opts }
|
||||
f.L1.IsWeak = opts.GetWeak()
|
||||
f.L1.HasPacked = opts.Packed != nil
|
||||
f.L1.IsPacked = opts.GetPacked()
|
||||
if opts.Packed != nil {
|
||||
f.L1.EditionFeatures.IsPacked = opts.GetPacked()
|
||||
}
|
||||
}
|
||||
f.L1.Number = protoreflect.FieldNumber(fd.GetNumber())
|
||||
f.L1.Cardinality = protoreflect.Cardinality(fd.GetLabel())
|
||||
|
@ -163,32 +163,12 @@ func (r descsByName) initFieldsFromDescriptorProto(fds []*descriptorpb.FieldDesc
|
|||
f.L1.StringName.InitJSON(fd.GetJsonName())
|
||||
}
|
||||
|
||||
if f.Base.L0.ParentFile.Syntax() == protoreflect.Editions {
|
||||
f.L1.EditionFeatures = mergeEditionFeatures(parent, fd.GetOptions().GetFeatures())
|
||||
if f.L1.EditionFeatures.IsLegacyRequired {
|
||||
f.L1.Cardinality = protoreflect.Required
|
||||
}
|
||||
|
||||
if f.L1.EditionFeatures.IsLegacyRequired {
|
||||
f.L1.Cardinality = protoreflect.Required
|
||||
}
|
||||
// We reuse the existing field because the old option `[packed =
|
||||
// true]` is mutually exclusive with the editions feature.
|
||||
if canBePacked(fd) {
|
||||
f.L1.HasPacked = true
|
||||
f.L1.IsPacked = f.L1.EditionFeatures.IsPacked
|
||||
}
|
||||
|
||||
// We pretend this option is always explicitly set because the only
|
||||
// use of HasEnforceUTF8 is to determine whether to use EnforceUTF8
|
||||
// or to return the appropriate default.
|
||||
// When using editions we either parse the option or resolve the
|
||||
// appropriate default here (instead of later when this option is
|
||||
// requested from the descriptor).
|
||||
// In proto2/proto3 syntax HasEnforceUTF8 might be false.
|
||||
f.L1.HasEnforceUTF8 = true
|
||||
f.L1.EnforceUTF8 = f.L1.EditionFeatures.IsUTF8Validated
|
||||
|
||||
if f.L1.Kind == protoreflect.MessageKind && f.L1.EditionFeatures.IsDelimitedEncoded {
|
||||
f.L1.Kind = protoreflect.GroupKind
|
||||
}
|
||||
if f.L1.Kind == protoreflect.MessageKind && f.L1.EditionFeatures.IsDelimitedEncoded {
|
||||
f.L1.Kind = protoreflect.GroupKind
|
||||
}
|
||||
}
|
||||
return fs, nil
|
||||
|
@ -201,12 +181,10 @@ func (r descsByName) initOneofsFromDescriptorProto(ods []*descriptorpb.OneofDesc
|
|||
if o.L0, err = r.makeBase(o, parent, od.GetName(), i, sb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
o.L1.EditionFeatures = mergeEditionFeatures(parent, od.GetOptions().GetFeatures())
|
||||
if opts := od.GetOptions(); opts != nil {
|
||||
opts = proto.Clone(opts).(*descriptorpb.OneofOptions)
|
||||
o.L1.Options = func() protoreflect.ProtoMessage { return opts }
|
||||
if parent.Syntax() == protoreflect.Editions {
|
||||
o.L1.EditionFeatures = mergeEditionFeatures(parent, opts.GetFeatures())
|
||||
}
|
||||
}
|
||||
}
|
||||
return os, nil
|
||||
|
@ -223,7 +201,9 @@ func (r descsByName) initExtensionDeclarations(xds []*descriptorpb.FieldDescript
|
|||
if opts := xd.GetOptions(); opts != nil {
|
||||
opts = proto.Clone(opts).(*descriptorpb.FieldOptions)
|
||||
x.L2.Options = func() protoreflect.ProtoMessage { return opts }
|
||||
x.L2.IsPacked = opts.GetPacked()
|
||||
if opts.Packed != nil {
|
||||
x.L1.EditionFeatures.IsPacked = opts.GetPacked()
|
||||
}
|
||||
}
|
||||
x.L1.Number = protoreflect.FieldNumber(xd.GetNumber())
|
||||
x.L1.Cardinality = protoreflect.Cardinality(xd.GetLabel())
|
||||
|
|
|
@ -45,11 +45,11 @@ func validateEnumDeclarations(es []filedesc.Enum, eds []*descriptorpb.EnumDescri
|
|||
if allowAlias && !foundAlias {
|
||||
return errors.New("enum %q allows aliases, but none were found", e.FullName())
|
||||
}
|
||||
if e.Syntax() == protoreflect.Proto3 {
|
||||
if !e.IsClosed() {
|
||||
if v := e.Values().Get(0); v.Number() != 0 {
|
||||
return errors.New("enum %q using proto3 semantics must have zero number for the first value", v.FullName())
|
||||
return errors.New("enum %q using open semantics must have zero number for the first value", v.FullName())
|
||||
}
|
||||
// Verify that value names in proto3 do not conflict if the
|
||||
// Verify that value names in open enums do not conflict if the
|
||||
// case-insensitive prefix is removed.
|
||||
// See protoc v3.8.0: src/google/protobuf/descriptor.cc:4991-5055
|
||||
names := map[string]protoreflect.EnumValueDescriptor{}
|
||||
|
@ -58,7 +58,7 @@ func validateEnumDeclarations(es []filedesc.Enum, eds []*descriptorpb.EnumDescri
|
|||
v1 := e.Values().Get(i)
|
||||
s := strs.EnumValueName(strs.TrimEnumPrefix(string(v1.Name()), prefix))
|
||||
if v2, ok := names[s]; ok && v1.Number() != v2.Number() {
|
||||
return errors.New("enum %q using proto3 semantics has conflict: %q with %q", e.FullName(), v1.Name(), v2.Name())
|
||||
return errors.New("enum %q using open semantics has conflict: %q with %q", e.FullName(), v1.Name(), v2.Name())
|
||||
}
|
||||
names[s] = v1
|
||||
}
|
||||
|
@ -80,7 +80,9 @@ func validateEnumDeclarations(es []filedesc.Enum, eds []*descriptorpb.EnumDescri
|
|||
return nil
|
||||
}
|
||||
|
||||
func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.DescriptorProto) error {
|
||||
func validateMessageDeclarations(file *filedesc.File, ms []filedesc.Message, mds []*descriptorpb.DescriptorProto) error {
|
||||
// There are a few limited exceptions only for proto3
|
||||
isProto3 := file.L1.Edition == fromEditionProto(descriptorpb.Edition_EDITION_PROTO3)
|
||||
for i, md := range mds {
|
||||
m := &ms[i]
|
||||
|
||||
|
@ -107,10 +109,10 @@ func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.Desc
|
|||
if isMessageSet && !flags.ProtoLegacy {
|
||||
return errors.New("message %q is a MessageSet, which is a legacy proto1 feature that is no longer supported", m.FullName())
|
||||
}
|
||||
if isMessageSet && (m.Syntax() == protoreflect.Proto3 || m.Fields().Len() > 0 || m.ExtensionRanges().Len() == 0) {
|
||||
if isMessageSet && (isProto3 || m.Fields().Len() > 0 || m.ExtensionRanges().Len() == 0) {
|
||||
return errors.New("message %q is an invalid proto1 MessageSet", m.FullName())
|
||||
}
|
||||
if m.Syntax() == protoreflect.Proto3 {
|
||||
if isProto3 {
|
||||
if m.ExtensionRanges().Len() > 0 {
|
||||
return errors.New("message %q using proto3 semantics cannot have extension ranges", m.FullName())
|
||||
}
|
||||
|
@ -149,7 +151,7 @@ func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.Desc
|
|||
return errors.New("message field %q may not have extendee: %q", f.FullName(), fd.GetExtendee())
|
||||
}
|
||||
if f.L1.IsProto3Optional {
|
||||
if f.Syntax() != protoreflect.Proto3 {
|
||||
if !isProto3 {
|
||||
return errors.New("message field %q under proto3 optional semantics must be specified in the proto3 syntax", f.FullName())
|
||||
}
|
||||
if f.Cardinality() != protoreflect.Optional {
|
||||
|
@ -162,26 +164,29 @@ func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.Desc
|
|||
if f.IsWeak() && !flags.ProtoLegacy {
|
||||
return errors.New("message field %q is a weak field, which is a legacy proto1 feature that is no longer supported", f.FullName())
|
||||
}
|
||||
if f.IsWeak() && (f.Syntax() != protoreflect.Proto2 || !isOptionalMessage(f) || f.ContainingOneof() != nil) {
|
||||
if f.IsWeak() && (!f.HasPresence() || !isOptionalMessage(f) || f.ContainingOneof() != nil) {
|
||||
return errors.New("message field %q may only be weak for an optional message", f.FullName())
|
||||
}
|
||||
if f.IsPacked() && !isPackable(f) {
|
||||
return errors.New("message field %q is not packable", f.FullName())
|
||||
}
|
||||
if err := checkValidGroup(f); err != nil {
|
||||
if err := checkValidGroup(file, f); err != nil {
|
||||
return errors.New("message field %q is an invalid group: %v", f.FullName(), err)
|
||||
}
|
||||
if err := checkValidMap(f); err != nil {
|
||||
return errors.New("message field %q is an invalid map: %v", f.FullName(), err)
|
||||
}
|
||||
if f.Syntax() == protoreflect.Proto3 {
|
||||
if isProto3 {
|
||||
if f.Cardinality() == protoreflect.Required {
|
||||
return errors.New("message field %q using proto3 semantics cannot be required", f.FullName())
|
||||
}
|
||||
if f.Enum() != nil && !f.Enum().IsPlaceholder() && f.Enum().Syntax() != protoreflect.Proto3 {
|
||||
return errors.New("message field %q using proto3 semantics may only depend on a proto3 enum", f.FullName())
|
||||
if f.Enum() != nil && !f.Enum().IsPlaceholder() && f.Enum().IsClosed() {
|
||||
return errors.New("message field %q using proto3 semantics may only depend on open enums", f.FullName())
|
||||
}
|
||||
}
|
||||
if f.Cardinality() == protoreflect.Optional && !f.HasPresence() && f.Enum() != nil && !f.Enum().IsPlaceholder() && f.Enum().IsClosed() {
|
||||
return errors.New("message field %q with implicit presence may only use open enums", f.FullName())
|
||||
}
|
||||
}
|
||||
seenSynthetic := false // synthetic oneofs for proto3 optional must come after real oneofs
|
||||
for j := range md.GetOneofDecl() {
|
||||
|
@ -215,17 +220,17 @@ func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.Desc
|
|||
if err := validateEnumDeclarations(m.L1.Enums.List, md.GetEnumType()); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateMessageDeclarations(m.L1.Messages.List, md.GetNestedType()); err != nil {
|
||||
if err := validateMessageDeclarations(file, m.L1.Messages.List, md.GetNestedType()); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateExtensionDeclarations(m.L1.Extensions.List, md.GetExtension()); err != nil {
|
||||
if err := validateExtensionDeclarations(file, m.L1.Extensions.List, md.GetExtension()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateExtensionDeclarations(xs []filedesc.Extension, xds []*descriptorpb.FieldDescriptorProto) error {
|
||||
func validateExtensionDeclarations(f *filedesc.File, xs []filedesc.Extension, xds []*descriptorpb.FieldDescriptorProto) error {
|
||||
for i, xd := range xds {
|
||||
x := &xs[i]
|
||||
// NOTE: Avoid using the IsValid method since extensions to MessageSet
|
||||
|
@ -267,13 +272,13 @@ func validateExtensionDeclarations(xs []filedesc.Extension, xds []*descriptorpb.
|
|||
if x.IsPacked() && !isPackable(x) {
|
||||
return errors.New("extension field %q is not packable", x.FullName())
|
||||
}
|
||||
if err := checkValidGroup(x); err != nil {
|
||||
if err := checkValidGroup(f, x); err != nil {
|
||||
return errors.New("extension field %q is an invalid group: %v", x.FullName(), err)
|
||||
}
|
||||
if md := x.Message(); md != nil && md.IsMapEntry() {
|
||||
return errors.New("extension field %q cannot be a map entry", x.FullName())
|
||||
}
|
||||
if x.Syntax() == protoreflect.Proto3 {
|
||||
if f.L1.Edition == fromEditionProto(descriptorpb.Edition_EDITION_PROTO3) {
|
||||
switch x.ContainingMessage().FullName() {
|
||||
case (*descriptorpb.FileOptions)(nil).ProtoReflect().Descriptor().FullName():
|
||||
case (*descriptorpb.EnumOptions)(nil).ProtoReflect().Descriptor().FullName():
|
||||
|
@ -309,21 +314,25 @@ func isPackable(fd protoreflect.FieldDescriptor) bool {
|
|||
|
||||
// checkValidGroup reports whether fd is a valid group according to the same
|
||||
// rules that protoc imposes.
|
||||
func checkValidGroup(fd protoreflect.FieldDescriptor) error {
|
||||
func checkValidGroup(f *filedesc.File, fd protoreflect.FieldDescriptor) error {
|
||||
md := fd.Message()
|
||||
switch {
|
||||
case fd.Kind() != protoreflect.GroupKind:
|
||||
return nil
|
||||
case fd.Syntax() == protoreflect.Proto3:
|
||||
case f.L1.Edition == fromEditionProto(descriptorpb.Edition_EDITION_PROTO3):
|
||||
return errors.New("invalid under proto3 semantics")
|
||||
case md == nil || md.IsPlaceholder():
|
||||
return errors.New("message must be resolvable")
|
||||
case fd.FullName().Parent() != md.FullName().Parent():
|
||||
return errors.New("message and field must be declared in the same scope")
|
||||
case !unicode.IsUpper(rune(md.Name()[0])):
|
||||
return errors.New("message name must start with an uppercase")
|
||||
case fd.Name() != protoreflect.Name(strings.ToLower(string(md.Name()))):
|
||||
return errors.New("field name must be lowercased form of the message name")
|
||||
}
|
||||
if f.L1.Edition < fromEditionProto(descriptorpb.Edition_EDITION_2023) {
|
||||
switch {
|
||||
case fd.FullName().Parent() != md.FullName().Parent():
|
||||
return errors.New("message and field must be declared in the same scope")
|
||||
case !unicode.IsUpper(rune(md.Name()[0])):
|
||||
return errors.New("message name must start with an uppercase")
|
||||
case fd.Name() != protoreflect.Name(strings.ToLower(string(md.Name()))):
|
||||
return errors.New("field name must be lowercased form of the message name")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -17,11 +17,6 @@ import (
|
|||
gofeaturespb "google.golang.org/protobuf/types/gofeaturespb"
|
||||
)
|
||||
|
||||
const (
|
||||
SupportedEditionsMinimum = descriptorpb.Edition_EDITION_PROTO2
|
||||
SupportedEditionsMaximum = descriptorpb.Edition_EDITION_2023
|
||||
)
|
||||
|
||||
var defaults = &descriptorpb.FeatureSetDefaults{}
|
||||
var defaultsCacheMu sync.Mutex
|
||||
var defaultsCache = make(map[filedesc.Edition]*descriptorpb.FeatureSet)
|
||||
|
|
|
@ -73,6 +73,16 @@ func ToFileDescriptorProto(file protoreflect.FileDescriptor) *descriptorpb.FileD
|
|||
if syntax := file.Syntax(); syntax != protoreflect.Proto2 && syntax.IsValid() {
|
||||
p.Syntax = proto.String(file.Syntax().String())
|
||||
}
|
||||
if file.Syntax() == protoreflect.Editions {
|
||||
desc := file
|
||||
if fileImportDesc, ok := file.(protoreflect.FileImport); ok {
|
||||
desc = fileImportDesc.FileDescriptor
|
||||
}
|
||||
|
||||
if editionsInterface, ok := desc.(interface{ Edition() int32 }); ok {
|
||||
p.Edition = descriptorpb.Edition(editionsInterface.Edition()).Enum()
|
||||
}
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
|
@ -153,6 +163,18 @@ func ToFieldDescriptorProto(field protoreflect.FieldDescriptor) *descriptorpb.Fi
|
|||
if field.Syntax() == protoreflect.Proto3 && field.HasOptionalKeyword() {
|
||||
p.Proto3Optional = proto.Bool(true)
|
||||
}
|
||||
if field.Syntax() == protoreflect.Editions {
|
||||
// Editions have no group keyword, this type is only set so that downstream users continue
|
||||
// treating this as delimited encoding.
|
||||
if p.GetType() == descriptorpb.FieldDescriptorProto_TYPE_GROUP {
|
||||
p.Type = descriptorpb.FieldDescriptorProto_TYPE_MESSAGE.Enum()
|
||||
}
|
||||
// Editions have no required keyword, this label is only set so that downstream users continue
|
||||
// treating it as required.
|
||||
if p.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REQUIRED {
|
||||
p.Label = descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL.Enum()
|
||||
}
|
||||
}
|
||||
if field.HasDefault() {
|
||||
def, err := defval.Marshal(field.Default(), field.DefaultEnumValue(), field.Kind(), defval.Descriptor)
|
||||
if err != nil && field.DefaultEnumValue() != nil {
|
||||
|
|
|
@ -161,7 +161,7 @@ const (
|
|||
// IsValid reports whether the syntax is valid.
|
||||
func (s Syntax) IsValid() bool {
|
||||
switch s {
|
||||
case Proto2, Proto3:
|
||||
case Proto2, Proto3, Editions:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
|
|
|
@ -544,6 +544,12 @@ type EnumDescriptor interface {
|
|||
// ReservedRanges is a list of reserved ranges of enum numbers.
|
||||
ReservedRanges() EnumRanges
|
||||
|
||||
// IsClosed reports whether this enum uses closed semantics.
|
||||
// See https://protobuf.dev/programming-guides/enum/#definitions.
|
||||
// Note: the Go protobuf implementation is not spec compliant and treats
|
||||
// all enums as open enums.
|
||||
IsClosed() bool
|
||||
|
||||
isEnumDescriptor
|
||||
}
|
||||
type isEnumDescriptor interface{ ProtoType(EnumDescriptor) }
|
||||
|
|
|
@ -506,12 +506,10 @@ github.com/zeromicro/go-zero/zrpc/resolver
|
|||
github.com/zeromicro/go-zero/zrpc/resolver/internal
|
||||
github.com/zeromicro/go-zero/zrpc/resolver/internal/kube
|
||||
github.com/zeromicro/go-zero/zrpc/resolver/internal/targets
|
||||
# gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240426095603-549fefd8bece
|
||||
# gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240619113316-c0186ee7b60c
|
||||
## explicit; go 1.21
|
||||
gitlink.org.cn/JointCloud/pcm-ac/hpcAC
|
||||
gitlink.org.cn/JointCloud/pcm-ac/hpcacclient
|
||||
# gitlink.org.cn/JointCloud/pcm-kubernetes v0.0.0-20240301071143-347480abff2c
|
||||
## explicit; go 1.21
|
||||
# gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240515005224-689bb339a9c9
|
||||
## explicit; go 1.21
|
||||
gitlink.org.cn/JointCloud/pcm-modelarts/client/imagesservice
|
||||
|
@ -817,7 +815,7 @@ google.golang.org/grpc/serviceconfig
|
|||
google.golang.org/grpc/stats
|
||||
google.golang.org/grpc/status
|
||||
google.golang.org/grpc/tap
|
||||
# google.golang.org/protobuf v1.33.0
|
||||
# google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002
|
||||
## explicit; go 1.17
|
||||
google.golang.org/protobuf/encoding/protodelim
|
||||
google.golang.org/protobuf/encoding/protojson
|
||||
|
@ -827,6 +825,7 @@ google.golang.org/protobuf/internal/descfmt
|
|||
google.golang.org/protobuf/internal/descopts
|
||||
google.golang.org/protobuf/internal/detrand
|
||||
google.golang.org/protobuf/internal/editiondefaults
|
||||
google.golang.org/protobuf/internal/editionssupport
|
||||
google.golang.org/protobuf/internal/encoding/defval
|
||||
google.golang.org/protobuf/internal/encoding/json
|
||||
google.golang.org/protobuf/internal/encoding/messageset
|
||||
|
|
Loading…
Reference in New Issue