feat: [NPM] define transport shim layer using gRPC (#1163)
This commit is contained in:
Родитель
6a47391365
Коммит
b6f04b6236
5
Makefile
5
Makefile
|
@ -425,6 +425,9 @@ $(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod
|
|||
|
||||
controller-gen: $(CONTROLLER_GEN) ## Build controller-gen
|
||||
|
||||
protoc:
|
||||
source ${REPO_ROOT}/scripts/install-protoc.sh
|
||||
|
||||
$(GOCOV): $(TOOLS_DIR)/go.mod
|
||||
cd $(TOOLS_DIR); go mod download; go build -tags=tools -o bin/gocov github.com/axw/gocov/gocov
|
||||
|
||||
|
@ -458,4 +461,4 @@ mockgen: $(MOCKGEN) ## Build mockgen
|
|||
clean-tools:
|
||||
rm -r build/tools/bin
|
||||
|
||||
tools: gocov gocov-xml go-junit-report golangci-lint gofumpt ## Build bins for build tools
|
||||
tools: gocov gocov-xml go-junit-report golangci-lint gofumpt protoc ## Build bins for build tools
|
||||
|
|
|
@ -9,5 +9,7 @@ import (
|
|||
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
|
||||
_ "github.com/jstemmer/go-junit-report"
|
||||
_ "mvdan.cc/gofumpt"
|
||||
_ "google.golang.org/protobuf/cmd/protoc-gen-go"
|
||||
_ "google.golang.org/grpc/cmd/protoc-gen-go-grpc"
|
||||
_ "sigs.k8s.io/controller-tools/cmd/controller-gen"
|
||||
)
|
||||
|
|
4
go.mod
4
go.mod
|
@ -94,12 +94,14 @@ require (
|
|||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
k8s.io/component-base v0.22.1 // indirect
|
||||
k8s.io/klog/v2 v2.9.0 // indirect
|
||||
k8s.io/klog/v2 v2.9.0
|
||||
k8s.io/kube-openapi v0.0.0-20211109043538-20434351676c // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/fatih/structs v1.1.0
|
||||
github.com/gofrs/uuid v3.3.0+incompatible // indirect
|
||||
github.com/jsternberg/zap-logfmt v1.2.0
|
||||
go.uber.org/zap v1.18.1
|
||||
)
|
||||
|
|
2
go.sum
2
go.sum
|
@ -295,6 +295,8 @@ github.com/evanphx/json-patch v4.11.0+incompatible h1:glyUF9yIYtMHzn8xaKw5rMhdWc
|
|||
github.com/evanphx/json-patch v4.11.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
|
||||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
||||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
|
||||
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
TARGET_DIRS = \
|
||||
./pkg/dataplane \
|
||||
./pkg/controlplane \
|
||||
./pkg/transport \
|
||||
./pkg/protos
|
||||
all: generate
|
||||
|
||||
generate:
|
||||
for dir in $(TARGET_DIRS); do \
|
||||
make -C $$dir $@; \
|
||||
done
|
||||
|
||||
.PHONY: all generate
|
|
@ -2,7 +2,7 @@
|
|||
//
|
||||
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: /mnt/c/Users/vamsi/Desktop/Microsoft_ws/azure-container-networking/npm/pkg/dataplane/types.go
|
||||
// Source: /home/nitishm/github/nitishm/azure-container-networking/npm/pkg/dataplane/types.go
|
||||
|
||||
// Package mocks is a generated GoMock package.
|
||||
package mocks
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
REPO_ROOT = $(shell git rev-parse --show-toplevel)
|
||||
PROTOC_INSTALL_PATH=$(HOME)/.local
|
||||
PROTOC_BIN=$(PROTOC_INSTALL_PATH)/bin/protoc
|
||||
|
||||
.PHONY: generate
|
||||
|
||||
generate: $(PROTOC_BIN) ## Generate mock clients
|
||||
$(PROTOC_BIN) --proto_path=. --go_out=. --go-grpc_out=. --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative transport.proto
|
|
@ -0,0 +1,491 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1
|
||||
// protoc v3.19.1
|
||||
// source: transport.proto
|
||||
|
||||
package protos
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
structpb "google.golang.org/protobuf/types/known/structpb"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type DatapathPodMetadata_APIVersion int32
|
||||
|
||||
const (
|
||||
DatapathPodMetadata_V1 DatapathPodMetadata_APIVersion = 0
|
||||
)
|
||||
|
||||
// Enum value maps for DatapathPodMetadata_APIVersion.
|
||||
var (
|
||||
DatapathPodMetadata_APIVersion_name = map[int32]string{
|
||||
0: "V1",
|
||||
}
|
||||
DatapathPodMetadata_APIVersion_value = map[string]int32{
|
||||
"V1": 0,
|
||||
}
|
||||
)
|
||||
|
||||
func (x DatapathPodMetadata_APIVersion) Enum() *DatapathPodMetadata_APIVersion {
|
||||
p := new(DatapathPodMetadata_APIVersion)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x DatapathPodMetadata_APIVersion) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (DatapathPodMetadata_APIVersion) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_transport_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (DatapathPodMetadata_APIVersion) Type() protoreflect.EnumType {
|
||||
return &file_transport_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x DatapathPodMetadata_APIVersion) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DatapathPodMetadata_APIVersion.Descriptor instead.
|
||||
func (DatapathPodMetadata_APIVersion) EnumDescriptor() ([]byte, []int) {
|
||||
return file_transport_proto_rawDescGZIP(), []int{0, 0}
|
||||
}
|
||||
|
||||
// The following events are supported:
|
||||
type Events_EventType int32
|
||||
|
||||
const (
|
||||
// Send a CREATE/UPDATE event to a datapath Pod
|
||||
Events_APPLY Events_EventType = 0
|
||||
// Send a DELETE event to a datapath Pod
|
||||
Events_REMOVE Events_EventType = 1
|
||||
)
|
||||
|
||||
// Enum value maps for Events_EventType.
|
||||
var (
|
||||
Events_EventType_name = map[int32]string{
|
||||
0: "APPLY",
|
||||
1: "REMOVE",
|
||||
}
|
||||
Events_EventType_value = map[string]int32{
|
||||
"APPLY": 0,
|
||||
"REMOVE": 1,
|
||||
}
|
||||
)
|
||||
|
||||
func (x Events_EventType) Enum() *Events_EventType {
|
||||
p := new(Events_EventType)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x Events_EventType) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (Events_EventType) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_transport_proto_enumTypes[1].Descriptor()
|
||||
}
|
||||
|
||||
func (Events_EventType) Type() protoreflect.EnumType {
|
||||
return &file_transport_proto_enumTypes[1]
|
||||
}
|
||||
|
||||
func (x Events_EventType) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Events_EventType.Descriptor instead.
|
||||
func (Events_EventType) EnumDescriptor() ([]byte, []int) {
|
||||
return file_transport_proto_rawDescGZIP(), []int{1, 0}
|
||||
}
|
||||
|
||||
// Supported objects are IPSet and NetworkPolicy objects.
|
||||
type Events_ObjectType int32
|
||||
|
||||
const (
|
||||
Events_IPSET Events_ObjectType = 0
|
||||
Events_POLICY Events_ObjectType = 1
|
||||
)
|
||||
|
||||
// Enum value maps for Events_ObjectType.
|
||||
var (
|
||||
Events_ObjectType_name = map[int32]string{
|
||||
0: "IPSET",
|
||||
1: "POLICY",
|
||||
}
|
||||
Events_ObjectType_value = map[string]int32{
|
||||
"IPSET": 0,
|
||||
"POLICY": 1,
|
||||
}
|
||||
)
|
||||
|
||||
func (x Events_ObjectType) Enum() *Events_ObjectType {
|
||||
p := new(Events_ObjectType)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x Events_ObjectType) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (Events_ObjectType) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_transport_proto_enumTypes[2].Descriptor()
|
||||
}
|
||||
|
||||
func (Events_ObjectType) Type() protoreflect.EnumType {
|
||||
return &file_transport_proto_enumTypes[2]
|
||||
}
|
||||
|
||||
func (x Events_ObjectType) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Events_ObjectType.Descriptor instead.
|
||||
func (Events_ObjectType) EnumDescriptor() ([]byte, []int) {
|
||||
return file_transport_proto_rawDescGZIP(), []int{1, 1}
|
||||
}
|
||||
|
||||
// DatapathPodMetadata is the metadata for a datapath pod
|
||||
type DatapathPodMetadata struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
PodName string `protobuf:"bytes,1,opt,name=pod_name,json=podName,proto3" json:"pod_name,omitempty"` // Daemonset Pod ID
|
||||
NodeName string `protobuf:"bytes,2,opt,name=node_name,json=nodeName,proto3" json:"node_name,omitempty"` // Node name
|
||||
ApiVersion DatapathPodMetadata_APIVersion `protobuf:"varint,3,opt,name=apiVersion,proto3,enum=protos.DatapathPodMetadata_APIVersion" json:"apiVersion,omitempty"` // Controlplane API version to support backwards compatibility
|
||||
}
|
||||
|
||||
func (x *DatapathPodMetadata) Reset() {
|
||||
*x = DatapathPodMetadata{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_transport_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *DatapathPodMetadata) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DatapathPodMetadata) ProtoMessage() {}
|
||||
|
||||
func (x *DatapathPodMetadata) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_transport_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DatapathPodMetadata.ProtoReflect.Descriptor instead.
|
||||
func (*DatapathPodMetadata) Descriptor() ([]byte, []int) {
|
||||
return file_transport_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *DatapathPodMetadata) GetPodName() string {
|
||||
if x != nil {
|
||||
return x.PodName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DatapathPodMetadata) GetNodeName() string {
|
||||
if x != nil {
|
||||
return x.NodeName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DatapathPodMetadata) GetApiVersion() DatapathPodMetadata_APIVersion {
|
||||
if x != nil {
|
||||
return x.ApiVersion
|
||||
}
|
||||
return DatapathPodMetadata_V1
|
||||
}
|
||||
|
||||
// Events defines the operation (event type) and object type being
|
||||
// streamed to the datapath client. A events message may carry one or
|
||||
// more Event objects.
|
||||
type Events struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Type Events_EventType `protobuf:"varint,1,opt,name=type,proto3,enum=protos.Events_EventType" json:"type,omitempty"`
|
||||
Object Events_ObjectType `protobuf:"varint,2,opt,name=object,proto3,enum=protos.Events_ObjectType" json:"object,omitempty"`
|
||||
// Payload can contain one or more Event objects.
|
||||
Event []*Event `protobuf:"bytes,3,rep,name=event,proto3" json:"event,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Events) Reset() {
|
||||
*x = Events{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_transport_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Events) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Events) ProtoMessage() {}
|
||||
|
||||
func (x *Events) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_transport_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Events.ProtoReflect.Descriptor instead.
|
||||
func (*Events) Descriptor() ([]byte, []int) {
|
||||
return file_transport_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *Events) GetType() Events_EventType {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return Events_APPLY
|
||||
}
|
||||
|
||||
func (x *Events) GetObject() Events_ObjectType {
|
||||
if x != nil {
|
||||
return x.Object
|
||||
}
|
||||
return Events_IPSET
|
||||
}
|
||||
|
||||
func (x *Events) GetEvent() []*Event {
|
||||
if x != nil {
|
||||
return x.Event
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Event is a generic object that can be Created,
|
||||
// Updated, Deleted by the controlplane.
|
||||
type Event struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Data can contain one or more instances of IPSet or NetworkPolicy
|
||||
// objects.
|
||||
Data []*structpb.Struct `protobuf:"bytes,3,rep,name=data,proto3" json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Event) Reset() {
|
||||
*x = Event{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_transport_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Event) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Event) ProtoMessage() {}
|
||||
|
||||
func (x *Event) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_transport_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Event.ProtoReflect.Descriptor instead.
|
||||
func (*Event) Descriptor() ([]byte, []int) {
|
||||
return file_transport_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Event) GetData() []*structpb.Struct {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_transport_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_transport_proto_rawDesc = []byte{
|
||||
0x0a, 0x0f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x12, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
||||
0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63,
|
||||
0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xab, 0x01, 0x0a, 0x13, 0x44, 0x61, 0x74, 0x61,
|
||||
0x70, 0x61, 0x74, 0x68, 0x50, 0x6f, 0x64, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12,
|
||||
0x19, 0x0a, 0x08, 0x70, 0x6f, 0x64, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x07, 0x70, 0x6f, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f,
|
||||
0x64, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e,
|
||||
0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x46, 0x0a, 0x0a, 0x61, 0x70, 0x69, 0x56, 0x65,
|
||||
0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x70, 0x61, 0x74, 0x68, 0x50, 0x6f, 0x64,
|
||||
0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x41, 0x50, 0x49, 0x56, 0x65, 0x72, 0x73,
|
||||
0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x61, 0x70, 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22,
|
||||
0x14, 0x0a, 0x0a, 0x41, 0x50, 0x49, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x06, 0x0a,
|
||||
0x02, 0x56, 0x31, 0x10, 0x00, 0x22, 0xd7, 0x01, 0x0a, 0x06, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73,
|
||||
0x12, 0x2c, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x45,
|
||||
0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x31,
|
||||
0x0a, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x19,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x2e, 0x4f,
|
||||
0x62, 0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x06, 0x6f, 0x62, 0x6a, 0x65, 0x63,
|
||||
0x74, 0x12, 0x23, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b,
|
||||
0x32, 0x0d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52,
|
||||
0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x22, 0x0a, 0x09, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x54,
|
||||
0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x50, 0x50, 0x4c, 0x59, 0x10, 0x00, 0x12, 0x0a,
|
||||
0x0a, 0x06, 0x52, 0x45, 0x4d, 0x4f, 0x56, 0x45, 0x10, 0x01, 0x22, 0x23, 0x0a, 0x0a, 0x4f, 0x62,
|
||||
0x6a, 0x65, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x49, 0x50, 0x53, 0x45,
|
||||
0x54, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x50, 0x4f, 0x4c, 0x49, 0x43, 0x59, 0x10, 0x01, 0x22,
|
||||
0x34, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x2b, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61,
|
||||
0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52,
|
||||
0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0x4b, 0x0a, 0x0f, 0x44, 0x61, 0x74, 0x61, 0x70, 0x6c, 0x61,
|
||||
0x6e, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x38, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x6e,
|
||||
0x65, 0x63, 0x74, 0x12, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x44, 0x61, 0x74,
|
||||
0x61, 0x70, 0x61, 0x74, 0x68, 0x50, 0x6f, 0x64, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61,
|
||||
0x1a, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73,
|
||||
0x30, 0x01, 0x42, 0x43, 0x5a, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
|
||||
0x2f, 0x41, 0x7a, 0x75, 0x72, 0x65, 0x2f, 0x61, 0x7a, 0x75, 0x72, 0x65, 0x2d, 0x63, 0x6f, 0x6e,
|
||||
0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x2d, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x69, 0x6e,
|
||||
0x67, 0x2f, 0x6e, 0x70, 0x6d, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73,
|
||||
0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_transport_proto_rawDescOnce sync.Once
|
||||
file_transport_proto_rawDescData = file_transport_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_transport_proto_rawDescGZIP() []byte {
|
||||
file_transport_proto_rawDescOnce.Do(func() {
|
||||
file_transport_proto_rawDescData = protoimpl.X.CompressGZIP(file_transport_proto_rawDescData)
|
||||
})
|
||||
return file_transport_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_transport_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
|
||||
var file_transport_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_transport_proto_goTypes = []interface{}{
|
||||
(DatapathPodMetadata_APIVersion)(0), // 0: protos.DatapathPodMetadata.APIVersion
|
||||
(Events_EventType)(0), // 1: protos.Events.EventType
|
||||
(Events_ObjectType)(0), // 2: protos.Events.ObjectType
|
||||
(*DatapathPodMetadata)(nil), // 3: protos.DatapathPodMetadata
|
||||
(*Events)(nil), // 4: protos.Events
|
||||
(*Event)(nil), // 5: protos.Event
|
||||
(*structpb.Struct)(nil), // 6: google.protobuf.Struct
|
||||
}
|
||||
var file_transport_proto_depIdxs = []int32{
|
||||
0, // 0: protos.DatapathPodMetadata.apiVersion:type_name -> protos.DatapathPodMetadata.APIVersion
|
||||
1, // 1: protos.Events.type:type_name -> protos.Events.EventType
|
||||
2, // 2: protos.Events.object:type_name -> protos.Events.ObjectType
|
||||
5, // 3: protos.Events.event:type_name -> protos.Event
|
||||
6, // 4: protos.Event.data:type_name -> google.protobuf.Struct
|
||||
3, // 5: protos.DataplaneEvents.Connect:input_type -> protos.DatapathPodMetadata
|
||||
4, // 6: protos.DataplaneEvents.Connect:output_type -> protos.Events
|
||||
6, // [6:7] is the sub-list for method output_type
|
||||
5, // [5:6] is the sub-list for method input_type
|
||||
5, // [5:5] is the sub-list for extension type_name
|
||||
5, // [5:5] is the sub-list for extension extendee
|
||||
0, // [0:5] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_transport_proto_init() }
|
||||
func file_transport_proto_init() {
|
||||
if File_transport_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_transport_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*DatapathPodMetadata); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_transport_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Events); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_transport_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Event); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_transport_proto_rawDesc,
|
||||
NumEnums: 3,
|
||||
NumMessages: 3,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_transport_proto_goTypes,
|
||||
DependencyIndexes: file_transport_proto_depIdxs,
|
||||
EnumInfos: file_transport_proto_enumTypes,
|
||||
MessageInfos: file_transport_proto_msgTypes,
|
||||
}.Build()
|
||||
File_transport_proto = out.File
|
||||
file_transport_proto_rawDesc = nil
|
||||
file_transport_proto_goTypes = nil
|
||||
file_transport_proto_depIdxs = nil
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
syntax = "proto3";
|
||||
package protos;
|
||||
option go_package = "github.com/Azure/azure-container-networking/npm/pkg/protos;protos";
|
||||
|
||||
import "google/protobuf/struct.proto";
|
||||
|
||||
// DataplaneEvents represents the Service RPC exposed by the gRPC server.
|
||||
service DataplaneEvents{
|
||||
rpc Connect(DatapathPodMetadata) returns (stream Events);
|
||||
}
|
||||
|
||||
// DatapathPodMetadata is the metadata for a datapath pod
|
||||
message DatapathPodMetadata {
|
||||
string pod_name = 1; // Daemonset Pod ID
|
||||
string node_name = 2; // Node name
|
||||
enum APIVersion {
|
||||
V1 = 0;
|
||||
}
|
||||
APIVersion apiVersion = 3; // Controlplane API version to support backwards compatibility
|
||||
}
|
||||
|
||||
// Events defines the operation (event type) and object type being
|
||||
// streamed to the datapath client. A events message may carry one or
|
||||
// more Event objects.
|
||||
message Events{
|
||||
EventType type = 1;
|
||||
// The following events are supported:
|
||||
enum EventType {
|
||||
// Send a CREATE/UPDATE event to a datapath Pod
|
||||
APPLY = 0;
|
||||
// Send a DELETE event to a datapath Pod
|
||||
REMOVE = 1;
|
||||
}
|
||||
|
||||
ObjectType object = 2;
|
||||
// Supported objects are IPSet and NetworkPolicy objects.
|
||||
enum ObjectType {
|
||||
IPSET = 0;
|
||||
POLICY = 1;
|
||||
}
|
||||
// Payload can contain one or more Event objects.
|
||||
repeated Event event = 3;
|
||||
}
|
||||
|
||||
// Event is a generic object that can be Created,
|
||||
// Updated, Deleted by the controlplane.
|
||||
message Event {
|
||||
// Data can contain one or more instances of IPSet or NetworkPolicy
|
||||
// objects.
|
||||
repeated google.protobuf.Struct data = 3;
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
|
||||
package protos
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// DataplaneEventsClient is the client API for DataplaneEvents 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.
|
||||
type DataplaneEventsClient interface {
|
||||
Connect(ctx context.Context, in *DatapathPodMetadata, opts ...grpc.CallOption) (DataplaneEvents_ConnectClient, error)
|
||||
}
|
||||
|
||||
type dataplaneEventsClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewDataplaneEventsClient(cc grpc.ClientConnInterface) DataplaneEventsClient {
|
||||
return &dataplaneEventsClient{cc}
|
||||
}
|
||||
|
||||
func (c *dataplaneEventsClient) Connect(ctx context.Context, in *DatapathPodMetadata, opts ...grpc.CallOption) (DataplaneEvents_ConnectClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &DataplaneEvents_ServiceDesc.Streams[0], "/protos.DataplaneEvents/Connect", opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &dataplaneEventsConnectClient{stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type DataplaneEvents_ConnectClient interface {
|
||||
Recv() (*Events, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
type dataplaneEventsConnectClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *dataplaneEventsConnectClient) Recv() (*Events, error) {
|
||||
m := new(Events)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// DataplaneEventsServer is the server API for DataplaneEvents service.
|
||||
// All implementations must embed UnimplementedDataplaneEventsServer
|
||||
// for forward compatibility
|
||||
type DataplaneEventsServer interface {
|
||||
Connect(*DatapathPodMetadata, DataplaneEvents_ConnectServer) error
|
||||
mustEmbedUnimplementedDataplaneEventsServer()
|
||||
}
|
||||
|
||||
// UnimplementedDataplaneEventsServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedDataplaneEventsServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedDataplaneEventsServer) Connect(*DatapathPodMetadata, DataplaneEvents_ConnectServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method Connect not implemented")
|
||||
}
|
||||
func (UnimplementedDataplaneEventsServer) mustEmbedUnimplementedDataplaneEventsServer() {}
|
||||
|
||||
// UnsafeDataplaneEventsServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to DataplaneEventsServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeDataplaneEventsServer interface {
|
||||
mustEmbedUnimplementedDataplaneEventsServer()
|
||||
}
|
||||
|
||||
func RegisterDataplaneEventsServer(s grpc.ServiceRegistrar, srv DataplaneEventsServer) {
|
||||
s.RegisterService(&DataplaneEvents_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _DataplaneEvents_Connect_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(DatapathPodMetadata)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(DataplaneEventsServer).Connect(m, &dataplaneEventsConnectServer{stream})
|
||||
}
|
||||
|
||||
type DataplaneEvents_ConnectServer interface {
|
||||
Send(*Events) error
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type dataplaneEventsConnectServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *dataplaneEventsConnectServer) Send(m *Events) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
// DataplaneEvents_ServiceDesc is the grpc.ServiceDesc for DataplaneEvents service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var DataplaneEvents_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "protos.DataplaneEvents",
|
||||
HandlerType: (*DataplaneEventsServer)(nil),
|
||||
Methods: []grpc.MethodDesc{},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "Connect",
|
||||
Handler: _DataplaneEvents_Connect_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "transport.proto",
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package transport
|
||||
|
||||
const (
|
||||
// concurrentInputRegistrations = 10
|
||||
grpcMaxConcurrentStreams = 100
|
||||
)
|
|
@ -0,0 +1,157 @@
|
|||
package transport
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/Azure/azure-container-networking/npm/pkg/protos"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
"google.golang.org/grpc/stats"
|
||||
"google.golang.org/protobuf/types/known/structpb"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
type Manager struct {
|
||||
ctx context.Context
|
||||
|
||||
// Server is the gRPC server
|
||||
Server protos.DataplaneEventsServer
|
||||
|
||||
// Watchdog is the watchdog for the gRPC server that implements the
|
||||
// gRPC stats handler interface
|
||||
Watchdog stats.Handler
|
||||
|
||||
// Registrations is a map of dataplane pod address to their associate connection stream
|
||||
Registrations map[string]clientStreamConnection
|
||||
|
||||
// port is the port the manager is listening on
|
||||
port int
|
||||
|
||||
// inCh is the input channel for the manager
|
||||
inCh chan interface{}
|
||||
|
||||
// regCh is the registration channel
|
||||
regCh chan clientStreamConnection
|
||||
|
||||
// deregCh is the deregistration channel
|
||||
deregCh chan deregistrationEvent
|
||||
|
||||
// errCh is the error channel
|
||||
errCh chan error
|
||||
}
|
||||
|
||||
// New creates a new transport manager
|
||||
func NewManager(ctx context.Context, port int) *Manager {
|
||||
// Create a registration channel
|
||||
regCh := make(chan clientStreamConnection, grpcMaxConcurrentStreams)
|
||||
|
||||
// Create a deregistration channel
|
||||
deregCh := make(chan deregistrationEvent, grpcMaxConcurrentStreams)
|
||||
|
||||
return &Manager{
|
||||
ctx: ctx,
|
||||
Server: NewServer(ctx, regCh),
|
||||
Watchdog: NewWatchdog(deregCh),
|
||||
Registrations: make(map[string]clientStreamConnection),
|
||||
port: port,
|
||||
inCh: make(chan interface{}),
|
||||
errCh: make(chan error),
|
||||
deregCh: deregCh,
|
||||
regCh: regCh,
|
||||
}
|
||||
}
|
||||
|
||||
// InputChannel returns the input channel for the manager
|
||||
func (m *Manager) InputChannel() chan interface{} {
|
||||
return m.inCh
|
||||
}
|
||||
|
||||
func (m *Manager) Start() error {
|
||||
klog.Info("Starting transport manager")
|
||||
if err := m.start(); err != nil {
|
||||
klog.Errorf("Failed to Start transport manager: %v", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Manager) start() error {
|
||||
if err := m.handle(); err != nil {
|
||||
return fmt.Errorf("failed to start transport manager handlers: %w", err)
|
||||
}
|
||||
|
||||
for {
|
||||
select {
|
||||
case client := <-m.regCh:
|
||||
klog.Infof("Registering remote client %s", client)
|
||||
m.Registrations[client.String()] = client
|
||||
case ev := <-m.deregCh:
|
||||
klog.Infof("Degregistering remote client %s", ev.remoteAddr)
|
||||
if v, ok := m.Registrations[ev.remoteAddr]; ok {
|
||||
if v.timestamp <= ev.timestamp {
|
||||
delete(m.Registrations, ev.remoteAddr)
|
||||
} else {
|
||||
klog.Info("Ignoring stale deregistration event")
|
||||
}
|
||||
}
|
||||
case msg := <-m.inCh:
|
||||
for _, client := range m.Registrations {
|
||||
if err := client.stream.SendMsg(&protos.Events{
|
||||
Type: *protos.Events_APPLY.Enum(),
|
||||
Object: *protos.Events_IPSET.Enum(),
|
||||
Event: []*protos.Event{
|
||||
{
|
||||
Data: []*structpb.Struct{
|
||||
msg.(*structpb.Struct),
|
||||
},
|
||||
},
|
||||
},
|
||||
}); err != nil {
|
||||
klog.Errorf("Failed to send message to client %s: %v", client, err)
|
||||
}
|
||||
}
|
||||
case <-m.ctx.Done():
|
||||
klog.Info("Stopping transport manager")
|
||||
return nil
|
||||
case err := <-m.errCh:
|
||||
klog.Errorf("Error in transport manager: %v", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Manager) handle() error {
|
||||
klog.Info("Starting transport manager listener")
|
||||
lis, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", m.port))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to handle server connections: %w", err)
|
||||
}
|
||||
|
||||
var opts []grpc.ServerOption = []grpc.ServerOption{
|
||||
grpc.MaxConcurrentStreams(grpcMaxConcurrentStreams),
|
||||
grpc.StatsHandler(m.Watchdog),
|
||||
}
|
||||
|
||||
server := grpc.NewServer(opts...)
|
||||
protos.RegisterDataplaneEventsServer(
|
||||
server,
|
||||
m.Server,
|
||||
)
|
||||
|
||||
// Register reflection service on gRPC server.
|
||||
// This is useful for debugging and testing with grpcurl and other CLI tools.
|
||||
reflection.Register(server)
|
||||
|
||||
klog.Info("Starting transport manager server")
|
||||
|
||||
// Start gRPC Server in background
|
||||
go func() {
|
||||
if err := server.Serve(lis); err != nil {
|
||||
m.errCh <- fmt.Errorf("failed to start gRPC server: %w", err)
|
||||
}
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package transport
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/Azure/azure-container-networking/npm/pkg/protos"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// DataplaneEventsClient is a client for the DataplaneEvents service
|
||||
type DataplaneEventsClient struct {
|
||||
protos.DataplaneEventsClient
|
||||
pod string
|
||||
node string
|
||||
serverAddr string
|
||||
}
|
||||
|
||||
func NewDataplaneEventsClient(ctx context.Context, pod, node, addr string) (*DataplaneEventsClient, error) {
|
||||
cc, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithBlock())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to dial %s: %w", addr, err)
|
||||
}
|
||||
|
||||
return &DataplaneEventsClient{
|
||||
DataplaneEventsClient: protos.NewDataplaneEventsClient(cc),
|
||||
pod: pod,
|
||||
node: node,
|
||||
serverAddr: addr,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *DataplaneEventsClient) Start(ctx context.Context) error {
|
||||
clientMetadata := &protos.DatapathPodMetadata{
|
||||
PodName: c.pod,
|
||||
NodeName: c.node,
|
||||
}
|
||||
|
||||
opts := []grpc.CallOption{}
|
||||
connectClient, err := c.Connect(ctx, clientMetadata, opts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to connect to dataplane events server: %w", err)
|
||||
}
|
||||
|
||||
return c.run(ctx, connectClient)
|
||||
}
|
||||
|
||||
func (c *DataplaneEventsClient) run(ctx context.Context, connectClient protos.DataplaneEvents_ConnectClient) error {
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return fmt.Errorf("context done: %w", ctx.Err())
|
||||
default:
|
||||
event, err := connectClient.Recv()
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
// TODO: REMOVE ME
|
||||
// This is for debugging purposes only
|
||||
fmt.Printf(
|
||||
"Received event type %s object type %s: \n",
|
||||
event.GetType(),
|
||||
event.GetObject(),
|
||||
)
|
||||
|
||||
for _, e := range event.GetEvent() {
|
||||
for _, d := range e.GetData() {
|
||||
eventAsMap := d.AsMap()
|
||||
fmt.Printf("%s: %s\n", eventAsMap["Type"], eventAsMap["Payload"])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package transport
|
||||
|
||||
import "errors"
|
||||
|
||||
// ErrNoPeer is returned when no peer was found in the gRPC context.
|
||||
var ErrNoPeer = errors.New("no peer found in gRPC context")
|
|
@ -0,0 +1,60 @@
|
|||
package transport
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/Azure/azure-container-networking/npm/pkg/protos"
|
||||
"google.golang.org/grpc/peer"
|
||||
)
|
||||
|
||||
// clientStreamConnection represents a client stream connection
|
||||
type clientStreamConnection struct {
|
||||
stream protos.DataplaneEvents_ConnectServer
|
||||
*protos.DatapathPodMetadata
|
||||
addr string
|
||||
timestamp int64
|
||||
}
|
||||
|
||||
// String returns the address of the client
|
||||
func (c clientStreamConnection) String() string {
|
||||
return c.addr
|
||||
}
|
||||
|
||||
// DataplaneEventsServer is the gRPC server for the DataplaneEvents service
|
||||
type DataplaneEventsServer struct {
|
||||
protos.UnimplementedDataplaneEventsServer
|
||||
ctx context.Context
|
||||
regCh chan<- clientStreamConnection
|
||||
}
|
||||
|
||||
// NewServer creates a new DataplaneEventsServer instance
|
||||
func NewServer(ctx context.Context, ch chan clientStreamConnection) *DataplaneEventsServer {
|
||||
return &DataplaneEventsServer{
|
||||
ctx: ctx,
|
||||
regCh: ch,
|
||||
}
|
||||
}
|
||||
|
||||
// Connect is called when a client connects to the server
|
||||
func (d *DataplaneEventsServer) Connect(m *protos.DatapathPodMetadata, stream protos.DataplaneEvents_ConnectServer) error {
|
||||
p, ok := peer.FromContext(stream.Context())
|
||||
if !ok {
|
||||
return ErrNoPeer
|
||||
}
|
||||
|
||||
conn := clientStreamConnection{
|
||||
DatapathPodMetadata: m,
|
||||
stream: stream,
|
||||
addr: p.Addr.String(),
|
||||
timestamp: time.Now().Unix(),
|
||||
}
|
||||
|
||||
// Add stream to the list of active streams
|
||||
d.regCh <- conn
|
||||
|
||||
// This should block until the client disconnects
|
||||
<-d.ctx.Done()
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/Azure/azure-container-networking/npm/pkg/transport"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
|
||||
sigs := make(chan os.Signal, 1)
|
||||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
go func() {
|
||||
<-sigs
|
||||
cancel()
|
||||
}()
|
||||
|
||||
c, err := transport.NewDataplaneEventsClient(ctx, "podname", "nodename", "127.0.0.1:8080")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := c.Start(ctx); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/Azure/azure-container-networking/npm/pkg/transport"
|
||||
"github.com/fatih/structs"
|
||||
"google.golang.org/protobuf/types/known/structpb"
|
||||
)
|
||||
|
||||
const (
|
||||
port = 8080
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
|
||||
sigs := make(chan os.Signal, 1)
|
||||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
go func() {
|
||||
<-sigs
|
||||
cancel()
|
||||
}()
|
||||
|
||||
m := transport.NewManager(ctx, port)
|
||||
|
||||
ch := m.InputChannel()
|
||||
|
||||
go func() {
|
||||
for _, d := range testData() {
|
||||
ch <- d
|
||||
//nolint:gomnd //ignore for test
|
||||
time.Sleep(time.Second * 5)
|
||||
}
|
||||
}()
|
||||
|
||||
if err := m.Start(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testData() []*structpb.Struct {
|
||||
var output []*structpb.Struct
|
||||
for i := 0; i < 10; i++ {
|
||||
v := struct {
|
||||
Type string
|
||||
Payload string
|
||||
}{
|
||||
Type: fmt.Sprintf("IPSET-%d", i),
|
||||
//nolint:gosec //ignore for test
|
||||
Payload: fmt.Sprintf("172.17.0.%d/%d", i, rand.Uint32()%32), //nolint:gomnd //ignore for test
|
||||
}
|
||||
|
||||
m := structs.Map(v)
|
||||
|
||||
data, _ := structpb.NewStruct(m)
|
||||
output = append(output, data)
|
||||
}
|
||||
return output
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package transport
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc/stats"
|
||||
)
|
||||
|
||||
// Defined type for context key
|
||||
type watchdogContextKey string
|
||||
|
||||
// String implements the Stringer interface
|
||||
func (c watchdogContextKey) String() string {
|
||||
return string(c)
|
||||
}
|
||||
|
||||
// contextRemoteAddrKey is the key used to store the remote address in the context
|
||||
var contextRemoteAddrKey = watchdogContextKey("remote-addr")
|
||||
|
||||
// deregistrationEvent is the type of event that is sent to the deregistration channel
|
||||
type deregistrationEvent struct {
|
||||
remoteAddr string
|
||||
timestamp int64
|
||||
}
|
||||
|
||||
// Watchdog is a stats handler that watches for connection and RPC events.
|
||||
// It implements the gRPC stats.Handler interface.
|
||||
type Watchdog struct {
|
||||
// deregCh is used by the Watchdog to signal the Watchdog to deregister a remote address/client
|
||||
deregCh chan<- deregistrationEvent
|
||||
}
|
||||
|
||||
// NewWatchdog creates a new Watchdog instance
|
||||
func NewWatchdog(deregCh chan<- deregistrationEvent) stats.Handler {
|
||||
return &Watchdog{
|
||||
deregCh: deregCh,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Watchdog) TagRPC(ctx context.Context, _ *stats.RPCTagInfo) context.Context {
|
||||
return ctx
|
||||
}
|
||||
|
||||
func (h *Watchdog) HandleRPC(ctx context.Context, _ stats.RPCStats) {
|
||||
_ = ctx
|
||||
}
|
||||
|
||||
func (h *Watchdog) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context {
|
||||
// Add the remote address to the context so that we can use it during a connection end event
|
||||
return context.WithValue(ctx, contextRemoteAddrKey, info.RemoteAddr.String())
|
||||
}
|
||||
|
||||
// HandleConn processes the Conn stats.
|
||||
func (h *Watchdog) HandleConn(c context.Context, s stats.ConnStats) {
|
||||
if _, ok := s.(*stats.ConnEnd); ok {
|
||||
// Watch for connection end events
|
||||
remoteAddr := c.Value(contextRemoteAddrKey).(string)
|
||||
h.deregCh <- deregistrationEvent{
|
||||
remoteAddr: remoteAddr,
|
||||
timestamp: time.Now().Unix(),
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
PROTOBUFF_VERSION=3.19.1
|
||||
PB_REL="https://github.com/protocolbuffers/protobuf/releases"
|
||||
PROTOC_ZIP_NAME=protoc-${PROTOBUFF_VERSION}-linux-x86_64.zip
|
||||
PROTOC_INSTALL_PATH=$HOME/.local
|
||||
|
||||
# install unzip on linux if not installed
|
||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||
if ! type "unzip" > /dev/null; then
|
||||
sudo apt-get install unzip
|
||||
fi
|
||||
fi
|
||||
|
||||
# install protoc and protoc-gen-go
|
||||
if [ ! -f ${PROTOC_INSTALL_PATH}/bin/protoc ]; then
|
||||
echo "Installing protobuf compiler"
|
||||
curl -LO ${PB_REL}/download/v${PROTOBUFF_VERSION}/${PROTOC_ZIP_NAME}
|
||||
echo "Unzipping protoc"
|
||||
unzip -o ${PROTOC_ZIP_NAME} -d ${PROTOC_INSTALL_PATH}
|
||||
chmod +x ${PROTOC_INSTALL_PATH}/bin/protoc
|
||||
export PATH=${PROTOC_INSTALL_PATH}/bin:$PATH
|
||||
echo "Removing protoc zip"
|
||||
rm ${PROTOC_ZIP_NAME}
|
||||
else
|
||||
echo "Protobuf compiler already installed at ${PROTOC_INSTALL_PATH}/bin/protoc"
|
||||
echo "Add protoc to your PATH if you want to use it from anywhere else using the following command:"
|
||||
export PATH=${PROTOC_INSTALL_PATH}/bin:$PATH
|
||||
fi
|
||||
|
||||
# install protoc-gen-go
|
||||
if [ ! -f ${GOPATH}/bin/protoc-gen-go ]; then
|
||||
echo "Installing protoc-gen-go"
|
||||
go install github.com/golang/protobuf/protoc-gen-go@v1.26
|
||||
else
|
||||
echo "protoc-gen-go already installed at ${GOPATH}/bin/protoc-gen-go"
|
||||
fi
|
||||
|
||||
# install protoc-gen-go-grpc
|
||||
if [ ! -f ${GOPATH}/bin/protoc-gen-go-grpc ]; then
|
||||
echo "Installing protoc-gen-go-grpc"
|
||||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
|
||||
else
|
||||
echo "protoc-gen-go-grpc already installed at ${GOPATH}/bin/protoc-gen-go-grpc"
|
||||
fi
|
|
@ -0,0 +1,23 @@
|
|||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
|
@ -0,0 +1,13 @@
|
|||
language: go
|
||||
go:
|
||||
- 1.7.x
|
||||
- 1.8.x
|
||||
- 1.9.x
|
||||
- tip
|
||||
sudo: false
|
||||
before_install:
|
||||
- go get github.com/axw/gocov/gocov
|
||||
- go get github.com/mattn/goveralls
|
||||
- if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
|
||||
script:
|
||||
- $HOME/gopath/bin/goveralls -service=travis-ci
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Fatih Arslan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,163 @@
|
|||
# Structs [![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/fatih/structs) [![Build Status](http://img.shields.io/travis/fatih/structs.svg?style=flat-square)](https://travis-ci.org/fatih/structs) [![Coverage Status](http://img.shields.io/coveralls/fatih/structs.svg?style=flat-square)](https://coveralls.io/r/fatih/structs)
|
||||
|
||||
Structs contains various utilities to work with Go (Golang) structs. It was
|
||||
initially used by me to convert a struct into a `map[string]interface{}`. With
|
||||
time I've added other utilities for structs. It's basically a high level
|
||||
package based on primitives from the reflect package. Feel free to add new
|
||||
functions or improve the existing code.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
go get github.com/fatih/structs
|
||||
```
|
||||
|
||||
## Usage and Examples
|
||||
|
||||
Just like the standard lib `strings`, `bytes` and co packages, `structs` has
|
||||
many global functions to manipulate or organize your struct data. Lets define
|
||||
and declare a struct:
|
||||
|
||||
```go
|
||||
type Server struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
ID int
|
||||
Enabled bool
|
||||
users []string // not exported
|
||||
http.Server // embedded
|
||||
}
|
||||
|
||||
server := &Server{
|
||||
Name: "gopher",
|
||||
ID: 123456,
|
||||
Enabled: true,
|
||||
}
|
||||
```
|
||||
|
||||
```go
|
||||
// Convert a struct to a map[string]interface{}
|
||||
// => {"Name":"gopher", "ID":123456, "Enabled":true}
|
||||
m := structs.Map(server)
|
||||
|
||||
// Convert the values of a struct to a []interface{}
|
||||
// => ["gopher", 123456, true]
|
||||
v := structs.Values(server)
|
||||
|
||||
// Convert the names of a struct to a []string
|
||||
// (see "Names methods" for more info about fields)
|
||||
n := structs.Names(server)
|
||||
|
||||
// Convert the values of a struct to a []*Field
|
||||
// (see "Field methods" for more info about fields)
|
||||
f := structs.Fields(server)
|
||||
|
||||
// Return the struct name => "Server"
|
||||
n := structs.Name(server)
|
||||
|
||||
// Check if any field of a struct is initialized or not.
|
||||
h := structs.HasZero(server)
|
||||
|
||||
// Check if all fields of a struct is initialized or not.
|
||||
z := structs.IsZero(server)
|
||||
|
||||
// Check if server is a struct or a pointer to struct
|
||||
i := structs.IsStruct(server)
|
||||
```
|
||||
|
||||
### Struct methods
|
||||
|
||||
The structs functions can be also used as independent methods by creating a new
|
||||
`*structs.Struct`. This is handy if you want to have more control over the
|
||||
structs (such as retrieving a single Field).
|
||||
|
||||
```go
|
||||
// Create a new struct type:
|
||||
s := structs.New(server)
|
||||
|
||||
m := s.Map() // Get a map[string]interface{}
|
||||
v := s.Values() // Get a []interface{}
|
||||
f := s.Fields() // Get a []*Field
|
||||
n := s.Names() // Get a []string
|
||||
f := s.Field(name) // Get a *Field based on the given field name
|
||||
f, ok := s.FieldOk(name) // Get a *Field based on the given field name
|
||||
n := s.Name() // Get the struct name
|
||||
h := s.HasZero() // Check if any field is uninitialized
|
||||
z := s.IsZero() // Check if all fields are uninitialized
|
||||
```
|
||||
|
||||
### Field methods
|
||||
|
||||
We can easily examine a single Field for more detail. Below you can see how we
|
||||
get and interact with various field methods:
|
||||
|
||||
|
||||
```go
|
||||
s := structs.New(server)
|
||||
|
||||
// Get the Field struct for the "Name" field
|
||||
name := s.Field("Name")
|
||||
|
||||
// Get the underlying value, value => "gopher"
|
||||
value := name.Value().(string)
|
||||
|
||||
// Set the field's value
|
||||
name.Set("another gopher")
|
||||
|
||||
// Get the field's kind, kind => "string"
|
||||
name.Kind()
|
||||
|
||||
// Check if the field is exported or not
|
||||
if name.IsExported() {
|
||||
fmt.Println("Name field is exported")
|
||||
}
|
||||
|
||||
// Check if the value is a zero value, such as "" for string, 0 for int
|
||||
if !name.IsZero() {
|
||||
fmt.Println("Name is initialized")
|
||||
}
|
||||
|
||||
// Check if the field is an anonymous (embedded) field
|
||||
if !name.IsEmbedded() {
|
||||
fmt.Println("Name is not an embedded field")
|
||||
}
|
||||
|
||||
// Get the Field's tag value for tag name "json", tag value => "name,omitempty"
|
||||
tagValue := name.Tag("json")
|
||||
```
|
||||
|
||||
Nested structs are supported too:
|
||||
|
||||
```go
|
||||
addrField := s.Field("Server").Field("Addr")
|
||||
|
||||
// Get the value for addr
|
||||
a := addrField.Value().(string)
|
||||
|
||||
// Or get all fields
|
||||
httpServer := s.Field("Server").Fields()
|
||||
```
|
||||
|
||||
We can also get a slice of Fields from the Struct type to iterate over all
|
||||
fields. This is handy if you wish to examine all fields:
|
||||
|
||||
```go
|
||||
s := structs.New(server)
|
||||
|
||||
for _, f := range s.Fields() {
|
||||
fmt.Printf("field name: %+v\n", f.Name())
|
||||
|
||||
if f.IsExported() {
|
||||
fmt.Printf("value : %+v\n", f.Value())
|
||||
fmt.Printf("is zero : %+v\n", f.IsZero())
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Credits
|
||||
|
||||
* [Fatih Arslan](https://github.com/fatih)
|
||||
* [Cihangir Savas](https://github.com/cihangir)
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT) - see LICENSE.md for more details
|
|
@ -0,0 +1,141 @@
|
|||
package structs
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
var (
|
||||
errNotExported = errors.New("field is not exported")
|
||||
errNotSettable = errors.New("field is not settable")
|
||||
)
|
||||
|
||||
// Field represents a single struct field that encapsulates high level
|
||||
// functions around the field.
|
||||
type Field struct {
|
||||
value reflect.Value
|
||||
field reflect.StructField
|
||||
defaultTag string
|
||||
}
|
||||
|
||||
// Tag returns the value associated with key in the tag string. If there is no
|
||||
// such key in the tag, Tag returns the empty string.
|
||||
func (f *Field) Tag(key string) string {
|
||||
return f.field.Tag.Get(key)
|
||||
}
|
||||
|
||||
// Value returns the underlying value of the field. It panics if the field
|
||||
// is not exported.
|
||||
func (f *Field) Value() interface{} {
|
||||
return f.value.Interface()
|
||||
}
|
||||
|
||||
// IsEmbedded returns true if the given field is an anonymous field (embedded)
|
||||
func (f *Field) IsEmbedded() bool {
|
||||
return f.field.Anonymous
|
||||
}
|
||||
|
||||
// IsExported returns true if the given field is exported.
|
||||
func (f *Field) IsExported() bool {
|
||||
return f.field.PkgPath == ""
|
||||
}
|
||||
|
||||
// IsZero returns true if the given field is not initialized (has a zero value).
|
||||
// It panics if the field is not exported.
|
||||
func (f *Field) IsZero() bool {
|
||||
zero := reflect.Zero(f.value.Type()).Interface()
|
||||
current := f.Value()
|
||||
|
||||
return reflect.DeepEqual(current, zero)
|
||||
}
|
||||
|
||||
// Name returns the name of the given field
|
||||
func (f *Field) Name() string {
|
||||
return f.field.Name
|
||||
}
|
||||
|
||||
// Kind returns the fields kind, such as "string", "map", "bool", etc ..
|
||||
func (f *Field) Kind() reflect.Kind {
|
||||
return f.value.Kind()
|
||||
}
|
||||
|
||||
// Set sets the field to given value v. It returns an error if the field is not
|
||||
// settable (not addressable or not exported) or if the given value's type
|
||||
// doesn't match the fields type.
|
||||
func (f *Field) Set(val interface{}) error {
|
||||
// we can't set unexported fields, so be sure this field is exported
|
||||
if !f.IsExported() {
|
||||
return errNotExported
|
||||
}
|
||||
|
||||
// do we get here? not sure...
|
||||
if !f.value.CanSet() {
|
||||
return errNotSettable
|
||||
}
|
||||
|
||||
given := reflect.ValueOf(val)
|
||||
|
||||
if f.value.Kind() != given.Kind() {
|
||||
return fmt.Errorf("wrong kind. got: %s want: %s", given.Kind(), f.value.Kind())
|
||||
}
|
||||
|
||||
f.value.Set(given)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Zero sets the field to its zero value. It returns an error if the field is not
|
||||
// settable (not addressable or not exported).
|
||||
func (f *Field) Zero() error {
|
||||
zero := reflect.Zero(f.value.Type()).Interface()
|
||||
return f.Set(zero)
|
||||
}
|
||||
|
||||
// Fields returns a slice of Fields. This is particular handy to get the fields
|
||||
// of a nested struct . A struct tag with the content of "-" ignores the
|
||||
// checking of that particular field. Example:
|
||||
//
|
||||
// // Field is ignored by this package.
|
||||
// Field *http.Request `structs:"-"`
|
||||
//
|
||||
// It panics if field is not exported or if field's kind is not struct
|
||||
func (f *Field) Fields() []*Field {
|
||||
return getFields(f.value, f.defaultTag)
|
||||
}
|
||||
|
||||
// Field returns the field from a nested struct. It panics if the nested struct
|
||||
// is not exported or if the field was not found.
|
||||
func (f *Field) Field(name string) *Field {
|
||||
field, ok := f.FieldOk(name)
|
||||
if !ok {
|
||||
panic("field not found")
|
||||
}
|
||||
|
||||
return field
|
||||
}
|
||||
|
||||
// FieldOk returns the field from a nested struct. The boolean returns whether
|
||||
// the field was found (true) or not (false).
|
||||
func (f *Field) FieldOk(name string) (*Field, bool) {
|
||||
value := &f.value
|
||||
// value must be settable so we need to make sure it holds the address of the
|
||||
// variable and not a copy, so we can pass the pointer to strctVal instead of a
|
||||
// copy (which is not assigned to any variable, hence not settable).
|
||||
// see "https://blog.golang.org/laws-of-reflection#TOC_8."
|
||||
if f.value.Kind() != reflect.Ptr {
|
||||
a := f.value.Addr()
|
||||
value = &a
|
||||
}
|
||||
v := strctVal(value.Interface())
|
||||
t := v.Type()
|
||||
|
||||
field, ok := t.FieldByName(name)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
return &Field{
|
||||
field: field,
|
||||
value: v.FieldByName(name),
|
||||
}, true
|
||||
}
|
|
@ -0,0 +1,584 @@
|
|||
// Package structs contains various utilities functions to work with structs.
|
||||
package structs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"reflect"
|
||||
)
|
||||
|
||||
var (
|
||||
// DefaultTagName is the default tag name for struct fields which provides
|
||||
// a more granular to tweak certain structs. Lookup the necessary functions
|
||||
// for more info.
|
||||
DefaultTagName = "structs" // struct's field default tag name
|
||||
)
|
||||
|
||||
// Struct encapsulates a struct type to provide several high level functions
|
||||
// around the struct.
|
||||
type Struct struct {
|
||||
raw interface{}
|
||||
value reflect.Value
|
||||
TagName string
|
||||
}
|
||||
|
||||
// New returns a new *Struct with the struct s. It panics if the s's kind is
|
||||
// not struct.
|
||||
func New(s interface{}) *Struct {
|
||||
return &Struct{
|
||||
raw: s,
|
||||
value: strctVal(s),
|
||||
TagName: DefaultTagName,
|
||||
}
|
||||
}
|
||||
|
||||
// Map converts the given struct to a map[string]interface{}, where the keys
|
||||
// of the map are the field names and the values of the map the associated
|
||||
// values of the fields. The default key string is the struct field name but
|
||||
// can be changed in the struct field's tag value. The "structs" key in the
|
||||
// struct's field tag value is the key name. Example:
|
||||
//
|
||||
// // Field appears in map as key "myName".
|
||||
// Name string `structs:"myName"`
|
||||
//
|
||||
// A tag value with the content of "-" ignores that particular field. Example:
|
||||
//
|
||||
// // Field is ignored by this package.
|
||||
// Field bool `structs:"-"`
|
||||
//
|
||||
// A tag value with the content of "string" uses the stringer to get the value. Example:
|
||||
//
|
||||
// // The value will be output of Animal's String() func.
|
||||
// // Map will panic if Animal does not implement String().
|
||||
// Field *Animal `structs:"field,string"`
|
||||
//
|
||||
// A tag value with the option of "flatten" used in a struct field is to flatten its fields
|
||||
// in the output map. Example:
|
||||
//
|
||||
// // The FieldStruct's fields will be flattened into the output map.
|
||||
// FieldStruct time.Time `structs:",flatten"`
|
||||
//
|
||||
// A tag value with the option of "omitnested" stops iterating further if the type
|
||||
// is a struct. Example:
|
||||
//
|
||||
// // Field is not processed further by this package.
|
||||
// Field time.Time `structs:"myName,omitnested"`
|
||||
// Field *http.Request `structs:",omitnested"`
|
||||
//
|
||||
// A tag value with the option of "omitempty" ignores that particular field if
|
||||
// the field value is empty. Example:
|
||||
//
|
||||
// // Field appears in map as key "myName", but the field is
|
||||
// // skipped if empty.
|
||||
// Field string `structs:"myName,omitempty"`
|
||||
//
|
||||
// // Field appears in map as key "Field" (the default), but
|
||||
// // the field is skipped if empty.
|
||||
// Field string `structs:",omitempty"`
|
||||
//
|
||||
// Note that only exported fields of a struct can be accessed, non exported
|
||||
// fields will be neglected.
|
||||
func (s *Struct) Map() map[string]interface{} {
|
||||
out := make(map[string]interface{})
|
||||
s.FillMap(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// FillMap is the same as Map. Instead of returning the output, it fills the
|
||||
// given map.
|
||||
func (s *Struct) FillMap(out map[string]interface{}) {
|
||||
if out == nil {
|
||||
return
|
||||
}
|
||||
|
||||
fields := s.structFields()
|
||||
|
||||
for _, field := range fields {
|
||||
name := field.Name
|
||||
val := s.value.FieldByName(name)
|
||||
isSubStruct := false
|
||||
var finalVal interface{}
|
||||
|
||||
tagName, tagOpts := parseTag(field.Tag.Get(s.TagName))
|
||||
if tagName != "" {
|
||||
name = tagName
|
||||
}
|
||||
|
||||
// if the value is a zero value and the field is marked as omitempty do
|
||||
// not include
|
||||
if tagOpts.Has("omitempty") {
|
||||
zero := reflect.Zero(val.Type()).Interface()
|
||||
current := val.Interface()
|
||||
|
||||
if reflect.DeepEqual(current, zero) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if !tagOpts.Has("omitnested") {
|
||||
finalVal = s.nested(val)
|
||||
|
||||
v := reflect.ValueOf(val.Interface())
|
||||
if v.Kind() == reflect.Ptr {
|
||||
v = v.Elem()
|
||||
}
|
||||
|
||||
switch v.Kind() {
|
||||
case reflect.Map, reflect.Struct:
|
||||
isSubStruct = true
|
||||
}
|
||||
} else {
|
||||
finalVal = val.Interface()
|
||||
}
|
||||
|
||||
if tagOpts.Has("string") {
|
||||
s, ok := val.Interface().(fmt.Stringer)
|
||||
if ok {
|
||||
out[name] = s.String()
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if isSubStruct && (tagOpts.Has("flatten")) {
|
||||
for k := range finalVal.(map[string]interface{}) {
|
||||
out[k] = finalVal.(map[string]interface{})[k]
|
||||
}
|
||||
} else {
|
||||
out[name] = finalVal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Values converts the given s struct's field values to a []interface{}. A
|
||||
// struct tag with the content of "-" ignores the that particular field.
|
||||
// Example:
|
||||
//
|
||||
// // Field is ignored by this package.
|
||||
// Field int `structs:"-"`
|
||||
//
|
||||
// A value with the option of "omitnested" stops iterating further if the type
|
||||
// is a struct. Example:
|
||||
//
|
||||
// // Fields is not processed further by this package.
|
||||
// Field time.Time `structs:",omitnested"`
|
||||
// Field *http.Request `structs:",omitnested"`
|
||||
//
|
||||
// A tag value with the option of "omitempty" ignores that particular field and
|
||||
// is not added to the values if the field value is empty. Example:
|
||||
//
|
||||
// // Field is skipped if empty
|
||||
// Field string `structs:",omitempty"`
|
||||
//
|
||||
// Note that only exported fields of a struct can be accessed, non exported
|
||||
// fields will be neglected.
|
||||
func (s *Struct) Values() []interface{} {
|
||||
fields := s.structFields()
|
||||
|
||||
var t []interface{}
|
||||
|
||||
for _, field := range fields {
|
||||
val := s.value.FieldByName(field.Name)
|
||||
|
||||
_, tagOpts := parseTag(field.Tag.Get(s.TagName))
|
||||
|
||||
// if the value is a zero value and the field is marked as omitempty do
|
||||
// not include
|
||||
if tagOpts.Has("omitempty") {
|
||||
zero := reflect.Zero(val.Type()).Interface()
|
||||
current := val.Interface()
|
||||
|
||||
if reflect.DeepEqual(current, zero) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if tagOpts.Has("string") {
|
||||
s, ok := val.Interface().(fmt.Stringer)
|
||||
if ok {
|
||||
t = append(t, s.String())
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if IsStruct(val.Interface()) && !tagOpts.Has("omitnested") {
|
||||
// look out for embedded structs, and convert them to a
|
||||
// []interface{} to be added to the final values slice
|
||||
t = append(t, Values(val.Interface())...)
|
||||
} else {
|
||||
t = append(t, val.Interface())
|
||||
}
|
||||
}
|
||||
|
||||
return t
|
||||
}
|
||||
|
||||
// Fields returns a slice of Fields. A struct tag with the content of "-"
|
||||
// ignores the checking of that particular field. Example:
|
||||
//
|
||||
// // Field is ignored by this package.
|
||||
// Field bool `structs:"-"`
|
||||
//
|
||||
// It panics if s's kind is not struct.
|
||||
func (s *Struct) Fields() []*Field {
|
||||
return getFields(s.value, s.TagName)
|
||||
}
|
||||
|
||||
// Names returns a slice of field names. A struct tag with the content of "-"
|
||||
// ignores the checking of that particular field. Example:
|
||||
//
|
||||
// // Field is ignored by this package.
|
||||
// Field bool `structs:"-"`
|
||||
//
|
||||
// It panics if s's kind is not struct.
|
||||
func (s *Struct) Names() []string {
|
||||
fields := getFields(s.value, s.TagName)
|
||||
|
||||
names := make([]string, len(fields))
|
||||
|
||||
for i, field := range fields {
|
||||
names[i] = field.Name()
|
||||
}
|
||||
|
||||
return names
|
||||
}
|
||||
|
||||
func getFields(v reflect.Value, tagName string) []*Field {
|
||||
if v.Kind() == reflect.Ptr {
|
||||
v = v.Elem()
|
||||
}
|
||||
|
||||
t := v.Type()
|
||||
|
||||
var fields []*Field
|
||||
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
field := t.Field(i)
|
||||
|
||||
if tag := field.Tag.Get(tagName); tag == "-" {
|
||||
continue
|
||||
}
|
||||
|
||||
f := &Field{
|
||||
field: field,
|
||||
value: v.FieldByName(field.Name),
|
||||
}
|
||||
|
||||
fields = append(fields, f)
|
||||
|
||||
}
|
||||
|
||||
return fields
|
||||
}
|
||||
|
||||
// Field returns a new Field struct that provides several high level functions
|
||||
// around a single struct field entity. It panics if the field is not found.
|
||||
func (s *Struct) Field(name string) *Field {
|
||||
f, ok := s.FieldOk(name)
|
||||
if !ok {
|
||||
panic("field not found")
|
||||
}
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
// FieldOk returns a new Field struct that provides several high level functions
|
||||
// around a single struct field entity. The boolean returns true if the field
|
||||
// was found.
|
||||
func (s *Struct) FieldOk(name string) (*Field, bool) {
|
||||
t := s.value.Type()
|
||||
|
||||
field, ok := t.FieldByName(name)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
return &Field{
|
||||
field: field,
|
||||
value: s.value.FieldByName(name),
|
||||
defaultTag: s.TagName,
|
||||
}, true
|
||||
}
|
||||
|
||||
// IsZero returns true if all fields in a struct is a zero value (not
|
||||
// initialized) A struct tag with the content of "-" ignores the checking of
|
||||
// that particular field. Example:
|
||||
//
|
||||
// // Field is ignored by this package.
|
||||
// Field bool `structs:"-"`
|
||||
//
|
||||
// A value with the option of "omitnested" stops iterating further if the type
|
||||
// is a struct. Example:
|
||||
//
|
||||
// // Field is not processed further by this package.
|
||||
// Field time.Time `structs:"myName,omitnested"`
|
||||
// Field *http.Request `structs:",omitnested"`
|
||||
//
|
||||
// Note that only exported fields of a struct can be accessed, non exported
|
||||
// fields will be neglected. It panics if s's kind is not struct.
|
||||
func (s *Struct) IsZero() bool {
|
||||
fields := s.structFields()
|
||||
|
||||
for _, field := range fields {
|
||||
val := s.value.FieldByName(field.Name)
|
||||
|
||||
_, tagOpts := parseTag(field.Tag.Get(s.TagName))
|
||||
|
||||
if IsStruct(val.Interface()) && !tagOpts.Has("omitnested") {
|
||||
ok := IsZero(val.Interface())
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
// zero value of the given field, such as "" for string, 0 for int
|
||||
zero := reflect.Zero(val.Type()).Interface()
|
||||
|
||||
// current value of the given field
|
||||
current := val.Interface()
|
||||
|
||||
if !reflect.DeepEqual(current, zero) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// HasZero returns true if a field in a struct is not initialized (zero value).
|
||||
// A struct tag with the content of "-" ignores the checking of that particular
|
||||
// field. Example:
|
||||
//
|
||||
// // Field is ignored by this package.
|
||||
// Field bool `structs:"-"`
|
||||
//
|
||||
// A value with the option of "omitnested" stops iterating further if the type
|
||||
// is a struct. Example:
|
||||
//
|
||||
// // Field is not processed further by this package.
|
||||
// Field time.Time `structs:"myName,omitnested"`
|
||||
// Field *http.Request `structs:",omitnested"`
|
||||
//
|
||||
// Note that only exported fields of a struct can be accessed, non exported
|
||||
// fields will be neglected. It panics if s's kind is not struct.
|
||||
func (s *Struct) HasZero() bool {
|
||||
fields := s.structFields()
|
||||
|
||||
for _, field := range fields {
|
||||
val := s.value.FieldByName(field.Name)
|
||||
|
||||
_, tagOpts := parseTag(field.Tag.Get(s.TagName))
|
||||
|
||||
if IsStruct(val.Interface()) && !tagOpts.Has("omitnested") {
|
||||
ok := HasZero(val.Interface())
|
||||
if ok {
|
||||
return true
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
// zero value of the given field, such as "" for string, 0 for int
|
||||
zero := reflect.Zero(val.Type()).Interface()
|
||||
|
||||
// current value of the given field
|
||||
current := val.Interface()
|
||||
|
||||
if reflect.DeepEqual(current, zero) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// Name returns the structs's type name within its package. For more info refer
|
||||
// to Name() function.
|
||||
func (s *Struct) Name() string {
|
||||
return s.value.Type().Name()
|
||||
}
|
||||
|
||||
// structFields returns the exported struct fields for a given s struct. This
|
||||
// is a convenient helper method to avoid duplicate code in some of the
|
||||
// functions.
|
||||
func (s *Struct) structFields() []reflect.StructField {
|
||||
t := s.value.Type()
|
||||
|
||||
var f []reflect.StructField
|
||||
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
field := t.Field(i)
|
||||
// we can't access the value of unexported fields
|
||||
if field.PkgPath != "" {
|
||||
continue
|
||||
}
|
||||
|
||||
// don't check if it's omitted
|
||||
if tag := field.Tag.Get(s.TagName); tag == "-" {
|
||||
continue
|
||||
}
|
||||
|
||||
f = append(f, field)
|
||||
}
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
func strctVal(s interface{}) reflect.Value {
|
||||
v := reflect.ValueOf(s)
|
||||
|
||||
// if pointer get the underlying element≤
|
||||
for v.Kind() == reflect.Ptr {
|
||||
v = v.Elem()
|
||||
}
|
||||
|
||||
if v.Kind() != reflect.Struct {
|
||||
panic("not struct")
|
||||
}
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
// Map converts the given struct to a map[string]interface{}. For more info
|
||||
// refer to Struct types Map() method. It panics if s's kind is not struct.
|
||||
func Map(s interface{}) map[string]interface{} {
|
||||
return New(s).Map()
|
||||
}
|
||||
|
||||
// FillMap is the same as Map. Instead of returning the output, it fills the
|
||||
// given map.
|
||||
func FillMap(s interface{}, out map[string]interface{}) {
|
||||
New(s).FillMap(out)
|
||||
}
|
||||
|
||||
// Values converts the given struct to a []interface{}. For more info refer to
|
||||
// Struct types Values() method. It panics if s's kind is not struct.
|
||||
func Values(s interface{}) []interface{} {
|
||||
return New(s).Values()
|
||||
}
|
||||
|
||||
// Fields returns a slice of *Field. For more info refer to Struct types
|
||||
// Fields() method. It panics if s's kind is not struct.
|
||||
func Fields(s interface{}) []*Field {
|
||||
return New(s).Fields()
|
||||
}
|
||||
|
||||
// Names returns a slice of field names. For more info refer to Struct types
|
||||
// Names() method. It panics if s's kind is not struct.
|
||||
func Names(s interface{}) []string {
|
||||
return New(s).Names()
|
||||
}
|
||||
|
||||
// IsZero returns true if all fields is equal to a zero value. For more info
|
||||
// refer to Struct types IsZero() method. It panics if s's kind is not struct.
|
||||
func IsZero(s interface{}) bool {
|
||||
return New(s).IsZero()
|
||||
}
|
||||
|
||||
// HasZero returns true if any field is equal to a zero value. For more info
|
||||
// refer to Struct types HasZero() method. It panics if s's kind is not struct.
|
||||
func HasZero(s interface{}) bool {
|
||||
return New(s).HasZero()
|
||||
}
|
||||
|
||||
// IsStruct returns true if the given variable is a struct or a pointer to
|
||||
// struct.
|
||||
func IsStruct(s interface{}) bool {
|
||||
v := reflect.ValueOf(s)
|
||||
if v.Kind() == reflect.Ptr {
|
||||
v = v.Elem()
|
||||
}
|
||||
|
||||
// uninitialized zero value of a struct
|
||||
if v.Kind() == reflect.Invalid {
|
||||
return false
|
||||
}
|
||||
|
||||
return v.Kind() == reflect.Struct
|
||||
}
|
||||
|
||||
// Name returns the structs's type name within its package. It returns an
|
||||
// empty string for unnamed types. It panics if s's kind is not struct.
|
||||
func Name(s interface{}) string {
|
||||
return New(s).Name()
|
||||
}
|
||||
|
||||
// nested retrieves recursively all types for the given value and returns the
|
||||
// nested value.
|
||||
func (s *Struct) nested(val reflect.Value) interface{} {
|
||||
var finalVal interface{}
|
||||
|
||||
v := reflect.ValueOf(val.Interface())
|
||||
if v.Kind() == reflect.Ptr {
|
||||
v = v.Elem()
|
||||
}
|
||||
|
||||
switch v.Kind() {
|
||||
case reflect.Struct:
|
||||
n := New(val.Interface())
|
||||
n.TagName = s.TagName
|
||||
m := n.Map()
|
||||
|
||||
// do not add the converted value if there are no exported fields, ie:
|
||||
// time.Time
|
||||
if len(m) == 0 {
|
||||
finalVal = val.Interface()
|
||||
} else {
|
||||
finalVal = m
|
||||
}
|
||||
case reflect.Map:
|
||||
// get the element type of the map
|
||||
mapElem := val.Type()
|
||||
switch val.Type().Kind() {
|
||||
case reflect.Ptr, reflect.Array, reflect.Map,
|
||||
reflect.Slice, reflect.Chan:
|
||||
mapElem = val.Type().Elem()
|
||||
if mapElem.Kind() == reflect.Ptr {
|
||||
mapElem = mapElem.Elem()
|
||||
}
|
||||
}
|
||||
|
||||
// only iterate over struct types, ie: map[string]StructType,
|
||||
// map[string][]StructType,
|
||||
if mapElem.Kind() == reflect.Struct ||
|
||||
(mapElem.Kind() == reflect.Slice &&
|
||||
mapElem.Elem().Kind() == reflect.Struct) {
|
||||
m := make(map[string]interface{}, val.Len())
|
||||
for _, k := range val.MapKeys() {
|
||||
m[k.String()] = s.nested(val.MapIndex(k))
|
||||
}
|
||||
finalVal = m
|
||||
break
|
||||
}
|
||||
|
||||
// TODO(arslan): should this be optional?
|
||||
finalVal = val.Interface()
|
||||
case reflect.Slice, reflect.Array:
|
||||
if val.Type().Kind() == reflect.Interface {
|
||||
finalVal = val.Interface()
|
||||
break
|
||||
}
|
||||
|
||||
// TODO(arslan): should this be optional?
|
||||
// do not iterate of non struct types, just pass the value. Ie: []int,
|
||||
// []string, co... We only iterate further if it's a struct.
|
||||
// i.e []foo or []*foo
|
||||
if val.Type().Elem().Kind() != reflect.Struct &&
|
||||
!(val.Type().Elem().Kind() == reflect.Ptr &&
|
||||
val.Type().Elem().Elem().Kind() == reflect.Struct) {
|
||||
finalVal = val.Interface()
|
||||
break
|
||||
}
|
||||
|
||||
slices := make([]interface{}, val.Len())
|
||||
for x := 0; x < val.Len(); x++ {
|
||||
slices[x] = s.nested(val.Index(x))
|
||||
}
|
||||
finalVal = slices
|
||||
default:
|
||||
finalVal = val.Interface()
|
||||
}
|
||||
|
||||
return finalVal
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package structs
|
||||
|
||||
import "strings"
|
||||
|
||||
// tagOptions contains a slice of tag options
|
||||
type tagOptions []string
|
||||
|
||||
// Has returns true if the given option is available in tagOptions
|
||||
func (t tagOptions) Has(opt string) bool {
|
||||
for _, tagOpt := range t {
|
||||
if tagOpt == opt {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// parseTag splits a struct field's tag into its name and a list of options
|
||||
// which comes after a name. A tag is in the form of: "name,option1,option2".
|
||||
// The name can be neglectected.
|
||||
func parseTag(tag string) (string, tagOptions) {
|
||||
// tag is one of followings:
|
||||
// ""
|
||||
// "name"
|
||||
// "name,opt"
|
||||
// "name,opt,opt2"
|
||||
// ",opt"
|
||||
|
||||
res := strings.Split(tag, ",")
|
||||
return res[0], res[1:]
|
||||
}
|
200
vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go
сгенерированный
поставляемый
Normal file
200
vendor/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.pb.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,200 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor.proto
|
||||
|
||||
package descriptor
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
descriptorpb "google.golang.org/protobuf/types/descriptorpb"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
// Symbols defined in public import of google/protobuf/descriptor.proto.
|
||||
|
||||
type FieldDescriptorProto_Type = descriptorpb.FieldDescriptorProto_Type
|
||||
|
||||
const FieldDescriptorProto_TYPE_DOUBLE = descriptorpb.FieldDescriptorProto_TYPE_DOUBLE
|
||||
const FieldDescriptorProto_TYPE_FLOAT = descriptorpb.FieldDescriptorProto_TYPE_FLOAT
|
||||
const FieldDescriptorProto_TYPE_INT64 = descriptorpb.FieldDescriptorProto_TYPE_INT64
|
||||
const FieldDescriptorProto_TYPE_UINT64 = descriptorpb.FieldDescriptorProto_TYPE_UINT64
|
||||
const FieldDescriptorProto_TYPE_INT32 = descriptorpb.FieldDescriptorProto_TYPE_INT32
|
||||
const FieldDescriptorProto_TYPE_FIXED64 = descriptorpb.FieldDescriptorProto_TYPE_FIXED64
|
||||
const FieldDescriptorProto_TYPE_FIXED32 = descriptorpb.FieldDescriptorProto_TYPE_FIXED32
|
||||
const FieldDescriptorProto_TYPE_BOOL = descriptorpb.FieldDescriptorProto_TYPE_BOOL
|
||||
const FieldDescriptorProto_TYPE_STRING = descriptorpb.FieldDescriptorProto_TYPE_STRING
|
||||
const FieldDescriptorProto_TYPE_GROUP = descriptorpb.FieldDescriptorProto_TYPE_GROUP
|
||||
const FieldDescriptorProto_TYPE_MESSAGE = descriptorpb.FieldDescriptorProto_TYPE_MESSAGE
|
||||
const FieldDescriptorProto_TYPE_BYTES = descriptorpb.FieldDescriptorProto_TYPE_BYTES
|
||||
const FieldDescriptorProto_TYPE_UINT32 = descriptorpb.FieldDescriptorProto_TYPE_UINT32
|
||||
const FieldDescriptorProto_TYPE_ENUM = descriptorpb.FieldDescriptorProto_TYPE_ENUM
|
||||
const FieldDescriptorProto_TYPE_SFIXED32 = descriptorpb.FieldDescriptorProto_TYPE_SFIXED32
|
||||
const FieldDescriptorProto_TYPE_SFIXED64 = descriptorpb.FieldDescriptorProto_TYPE_SFIXED64
|
||||
const FieldDescriptorProto_TYPE_SINT32 = descriptorpb.FieldDescriptorProto_TYPE_SINT32
|
||||
const FieldDescriptorProto_TYPE_SINT64 = descriptorpb.FieldDescriptorProto_TYPE_SINT64
|
||||
|
||||
var FieldDescriptorProto_Type_name = descriptorpb.FieldDescriptorProto_Type_name
|
||||
var FieldDescriptorProto_Type_value = descriptorpb.FieldDescriptorProto_Type_value
|
||||
|
||||
type FieldDescriptorProto_Label = descriptorpb.FieldDescriptorProto_Label
|
||||
|
||||
const FieldDescriptorProto_LABEL_OPTIONAL = descriptorpb.FieldDescriptorProto_LABEL_OPTIONAL
|
||||
const FieldDescriptorProto_LABEL_REQUIRED = descriptorpb.FieldDescriptorProto_LABEL_REQUIRED
|
||||
const FieldDescriptorProto_LABEL_REPEATED = descriptorpb.FieldDescriptorProto_LABEL_REPEATED
|
||||
|
||||
var FieldDescriptorProto_Label_name = descriptorpb.FieldDescriptorProto_Label_name
|
||||
var FieldDescriptorProto_Label_value = descriptorpb.FieldDescriptorProto_Label_value
|
||||
|
||||
type FileOptions_OptimizeMode = descriptorpb.FileOptions_OptimizeMode
|
||||
|
||||
const FileOptions_SPEED = descriptorpb.FileOptions_SPEED
|
||||
const FileOptions_CODE_SIZE = descriptorpb.FileOptions_CODE_SIZE
|
||||
const FileOptions_LITE_RUNTIME = descriptorpb.FileOptions_LITE_RUNTIME
|
||||
|
||||
var FileOptions_OptimizeMode_name = descriptorpb.FileOptions_OptimizeMode_name
|
||||
var FileOptions_OptimizeMode_value = descriptorpb.FileOptions_OptimizeMode_value
|
||||
|
||||
type FieldOptions_CType = descriptorpb.FieldOptions_CType
|
||||
|
||||
const FieldOptions_STRING = descriptorpb.FieldOptions_STRING
|
||||
const FieldOptions_CORD = descriptorpb.FieldOptions_CORD
|
||||
const FieldOptions_STRING_PIECE = descriptorpb.FieldOptions_STRING_PIECE
|
||||
|
||||
var FieldOptions_CType_name = descriptorpb.FieldOptions_CType_name
|
||||
var FieldOptions_CType_value = descriptorpb.FieldOptions_CType_value
|
||||
|
||||
type FieldOptions_JSType = descriptorpb.FieldOptions_JSType
|
||||
|
||||
const FieldOptions_JS_NORMAL = descriptorpb.FieldOptions_JS_NORMAL
|
||||
const FieldOptions_JS_STRING = descriptorpb.FieldOptions_JS_STRING
|
||||
const FieldOptions_JS_NUMBER = descriptorpb.FieldOptions_JS_NUMBER
|
||||
|
||||
var FieldOptions_JSType_name = descriptorpb.FieldOptions_JSType_name
|
||||
var FieldOptions_JSType_value = descriptorpb.FieldOptions_JSType_value
|
||||
|
||||
type MethodOptions_IdempotencyLevel = descriptorpb.MethodOptions_IdempotencyLevel
|
||||
|
||||
const MethodOptions_IDEMPOTENCY_UNKNOWN = descriptorpb.MethodOptions_IDEMPOTENCY_UNKNOWN
|
||||
const MethodOptions_NO_SIDE_EFFECTS = descriptorpb.MethodOptions_NO_SIDE_EFFECTS
|
||||
const MethodOptions_IDEMPOTENT = descriptorpb.MethodOptions_IDEMPOTENT
|
||||
|
||||
var MethodOptions_IdempotencyLevel_name = descriptorpb.MethodOptions_IdempotencyLevel_name
|
||||
var MethodOptions_IdempotencyLevel_value = descriptorpb.MethodOptions_IdempotencyLevel_value
|
||||
|
||||
type FileDescriptorSet = descriptorpb.FileDescriptorSet
|
||||
type FileDescriptorProto = descriptorpb.FileDescriptorProto
|
||||
type DescriptorProto = descriptorpb.DescriptorProto
|
||||
type ExtensionRangeOptions = descriptorpb.ExtensionRangeOptions
|
||||
type FieldDescriptorProto = descriptorpb.FieldDescriptorProto
|
||||
type OneofDescriptorProto = descriptorpb.OneofDescriptorProto
|
||||
type EnumDescriptorProto = descriptorpb.EnumDescriptorProto
|
||||
type EnumValueDescriptorProto = descriptorpb.EnumValueDescriptorProto
|
||||
type ServiceDescriptorProto = descriptorpb.ServiceDescriptorProto
|
||||
type MethodDescriptorProto = descriptorpb.MethodDescriptorProto
|
||||
|
||||
const Default_MethodDescriptorProto_ClientStreaming = descriptorpb.Default_MethodDescriptorProto_ClientStreaming
|
||||
const Default_MethodDescriptorProto_ServerStreaming = descriptorpb.Default_MethodDescriptorProto_ServerStreaming
|
||||
|
||||
type FileOptions = descriptorpb.FileOptions
|
||||
|
||||
const Default_FileOptions_JavaMultipleFiles = descriptorpb.Default_FileOptions_JavaMultipleFiles
|
||||
const Default_FileOptions_JavaStringCheckUtf8 = descriptorpb.Default_FileOptions_JavaStringCheckUtf8
|
||||
const Default_FileOptions_OptimizeFor = descriptorpb.Default_FileOptions_OptimizeFor
|
||||
const Default_FileOptions_CcGenericServices = descriptorpb.Default_FileOptions_CcGenericServices
|
||||
const Default_FileOptions_JavaGenericServices = descriptorpb.Default_FileOptions_JavaGenericServices
|
||||
const Default_FileOptions_PyGenericServices = descriptorpb.Default_FileOptions_PyGenericServices
|
||||
const Default_FileOptions_PhpGenericServices = descriptorpb.Default_FileOptions_PhpGenericServices
|
||||
const Default_FileOptions_Deprecated = descriptorpb.Default_FileOptions_Deprecated
|
||||
const Default_FileOptions_CcEnableArenas = descriptorpb.Default_FileOptions_CcEnableArenas
|
||||
|
||||
type MessageOptions = descriptorpb.MessageOptions
|
||||
|
||||
const Default_MessageOptions_MessageSetWireFormat = descriptorpb.Default_MessageOptions_MessageSetWireFormat
|
||||
const Default_MessageOptions_NoStandardDescriptorAccessor = descriptorpb.Default_MessageOptions_NoStandardDescriptorAccessor
|
||||
const Default_MessageOptions_Deprecated = descriptorpb.Default_MessageOptions_Deprecated
|
||||
|
||||
type FieldOptions = descriptorpb.FieldOptions
|
||||
|
||||
const Default_FieldOptions_Ctype = descriptorpb.Default_FieldOptions_Ctype
|
||||
const Default_FieldOptions_Jstype = descriptorpb.Default_FieldOptions_Jstype
|
||||
const Default_FieldOptions_Lazy = descriptorpb.Default_FieldOptions_Lazy
|
||||
const Default_FieldOptions_Deprecated = descriptorpb.Default_FieldOptions_Deprecated
|
||||
const Default_FieldOptions_Weak = descriptorpb.Default_FieldOptions_Weak
|
||||
|
||||
type OneofOptions = descriptorpb.OneofOptions
|
||||
type EnumOptions = descriptorpb.EnumOptions
|
||||
|
||||
const Default_EnumOptions_Deprecated = descriptorpb.Default_EnumOptions_Deprecated
|
||||
|
||||
type EnumValueOptions = descriptorpb.EnumValueOptions
|
||||
|
||||
const Default_EnumValueOptions_Deprecated = descriptorpb.Default_EnumValueOptions_Deprecated
|
||||
|
||||
type ServiceOptions = descriptorpb.ServiceOptions
|
||||
|
||||
const Default_ServiceOptions_Deprecated = descriptorpb.Default_ServiceOptions_Deprecated
|
||||
|
||||
type MethodOptions = descriptorpb.MethodOptions
|
||||
|
||||
const Default_MethodOptions_Deprecated = descriptorpb.Default_MethodOptions_Deprecated
|
||||
const Default_MethodOptions_IdempotencyLevel = descriptorpb.Default_MethodOptions_IdempotencyLevel
|
||||
|
||||
type UninterpretedOption = descriptorpb.UninterpretedOption
|
||||
type SourceCodeInfo = descriptorpb.SourceCodeInfo
|
||||
type GeneratedCodeInfo = descriptorpb.GeneratedCodeInfo
|
||||
type DescriptorProto_ExtensionRange = descriptorpb.DescriptorProto_ExtensionRange
|
||||
type DescriptorProto_ReservedRange = descriptorpb.DescriptorProto_ReservedRange
|
||||
type EnumDescriptorProto_EnumReservedRange = descriptorpb.EnumDescriptorProto_EnumReservedRange
|
||||
type UninterpretedOption_NamePart = descriptorpb.UninterpretedOption_NamePart
|
||||
type SourceCodeInfo_Location = descriptorpb.SourceCodeInfo_Location
|
||||
type GeneratedCodeInfo_Annotation = descriptorpb.GeneratedCodeInfo_Annotation
|
||||
|
||||
var File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDesc = []byte{
|
||||
0x0a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c,
|
||||
0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72,
|
||||
0x69, 0x70, 0x74, 0x6f, 0x72, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
|
||||
0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0x40, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68,
|
||||
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65,
|
||||
0x6e, 0x2d, 0x67, 0x6f, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x3b,
|
||||
0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x00, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x32,
|
||||
}
|
||||
|
||||
var file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_goTypes = []interface{}{}
|
||||
var file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_init() }
|
||||
func file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_init() {
|
||||
if File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 0,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_goTypes,
|
||||
DependencyIndexes: file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_depIdxs,
|
||||
}.Build()
|
||||
File_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto = out.File
|
||||
file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_rawDesc = nil
|
||||
file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_goTypes = nil
|
||||
file_github_com_golang_protobuf_protoc_gen_go_descriptor_descriptor_proto_depIdxs = nil
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
# Reflection
|
||||
|
||||
Package reflection implements server reflection service.
|
||||
|
||||
The service implemented is defined in: https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto.
|
||||
|
||||
To register server reflection on a gRPC server:
|
||||
```go
|
||||
import "google.golang.org/grpc/reflection"
|
||||
|
||||
s := grpc.NewServer()
|
||||
pb.RegisterYourOwnServer(s, &server{})
|
||||
|
||||
// Register reflection service on gRPC server.
|
||||
reflection.Register(s)
|
||||
|
||||
s.Serve(lis)
|
||||
```
|
953
vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.pb.go
сгенерированный
поставляемый
Normal file
953
vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.pb.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,953 @@
|
|||
// Copyright 2016 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Service exported by server reflection
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.25.0
|
||||
// protoc v3.14.0
|
||||
// source: reflection/grpc_reflection_v1alpha/reflection.proto
|
||||
|
||||
package grpc_reflection_v1alpha
|
||||
|
||||
import (
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// This is a compile-time assertion that a sufficiently up-to-date version
|
||||
// of the legacy proto package is being used.
|
||||
const _ = proto.ProtoPackageIsVersion4
|
||||
|
||||
// The message sent by the client when calling ServerReflectionInfo method.
|
||||
type ServerReflectionRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"`
|
||||
// To use reflection service, the client should set one of the following
|
||||
// fields in message_request. The server distinguishes requests by their
|
||||
// defined field and then handles them using corresponding methods.
|
||||
//
|
||||
// Types that are assignable to MessageRequest:
|
||||
// *ServerReflectionRequest_FileByFilename
|
||||
// *ServerReflectionRequest_FileContainingSymbol
|
||||
// *ServerReflectionRequest_FileContainingExtension
|
||||
// *ServerReflectionRequest_AllExtensionNumbersOfType
|
||||
// *ServerReflectionRequest_ListServices
|
||||
MessageRequest isServerReflectionRequest_MessageRequest `protobuf_oneof:"message_request"`
|
||||
}
|
||||
|
||||
func (x *ServerReflectionRequest) Reset() {
|
||||
*x = ServerReflectionRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ServerReflectionRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ServerReflectionRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ServerReflectionRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ServerReflectionRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ServerReflectionRequest) Descriptor() ([]byte, []int) {
|
||||
return file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *ServerReflectionRequest) GetHost() string {
|
||||
if x != nil {
|
||||
return x.Host
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *ServerReflectionRequest) GetMessageRequest() isServerReflectionRequest_MessageRequest {
|
||||
if m != nil {
|
||||
return m.MessageRequest
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ServerReflectionRequest) GetFileByFilename() string {
|
||||
if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_FileByFilename); ok {
|
||||
return x.FileByFilename
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ServerReflectionRequest) GetFileContainingSymbol() string {
|
||||
if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_FileContainingSymbol); ok {
|
||||
return x.FileContainingSymbol
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ServerReflectionRequest) GetFileContainingExtension() *ExtensionRequest {
|
||||
if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_FileContainingExtension); ok {
|
||||
return x.FileContainingExtension
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ServerReflectionRequest) GetAllExtensionNumbersOfType() string {
|
||||
if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_AllExtensionNumbersOfType); ok {
|
||||
return x.AllExtensionNumbersOfType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ServerReflectionRequest) GetListServices() string {
|
||||
if x, ok := x.GetMessageRequest().(*ServerReflectionRequest_ListServices); ok {
|
||||
return x.ListServices
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type isServerReflectionRequest_MessageRequest interface {
|
||||
isServerReflectionRequest_MessageRequest()
|
||||
}
|
||||
|
||||
type ServerReflectionRequest_FileByFilename struct {
|
||||
// Find a proto file by the file name.
|
||||
FileByFilename string `protobuf:"bytes,3,opt,name=file_by_filename,json=fileByFilename,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ServerReflectionRequest_FileContainingSymbol struct {
|
||||
// Find the proto file that declares the given fully-qualified symbol name.
|
||||
// This field should be a fully-qualified symbol name
|
||||
// (e.g. <package>.<service>[.<method>] or <package>.<type>).
|
||||
FileContainingSymbol string `protobuf:"bytes,4,opt,name=file_containing_symbol,json=fileContainingSymbol,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ServerReflectionRequest_FileContainingExtension struct {
|
||||
// Find the proto file which defines an extension extending the given
|
||||
// message type with the given field number.
|
||||
FileContainingExtension *ExtensionRequest `protobuf:"bytes,5,opt,name=file_containing_extension,json=fileContainingExtension,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ServerReflectionRequest_AllExtensionNumbersOfType struct {
|
||||
// Finds the tag numbers used by all known extensions of extendee_type, and
|
||||
// appends them to ExtensionNumberResponse in an undefined order.
|
||||
// Its corresponding method is best-effort: it's not guaranteed that the
|
||||
// reflection service will implement this method, and it's not guaranteed
|
||||
// that this method will provide all extensions. Returns
|
||||
// StatusCode::UNIMPLEMENTED if it's not implemented.
|
||||
// This field should be a fully-qualified type name. The format is
|
||||
// <package>.<type>
|
||||
AllExtensionNumbersOfType string `protobuf:"bytes,6,opt,name=all_extension_numbers_of_type,json=allExtensionNumbersOfType,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ServerReflectionRequest_ListServices struct {
|
||||
// List the full names of registered services. The content will not be
|
||||
// checked.
|
||||
ListServices string `protobuf:"bytes,7,opt,name=list_services,json=listServices,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*ServerReflectionRequest_FileByFilename) isServerReflectionRequest_MessageRequest() {}
|
||||
|
||||
func (*ServerReflectionRequest_FileContainingSymbol) isServerReflectionRequest_MessageRequest() {}
|
||||
|
||||
func (*ServerReflectionRequest_FileContainingExtension) isServerReflectionRequest_MessageRequest() {}
|
||||
|
||||
func (*ServerReflectionRequest_AllExtensionNumbersOfType) isServerReflectionRequest_MessageRequest() {
|
||||
}
|
||||
|
||||
func (*ServerReflectionRequest_ListServices) isServerReflectionRequest_MessageRequest() {}
|
||||
|
||||
// The type name and extension number sent by the client when requesting
|
||||
// file_containing_extension.
|
||||
type ExtensionRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Fully-qualified type name. The format should be <package>.<type>
|
||||
ContainingType string `protobuf:"bytes,1,opt,name=containing_type,json=containingType,proto3" json:"containing_type,omitempty"`
|
||||
ExtensionNumber int32 `protobuf:"varint,2,opt,name=extension_number,json=extensionNumber,proto3" json:"extension_number,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ExtensionRequest) Reset() {
|
||||
*x = ExtensionRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ExtensionRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ExtensionRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ExtensionRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ExtensionRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ExtensionRequest) Descriptor() ([]byte, []int) {
|
||||
return file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *ExtensionRequest) GetContainingType() string {
|
||||
if x != nil {
|
||||
return x.ContainingType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ExtensionRequest) GetExtensionNumber() int32 {
|
||||
if x != nil {
|
||||
return x.ExtensionNumber
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// The message sent by the server to answer ServerReflectionInfo method.
|
||||
type ServerReflectionResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
ValidHost string `protobuf:"bytes,1,opt,name=valid_host,json=validHost,proto3" json:"valid_host,omitempty"`
|
||||
OriginalRequest *ServerReflectionRequest `protobuf:"bytes,2,opt,name=original_request,json=originalRequest,proto3" json:"original_request,omitempty"`
|
||||
// The server sets one of the following fields according to the
|
||||
// message_request in the request.
|
||||
//
|
||||
// Types that are assignable to MessageResponse:
|
||||
// *ServerReflectionResponse_FileDescriptorResponse
|
||||
// *ServerReflectionResponse_AllExtensionNumbersResponse
|
||||
// *ServerReflectionResponse_ListServicesResponse
|
||||
// *ServerReflectionResponse_ErrorResponse
|
||||
MessageResponse isServerReflectionResponse_MessageResponse `protobuf_oneof:"message_response"`
|
||||
}
|
||||
|
||||
func (x *ServerReflectionResponse) Reset() {
|
||||
*x = ServerReflectionResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ServerReflectionResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ServerReflectionResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ServerReflectionResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ServerReflectionResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ServerReflectionResponse) Descriptor() ([]byte, []int) {
|
||||
return file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *ServerReflectionResponse) GetValidHost() string {
|
||||
if x != nil {
|
||||
return x.ValidHost
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ServerReflectionResponse) GetOriginalRequest() *ServerReflectionRequest {
|
||||
if x != nil {
|
||||
return x.OriginalRequest
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ServerReflectionResponse) GetMessageResponse() isServerReflectionResponse_MessageResponse {
|
||||
if m != nil {
|
||||
return m.MessageResponse
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ServerReflectionResponse) GetFileDescriptorResponse() *FileDescriptorResponse {
|
||||
if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_FileDescriptorResponse); ok {
|
||||
return x.FileDescriptorResponse
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ServerReflectionResponse) GetAllExtensionNumbersResponse() *ExtensionNumberResponse {
|
||||
if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_AllExtensionNumbersResponse); ok {
|
||||
return x.AllExtensionNumbersResponse
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ServerReflectionResponse) GetListServicesResponse() *ListServiceResponse {
|
||||
if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_ListServicesResponse); ok {
|
||||
return x.ListServicesResponse
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ServerReflectionResponse) GetErrorResponse() *ErrorResponse {
|
||||
if x, ok := x.GetMessageResponse().(*ServerReflectionResponse_ErrorResponse); ok {
|
||||
return x.ErrorResponse
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type isServerReflectionResponse_MessageResponse interface {
|
||||
isServerReflectionResponse_MessageResponse()
|
||||
}
|
||||
|
||||
type ServerReflectionResponse_FileDescriptorResponse struct {
|
||||
// This message is used to answer file_by_filename, file_containing_symbol,
|
||||
// file_containing_extension requests with transitive dependencies.
|
||||
// As the repeated label is not allowed in oneof fields, we use a
|
||||
// FileDescriptorResponse message to encapsulate the repeated fields.
|
||||
// The reflection service is allowed to avoid sending FileDescriptorProtos
|
||||
// that were previously sent in response to earlier requests in the stream.
|
||||
FileDescriptorResponse *FileDescriptorResponse `protobuf:"bytes,4,opt,name=file_descriptor_response,json=fileDescriptorResponse,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ServerReflectionResponse_AllExtensionNumbersResponse struct {
|
||||
// This message is used to answer all_extension_numbers_of_type requests.
|
||||
AllExtensionNumbersResponse *ExtensionNumberResponse `protobuf:"bytes,5,opt,name=all_extension_numbers_response,json=allExtensionNumbersResponse,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ServerReflectionResponse_ListServicesResponse struct {
|
||||
// This message is used to answer list_services requests.
|
||||
ListServicesResponse *ListServiceResponse `protobuf:"bytes,6,opt,name=list_services_response,json=listServicesResponse,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ServerReflectionResponse_ErrorResponse struct {
|
||||
// This message is used when an error occurs.
|
||||
ErrorResponse *ErrorResponse `protobuf:"bytes,7,opt,name=error_response,json=errorResponse,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*ServerReflectionResponse_FileDescriptorResponse) isServerReflectionResponse_MessageResponse() {
|
||||
}
|
||||
|
||||
func (*ServerReflectionResponse_AllExtensionNumbersResponse) isServerReflectionResponse_MessageResponse() {
|
||||
}
|
||||
|
||||
func (*ServerReflectionResponse_ListServicesResponse) isServerReflectionResponse_MessageResponse() {}
|
||||
|
||||
func (*ServerReflectionResponse_ErrorResponse) isServerReflectionResponse_MessageResponse() {}
|
||||
|
||||
// Serialized FileDescriptorProto messages sent by the server answering
|
||||
// a file_by_filename, file_containing_symbol, or file_containing_extension
|
||||
// request.
|
||||
type FileDescriptorResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Serialized FileDescriptorProto messages. We avoid taking a dependency on
|
||||
// descriptor.proto, which uses proto2 only features, by making them opaque
|
||||
// bytes instead.
|
||||
FileDescriptorProto [][]byte `protobuf:"bytes,1,rep,name=file_descriptor_proto,json=fileDescriptorProto,proto3" json:"file_descriptor_proto,omitempty"`
|
||||
}
|
||||
|
||||
func (x *FileDescriptorResponse) Reset() {
|
||||
*x = FileDescriptorResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *FileDescriptorResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*FileDescriptorResponse) ProtoMessage() {}
|
||||
|
||||
func (x *FileDescriptorResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use FileDescriptorResponse.ProtoReflect.Descriptor instead.
|
||||
func (*FileDescriptorResponse) Descriptor() ([]byte, []int) {
|
||||
return file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *FileDescriptorResponse) GetFileDescriptorProto() [][]byte {
|
||||
if x != nil {
|
||||
return x.FileDescriptorProto
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// A list of extension numbers sent by the server answering
|
||||
// all_extension_numbers_of_type request.
|
||||
type ExtensionNumberResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Full name of the base type, including the package name. The format
|
||||
// is <package>.<type>
|
||||
BaseTypeName string `protobuf:"bytes,1,opt,name=base_type_name,json=baseTypeName,proto3" json:"base_type_name,omitempty"`
|
||||
ExtensionNumber []int32 `protobuf:"varint,2,rep,packed,name=extension_number,json=extensionNumber,proto3" json:"extension_number,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ExtensionNumberResponse) Reset() {
|
||||
*x = ExtensionNumberResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ExtensionNumberResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ExtensionNumberResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ExtensionNumberResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ExtensionNumberResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ExtensionNumberResponse) Descriptor() ([]byte, []int) {
|
||||
return file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *ExtensionNumberResponse) GetBaseTypeName() string {
|
||||
if x != nil {
|
||||
return x.BaseTypeName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ExtensionNumberResponse) GetExtensionNumber() []int32 {
|
||||
if x != nil {
|
||||
return x.ExtensionNumber
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// A list of ServiceResponse sent by the server answering list_services request.
|
||||
type ListServiceResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// The information of each service may be expanded in the future, so we use
|
||||
// ServiceResponse message to encapsulate it.
|
||||
Service []*ServiceResponse `protobuf:"bytes,1,rep,name=service,proto3" json:"service,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ListServiceResponse) Reset() {
|
||||
*x = ListServiceResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ListServiceResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListServiceResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ListServiceResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListServiceResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ListServiceResponse) Descriptor() ([]byte, []int) {
|
||||
return file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *ListServiceResponse) GetService() []*ServiceResponse {
|
||||
if x != nil {
|
||||
return x.Service
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// The information of a single service used by ListServiceResponse to answer
|
||||
// list_services request.
|
||||
type ServiceResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Full name of a registered service, including its package name. The format
|
||||
// is <package>.<service>
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ServiceResponse) Reset() {
|
||||
*x = ServiceResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ServiceResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ServiceResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ServiceResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[6]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ServiceResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ServiceResponse) Descriptor() ([]byte, []int) {
|
||||
return file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *ServiceResponse) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// The error code and error message sent by the server when an error occurs.
|
||||
type ErrorResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// This field uses the error codes defined in grpc::StatusCode.
|
||||
ErrorCode int32 `protobuf:"varint,1,opt,name=error_code,json=errorCode,proto3" json:"error_code,omitempty"`
|
||||
ErrorMessage string `protobuf:"bytes,2,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ErrorResponse) Reset() {
|
||||
*x = ErrorResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ErrorResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ErrorResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ErrorResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[7]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ErrorResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ErrorResponse) Descriptor() ([]byte, []int) {
|
||||
return file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *ErrorResponse) GetErrorCode() int32 {
|
||||
if x != nil {
|
||||
return x.ErrorCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ErrorResponse) GetErrorMessage() string {
|
||||
if x != nil {
|
||||
return x.ErrorMessage
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_reflection_grpc_reflection_v1alpha_reflection_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDesc = []byte{
|
||||
0x0a, 0x33, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x67, 0x72, 0x70,
|
||||
0x63, 0x5f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x76, 0x31, 0x61,
|
||||
0x6c, 0x70, 0x68, 0x61, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x17, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c,
|
||||
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x22, 0xf8,
|
||||
0x02, 0x0a, 0x17, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f,
|
||||
0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x2a,
|
||||
0x0a, 0x10, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x62, 0x79, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61,
|
||||
0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0e, 0x66, 0x69, 0x6c, 0x65,
|
||||
0x42, 0x79, 0x46, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x36, 0x0a, 0x16, 0x66, 0x69,
|
||||
0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x79,
|
||||
0x6d, 0x62, 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x14, 0x66, 0x69,
|
||||
0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x53, 0x79, 0x6d, 0x62,
|
||||
0x6f, 0x6c, 0x12, 0x67, 0x0a, 0x19, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61,
|
||||
0x69, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18,
|
||||
0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66,
|
||||
0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e,
|
||||
0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x48, 0x00, 0x52, 0x17, 0x66, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69,
|
||||
0x6e, 0x67, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x42, 0x0a, 0x1d, 0x61,
|
||||
0x6c, 0x6c, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d,
|
||||
0x62, 0x65, 0x72, 0x73, 0x5f, 0x6f, 0x66, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01,
|
||||
0x28, 0x09, 0x48, 0x00, 0x52, 0x19, 0x61, 0x6c, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69,
|
||||
0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x4f, 0x66, 0x54, 0x79, 0x70, 0x65, 0x12,
|
||||
0x25, 0x0a, 0x0d, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
|
||||
0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0c, 0x6c, 0x69, 0x73, 0x74, 0x53, 0x65,
|
||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x42, 0x11, 0x0a, 0x0f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
|
||||
0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x66, 0x0a, 0x10, 0x45, 0x78, 0x74,
|
||||
0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x27, 0x0a,
|
||||
0x0f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x69,
|
||||
0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73,
|
||||
0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x0f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65,
|
||||
0x72, 0x22, 0xc7, 0x04, 0x0a, 0x18, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c,
|
||||
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d,
|
||||
0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x09, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x5b, 0x0a,
|
||||
0x10, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||
0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72,
|
||||
0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68,
|
||||
0x61, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x0f, 0x6f, 0x72, 0x69, 0x67, 0x69,
|
||||
0x6e, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x6b, 0x0a, 0x18, 0x66, 0x69,
|
||||
0x6c, 0x65, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x5f, 0x72, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x67,
|
||||
0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76,
|
||||
0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72,
|
||||
0x69, 0x70, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52,
|
||||
0x16, 0x66, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x77, 0x0a, 0x1e, 0x61, 0x6c, 0x6c, 0x5f, 0x65,
|
||||
0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73,
|
||||
0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
||||
0x30, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73,
|
||||
0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||
0x65, 0x48, 0x00, 0x52, 0x1b, 0x61, 0x6c, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f,
|
||||
0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
|
||||
0x12, 0x64, 0x0a, 0x16, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
||||
0x73, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b,
|
||||
0x32, 0x2c, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53,
|
||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00,
|
||||
0x52, 0x14, 0x6c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4f, 0x0a, 0x0e, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f,
|
||||
0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26,
|
||||
0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x48, 0x00, 0x52, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x12, 0x0a, 0x10, 0x6d, 0x65, 0x73, 0x73, 0x61,
|
||||
0x67, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x4c, 0x0a, 0x16, 0x46,
|
||||
0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x15, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x64, 0x65,
|
||||
0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x18, 0x01,
|
||||
0x20, 0x03, 0x28, 0x0c, 0x52, 0x13, 0x66, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69,
|
||||
0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6a, 0x0a, 0x17, 0x45, 0x78, 0x74,
|
||||
0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x74, 0x79, 0x70,
|
||||
0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x62, 0x61,
|
||||
0x73, 0x65, 0x54, 0x79, 0x70, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x78,
|
||||
0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02,
|
||||
0x20, 0x03, 0x28, 0x05, 0x52, 0x0f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4e,
|
||||
0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x59, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72,
|
||||
0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x42, 0x0a, 0x07,
|
||||
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e,
|
||||
0x67, 0x72, 0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e,
|
||||
0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
||||
0x22, 0x25, 0x0a, 0x0f, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
||||
0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x53, 0x0a, 0x0d, 0x45, 0x72, 0x72, 0x6f, 0x72,
|
||||
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f,
|
||||
0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x65, 0x72,
|
||||
0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x72, 0x72, 0x6f, 0x72,
|
||||
0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c,
|
||||
0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x93, 0x01, 0x0a,
|
||||
0x10, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x12, 0x7f, 0x0a, 0x14, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65,
|
||||
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x30, 0x2e, 0x67, 0x72, 0x70, 0x63,
|
||||
0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x61, 0x6c,
|
||||
0x70, 0x68, 0x61, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x67, 0x72,
|
||||
0x70, 0x63, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31,
|
||||
0x61, 0x6c, 0x70, 0x68, 0x61, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x66, 0x6c,
|
||||
0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01,
|
||||
0x30, 0x01, 0x42, 0x3b, 0x5a, 0x39, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c,
|
||||
0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x65, 0x66,
|
||||
0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x72, 0x65, 0x66,
|
||||
0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDescOnce sync.Once
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDescData = file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDescGZIP() []byte {
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDescOnce.Do(func() {
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDescData = protoimpl.X.CompressGZIP(file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDescData)
|
||||
})
|
||||
return file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
var file_reflection_grpc_reflection_v1alpha_reflection_proto_goTypes = []interface{}{
|
||||
(*ServerReflectionRequest)(nil), // 0: grpc.reflection.v1alpha.ServerReflectionRequest
|
||||
(*ExtensionRequest)(nil), // 1: grpc.reflection.v1alpha.ExtensionRequest
|
||||
(*ServerReflectionResponse)(nil), // 2: grpc.reflection.v1alpha.ServerReflectionResponse
|
||||
(*FileDescriptorResponse)(nil), // 3: grpc.reflection.v1alpha.FileDescriptorResponse
|
||||
(*ExtensionNumberResponse)(nil), // 4: grpc.reflection.v1alpha.ExtensionNumberResponse
|
||||
(*ListServiceResponse)(nil), // 5: grpc.reflection.v1alpha.ListServiceResponse
|
||||
(*ServiceResponse)(nil), // 6: grpc.reflection.v1alpha.ServiceResponse
|
||||
(*ErrorResponse)(nil), // 7: grpc.reflection.v1alpha.ErrorResponse
|
||||
}
|
||||
var file_reflection_grpc_reflection_v1alpha_reflection_proto_depIdxs = []int32{
|
||||
1, // 0: grpc.reflection.v1alpha.ServerReflectionRequest.file_containing_extension:type_name -> grpc.reflection.v1alpha.ExtensionRequest
|
||||
0, // 1: grpc.reflection.v1alpha.ServerReflectionResponse.original_request:type_name -> grpc.reflection.v1alpha.ServerReflectionRequest
|
||||
3, // 2: grpc.reflection.v1alpha.ServerReflectionResponse.file_descriptor_response:type_name -> grpc.reflection.v1alpha.FileDescriptorResponse
|
||||
4, // 3: grpc.reflection.v1alpha.ServerReflectionResponse.all_extension_numbers_response:type_name -> grpc.reflection.v1alpha.ExtensionNumberResponse
|
||||
5, // 4: grpc.reflection.v1alpha.ServerReflectionResponse.list_services_response:type_name -> grpc.reflection.v1alpha.ListServiceResponse
|
||||
7, // 5: grpc.reflection.v1alpha.ServerReflectionResponse.error_response:type_name -> grpc.reflection.v1alpha.ErrorResponse
|
||||
6, // 6: grpc.reflection.v1alpha.ListServiceResponse.service:type_name -> grpc.reflection.v1alpha.ServiceResponse
|
||||
0, // 7: grpc.reflection.v1alpha.ServerReflection.ServerReflectionInfo:input_type -> grpc.reflection.v1alpha.ServerReflectionRequest
|
||||
2, // 8: grpc.reflection.v1alpha.ServerReflection.ServerReflectionInfo:output_type -> grpc.reflection.v1alpha.ServerReflectionResponse
|
||||
8, // [8:9] is the sub-list for method output_type
|
||||
7, // [7:8] is the sub-list for method input_type
|
||||
7, // [7:7] is the sub-list for extension type_name
|
||||
7, // [7:7] is the sub-list for extension extendee
|
||||
0, // [0:7] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_reflection_grpc_reflection_v1alpha_reflection_proto_init() }
|
||||
func file_reflection_grpc_reflection_v1alpha_reflection_proto_init() {
|
||||
if File_reflection_grpc_reflection_v1alpha_reflection_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ServerReflectionRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ExtensionRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ServerReflectionResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*FileDescriptorResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ExtensionNumberResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ListServiceResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ServiceResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ErrorResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[0].OneofWrappers = []interface{}{
|
||||
(*ServerReflectionRequest_FileByFilename)(nil),
|
||||
(*ServerReflectionRequest_FileContainingSymbol)(nil),
|
||||
(*ServerReflectionRequest_FileContainingExtension)(nil),
|
||||
(*ServerReflectionRequest_AllExtensionNumbersOfType)(nil),
|
||||
(*ServerReflectionRequest_ListServices)(nil),
|
||||
}
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes[2].OneofWrappers = []interface{}{
|
||||
(*ServerReflectionResponse_FileDescriptorResponse)(nil),
|
||||
(*ServerReflectionResponse_AllExtensionNumbersResponse)(nil),
|
||||
(*ServerReflectionResponse_ListServicesResponse)(nil),
|
||||
(*ServerReflectionResponse_ErrorResponse)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 8,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_reflection_grpc_reflection_v1alpha_reflection_proto_goTypes,
|
||||
DependencyIndexes: file_reflection_grpc_reflection_v1alpha_reflection_proto_depIdxs,
|
||||
MessageInfos: file_reflection_grpc_reflection_v1alpha_reflection_proto_msgTypes,
|
||||
}.Build()
|
||||
File_reflection_grpc_reflection_v1alpha_reflection_proto = out.File
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_rawDesc = nil
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_goTypes = nil
|
||||
file_reflection_grpc_reflection_v1alpha_reflection_proto_depIdxs = nil
|
||||
}
|
138
vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.proto
сгенерированный
поставляемый
Normal file
138
vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.proto
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,138 @@
|
|||
// Copyright 2016 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Service exported by server reflection
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
option go_package = "google.golang.org/grpc/reflection/grpc_reflection_v1alpha";
|
||||
|
||||
package grpc.reflection.v1alpha;
|
||||
|
||||
service ServerReflection {
|
||||
// The reflection service is structured as a bidirectional stream, ensuring
|
||||
// all related requests go to a single server.
|
||||
rpc ServerReflectionInfo(stream ServerReflectionRequest)
|
||||
returns (stream ServerReflectionResponse);
|
||||
}
|
||||
|
||||
// The message sent by the client when calling ServerReflectionInfo method.
|
||||
message ServerReflectionRequest {
|
||||
string host = 1;
|
||||
// To use reflection service, the client should set one of the following
|
||||
// fields in message_request. The server distinguishes requests by their
|
||||
// defined field and then handles them using corresponding methods.
|
||||
oneof message_request {
|
||||
// Find a proto file by the file name.
|
||||
string file_by_filename = 3;
|
||||
|
||||
// Find the proto file that declares the given fully-qualified symbol name.
|
||||
// This field should be a fully-qualified symbol name
|
||||
// (e.g. <package>.<service>[.<method>] or <package>.<type>).
|
||||
string file_containing_symbol = 4;
|
||||
|
||||
// Find the proto file which defines an extension extending the given
|
||||
// message type with the given field number.
|
||||
ExtensionRequest file_containing_extension = 5;
|
||||
|
||||
// Finds the tag numbers used by all known extensions of extendee_type, and
|
||||
// appends them to ExtensionNumberResponse in an undefined order.
|
||||
// Its corresponding method is best-effort: it's not guaranteed that the
|
||||
// reflection service will implement this method, and it's not guaranteed
|
||||
// that this method will provide all extensions. Returns
|
||||
// StatusCode::UNIMPLEMENTED if it's not implemented.
|
||||
// This field should be a fully-qualified type name. The format is
|
||||
// <package>.<type>
|
||||
string all_extension_numbers_of_type = 6;
|
||||
|
||||
// List the full names of registered services. The content will not be
|
||||
// checked.
|
||||
string list_services = 7;
|
||||
}
|
||||
}
|
||||
|
||||
// The type name and extension number sent by the client when requesting
|
||||
// file_containing_extension.
|
||||
message ExtensionRequest {
|
||||
// Fully-qualified type name. The format should be <package>.<type>
|
||||
string containing_type = 1;
|
||||
int32 extension_number = 2;
|
||||
}
|
||||
|
||||
// The message sent by the server to answer ServerReflectionInfo method.
|
||||
message ServerReflectionResponse {
|
||||
string valid_host = 1;
|
||||
ServerReflectionRequest original_request = 2;
|
||||
// The server sets one of the following fields according to the
|
||||
// message_request in the request.
|
||||
oneof message_response {
|
||||
// This message is used to answer file_by_filename, file_containing_symbol,
|
||||
// file_containing_extension requests with transitive dependencies.
|
||||
// As the repeated label is not allowed in oneof fields, we use a
|
||||
// FileDescriptorResponse message to encapsulate the repeated fields.
|
||||
// The reflection service is allowed to avoid sending FileDescriptorProtos
|
||||
// that were previously sent in response to earlier requests in the stream.
|
||||
FileDescriptorResponse file_descriptor_response = 4;
|
||||
|
||||
// This message is used to answer all_extension_numbers_of_type requests.
|
||||
ExtensionNumberResponse all_extension_numbers_response = 5;
|
||||
|
||||
// This message is used to answer list_services requests.
|
||||
ListServiceResponse list_services_response = 6;
|
||||
|
||||
// This message is used when an error occurs.
|
||||
ErrorResponse error_response = 7;
|
||||
}
|
||||
}
|
||||
|
||||
// Serialized FileDescriptorProto messages sent by the server answering
|
||||
// a file_by_filename, file_containing_symbol, or file_containing_extension
|
||||
// request.
|
||||
message FileDescriptorResponse {
|
||||
// Serialized FileDescriptorProto messages. We avoid taking a dependency on
|
||||
// descriptor.proto, which uses proto2 only features, by making them opaque
|
||||
// bytes instead.
|
||||
repeated bytes file_descriptor_proto = 1;
|
||||
}
|
||||
|
||||
// A list of extension numbers sent by the server answering
|
||||
// all_extension_numbers_of_type request.
|
||||
message ExtensionNumberResponse {
|
||||
// Full name of the base type, including the package name. The format
|
||||
// is <package>.<type>
|
||||
string base_type_name = 1;
|
||||
repeated int32 extension_number = 2;
|
||||
}
|
||||
|
||||
// A list of ServiceResponse sent by the server answering list_services request.
|
||||
message ListServiceResponse {
|
||||
// The information of each service may be expanded in the future, so we use
|
||||
// ServiceResponse message to encapsulate it.
|
||||
repeated ServiceResponse service = 1;
|
||||
}
|
||||
|
||||
// The information of a single service used by ListServiceResponse to answer
|
||||
// list_services request.
|
||||
message ServiceResponse {
|
||||
// Full name of a registered service, including its package name. The format
|
||||
// is <package>.<service>
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
// The error code and error message sent by the server when an error occurs.
|
||||
message ErrorResponse {
|
||||
// This field uses the error codes defined in grpc::StatusCode.
|
||||
int32 error_code = 1;
|
||||
string error_message = 2;
|
||||
}
|
139
vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection_grpc.pb.go
сгенерированный
поставляемый
Normal file
139
vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection_grpc.pb.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,139 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.1.0
|
||||
// - protoc v3.14.0
|
||||
// source: reflection/grpc_reflection_v1alpha/reflection.proto
|
||||
|
||||
package grpc_reflection_v1alpha
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// ServerReflectionClient is the client API for ServerReflection 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.
|
||||
type ServerReflectionClient interface {
|
||||
// The reflection service is structured as a bidirectional stream, ensuring
|
||||
// all related requests go to a single server.
|
||||
ServerReflectionInfo(ctx context.Context, opts ...grpc.CallOption) (ServerReflection_ServerReflectionInfoClient, error)
|
||||
}
|
||||
|
||||
type serverReflectionClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewServerReflectionClient(cc grpc.ClientConnInterface) ServerReflectionClient {
|
||||
return &serverReflectionClient{cc}
|
||||
}
|
||||
|
||||
func (c *serverReflectionClient) ServerReflectionInfo(ctx context.Context, opts ...grpc.CallOption) (ServerReflection_ServerReflectionInfoClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &ServerReflection_ServiceDesc.Streams[0], "/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo", opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &serverReflectionServerReflectionInfoClient{stream}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type ServerReflection_ServerReflectionInfoClient interface {
|
||||
Send(*ServerReflectionRequest) error
|
||||
Recv() (*ServerReflectionResponse, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
type serverReflectionServerReflectionInfoClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *serverReflectionServerReflectionInfoClient) Send(m *ServerReflectionRequest) error {
|
||||
return x.ClientStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func (x *serverReflectionServerReflectionInfoClient) Recv() (*ServerReflectionResponse, error) {
|
||||
m := new(ServerReflectionResponse)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// ServerReflectionServer is the server API for ServerReflection service.
|
||||
// All implementations should embed UnimplementedServerReflectionServer
|
||||
// for forward compatibility
|
||||
type ServerReflectionServer interface {
|
||||
// The reflection service is structured as a bidirectional stream, ensuring
|
||||
// all related requests go to a single server.
|
||||
ServerReflectionInfo(ServerReflection_ServerReflectionInfoServer) error
|
||||
}
|
||||
|
||||
// UnimplementedServerReflectionServer should be embedded to have forward compatible implementations.
|
||||
type UnimplementedServerReflectionServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedServerReflectionServer) ServerReflectionInfo(ServerReflection_ServerReflectionInfoServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method ServerReflectionInfo not implemented")
|
||||
}
|
||||
|
||||
// UnsafeServerReflectionServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to ServerReflectionServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeServerReflectionServer interface {
|
||||
mustEmbedUnimplementedServerReflectionServer()
|
||||
}
|
||||
|
||||
func RegisterServerReflectionServer(s grpc.ServiceRegistrar, srv ServerReflectionServer) {
|
||||
s.RegisterService(&ServerReflection_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _ServerReflection_ServerReflectionInfo_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
return srv.(ServerReflectionServer).ServerReflectionInfo(&serverReflectionServerReflectionInfoServer{stream})
|
||||
}
|
||||
|
||||
type ServerReflection_ServerReflectionInfoServer interface {
|
||||
Send(*ServerReflectionResponse) error
|
||||
Recv() (*ServerReflectionRequest, error)
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type serverReflectionServerReflectionInfoServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *serverReflectionServerReflectionInfoServer) Send(m *ServerReflectionResponse) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func (x *serverReflectionServerReflectionInfoServer) Recv() (*ServerReflectionRequest, error) {
|
||||
m := new(ServerReflectionRequest)
|
||||
if err := x.ServerStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// ServerReflection_ServiceDesc is the grpc.ServiceDesc for ServerReflection service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var ServerReflection_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "grpc.reflection.v1alpha.ServerReflection",
|
||||
HandlerType: (*ServerReflectionServer)(nil),
|
||||
Methods: []grpc.MethodDesc{},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "ServerReflectionInfo",
|
||||
Handler: _ServerReflection_ServerReflectionInfo_Handler,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "reflection/grpc_reflection_v1alpha/reflection.proto",
|
||||
}
|
496
vendor/google.golang.org/grpc/reflection/serverreflection.go
сгенерированный
поставляемый
Normal file
496
vendor/google.golang.org/grpc/reflection/serverreflection.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,496 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2016 gRPC authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
Package reflection implements server reflection service.
|
||||
|
||||
The service implemented is defined in:
|
||||
https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto.
|
||||
|
||||
To register server reflection on a gRPC server:
|
||||
import "google.golang.org/grpc/reflection"
|
||||
|
||||
s := grpc.NewServer()
|
||||
pb.RegisterYourOwnServer(s, &server{})
|
||||
|
||||
// Register reflection service on gRPC server.
|
||||
reflection.Register(s)
|
||||
|
||||
s.Serve(lis)
|
||||
|
||||
*/
|
||||
package reflection // import "google.golang.org/grpc/reflection"
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"reflect"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
dpb "github.com/golang/protobuf/protoc-gen-go/descriptor"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
rpb "google.golang.org/grpc/reflection/grpc_reflection_v1alpha"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// GRPCServer is the interface provided by a gRPC server. It is implemented by
|
||||
// *grpc.Server, but could also be implemented by other concrete types. It acts
|
||||
// as a registry, for accumulating the services exposed by the server.
|
||||
type GRPCServer interface {
|
||||
grpc.ServiceRegistrar
|
||||
GetServiceInfo() map[string]grpc.ServiceInfo
|
||||
}
|
||||
|
||||
var _ GRPCServer = (*grpc.Server)(nil)
|
||||
|
||||
type serverReflectionServer struct {
|
||||
rpb.UnimplementedServerReflectionServer
|
||||
s GRPCServer
|
||||
|
||||
initSymbols sync.Once
|
||||
serviceNames []string
|
||||
symbols map[string]*dpb.FileDescriptorProto // map of fully-qualified names to files
|
||||
}
|
||||
|
||||
// Register registers the server reflection service on the given gRPC server.
|
||||
func Register(s GRPCServer) {
|
||||
rpb.RegisterServerReflectionServer(s, &serverReflectionServer{
|
||||
s: s,
|
||||
})
|
||||
}
|
||||
|
||||
// protoMessage is used for type assertion on proto messages.
|
||||
// Generated proto message implements function Descriptor(), but Descriptor()
|
||||
// is not part of interface proto.Message. This interface is needed to
|
||||
// call Descriptor().
|
||||
type protoMessage interface {
|
||||
Descriptor() ([]byte, []int)
|
||||
}
|
||||
|
||||
func (s *serverReflectionServer) getSymbols() (svcNames []string, symbolIndex map[string]*dpb.FileDescriptorProto) {
|
||||
s.initSymbols.Do(func() {
|
||||
serviceInfo := s.s.GetServiceInfo()
|
||||
|
||||
s.symbols = map[string]*dpb.FileDescriptorProto{}
|
||||
s.serviceNames = make([]string, 0, len(serviceInfo))
|
||||
processed := map[string]struct{}{}
|
||||
for svc, info := range serviceInfo {
|
||||
s.serviceNames = append(s.serviceNames, svc)
|
||||
fdenc, ok := parseMetadata(info.Metadata)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
fd, err := decodeFileDesc(fdenc)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
s.processFile(fd, processed)
|
||||
}
|
||||
sort.Strings(s.serviceNames)
|
||||
})
|
||||
|
||||
return s.serviceNames, s.symbols
|
||||
}
|
||||
|
||||
func (s *serverReflectionServer) processFile(fd *dpb.FileDescriptorProto, processed map[string]struct{}) {
|
||||
filename := fd.GetName()
|
||||
if _, ok := processed[filename]; ok {
|
||||
return
|
||||
}
|
||||
processed[filename] = struct{}{}
|
||||
|
||||
prefix := fd.GetPackage()
|
||||
|
||||
for _, msg := range fd.MessageType {
|
||||
s.processMessage(fd, prefix, msg)
|
||||
}
|
||||
for _, en := range fd.EnumType {
|
||||
s.processEnum(fd, prefix, en)
|
||||
}
|
||||
for _, ext := range fd.Extension {
|
||||
s.processField(fd, prefix, ext)
|
||||
}
|
||||
for _, svc := range fd.Service {
|
||||
svcName := fqn(prefix, svc.GetName())
|
||||
s.symbols[svcName] = fd
|
||||
for _, meth := range svc.Method {
|
||||
name := fqn(svcName, meth.GetName())
|
||||
s.symbols[name] = fd
|
||||
}
|
||||
}
|
||||
|
||||
for _, dep := range fd.Dependency {
|
||||
fdenc := proto.FileDescriptor(dep)
|
||||
fdDep, err := decodeFileDesc(fdenc)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
s.processFile(fdDep, processed)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *serverReflectionServer) processMessage(fd *dpb.FileDescriptorProto, prefix string, msg *dpb.DescriptorProto) {
|
||||
msgName := fqn(prefix, msg.GetName())
|
||||
s.symbols[msgName] = fd
|
||||
|
||||
for _, nested := range msg.NestedType {
|
||||
s.processMessage(fd, msgName, nested)
|
||||
}
|
||||
for _, en := range msg.EnumType {
|
||||
s.processEnum(fd, msgName, en)
|
||||
}
|
||||
for _, ext := range msg.Extension {
|
||||
s.processField(fd, msgName, ext)
|
||||
}
|
||||
for _, fld := range msg.Field {
|
||||
s.processField(fd, msgName, fld)
|
||||
}
|
||||
for _, oneof := range msg.OneofDecl {
|
||||
oneofName := fqn(msgName, oneof.GetName())
|
||||
s.symbols[oneofName] = fd
|
||||
}
|
||||
}
|
||||
|
||||
func (s *serverReflectionServer) processEnum(fd *dpb.FileDescriptorProto, prefix string, en *dpb.EnumDescriptorProto) {
|
||||
enName := fqn(prefix, en.GetName())
|
||||
s.symbols[enName] = fd
|
||||
|
||||
for _, val := range en.Value {
|
||||
valName := fqn(enName, val.GetName())
|
||||
s.symbols[valName] = fd
|
||||
}
|
||||
}
|
||||
|
||||
func (s *serverReflectionServer) processField(fd *dpb.FileDescriptorProto, prefix string, fld *dpb.FieldDescriptorProto) {
|
||||
fldName := fqn(prefix, fld.GetName())
|
||||
s.symbols[fldName] = fd
|
||||
}
|
||||
|
||||
func fqn(prefix, name string) string {
|
||||
if prefix == "" {
|
||||
return name
|
||||
}
|
||||
return prefix + "." + name
|
||||
}
|
||||
|
||||
// fileDescForType gets the file descriptor for the given type.
|
||||
// The given type should be a proto message.
|
||||
func (s *serverReflectionServer) fileDescForType(st reflect.Type) (*dpb.FileDescriptorProto, error) {
|
||||
m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(protoMessage)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to create message from type: %v", st)
|
||||
}
|
||||
enc, _ := m.Descriptor()
|
||||
|
||||
return decodeFileDesc(enc)
|
||||
}
|
||||
|
||||
// decodeFileDesc does decompression and unmarshalling on the given
|
||||
// file descriptor byte slice.
|
||||
func decodeFileDesc(enc []byte) (*dpb.FileDescriptorProto, error) {
|
||||
raw, err := decompress(enc)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to decompress enc: %v", err)
|
||||
}
|
||||
|
||||
fd := new(dpb.FileDescriptorProto)
|
||||
if err := proto.Unmarshal(raw, fd); err != nil {
|
||||
return nil, fmt.Errorf("bad descriptor: %v", err)
|
||||
}
|
||||
return fd, nil
|
||||
}
|
||||
|
||||
// decompress does gzip decompression.
|
||||
func decompress(b []byte) ([]byte, error) {
|
||||
r, err := gzip.NewReader(bytes.NewReader(b))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("bad gzipped descriptor: %v", err)
|
||||
}
|
||||
out, err := ioutil.ReadAll(r)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("bad gzipped descriptor: %v", err)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func typeForName(name string) (reflect.Type, error) {
|
||||
pt := proto.MessageType(name)
|
||||
if pt == nil {
|
||||
return nil, fmt.Errorf("unknown type: %q", name)
|
||||
}
|
||||
st := pt.Elem()
|
||||
|
||||
return st, nil
|
||||
}
|
||||
|
||||
func fileDescContainingExtension(st reflect.Type, ext int32) (*dpb.FileDescriptorProto, error) {
|
||||
m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(proto.Message)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to create message from type: %v", st)
|
||||
}
|
||||
|
||||
var extDesc *proto.ExtensionDesc
|
||||
for id, desc := range proto.RegisteredExtensions(m) {
|
||||
if id == ext {
|
||||
extDesc = desc
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if extDesc == nil {
|
||||
return nil, fmt.Errorf("failed to find registered extension for extension number %v", ext)
|
||||
}
|
||||
|
||||
return decodeFileDesc(proto.FileDescriptor(extDesc.Filename))
|
||||
}
|
||||
|
||||
func (s *serverReflectionServer) allExtensionNumbersForType(st reflect.Type) ([]int32, error) {
|
||||
m, ok := reflect.Zero(reflect.PtrTo(st)).Interface().(proto.Message)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to create message from type: %v", st)
|
||||
}
|
||||
|
||||
exts := proto.RegisteredExtensions(m)
|
||||
out := make([]int32, 0, len(exts))
|
||||
for id := range exts {
|
||||
out = append(out, id)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// fileDescWithDependencies returns a slice of serialized fileDescriptors in
|
||||
// wire format ([]byte). The fileDescriptors will include fd and all the
|
||||
// transitive dependencies of fd with names not in sentFileDescriptors.
|
||||
func fileDescWithDependencies(fd *dpb.FileDescriptorProto, sentFileDescriptors map[string]bool) ([][]byte, error) {
|
||||
r := [][]byte{}
|
||||
queue := []*dpb.FileDescriptorProto{fd}
|
||||
for len(queue) > 0 {
|
||||
currentfd := queue[0]
|
||||
queue = queue[1:]
|
||||
if sent := sentFileDescriptors[currentfd.GetName()]; len(r) == 0 || !sent {
|
||||
sentFileDescriptors[currentfd.GetName()] = true
|
||||
currentfdEncoded, err := proto.Marshal(currentfd)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r = append(r, currentfdEncoded)
|
||||
}
|
||||
for _, dep := range currentfd.Dependency {
|
||||
fdenc := proto.FileDescriptor(dep)
|
||||
fdDep, err := decodeFileDesc(fdenc)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
queue = append(queue, fdDep)
|
||||
}
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
// fileDescEncodingByFilename finds the file descriptor for given filename,
|
||||
// finds all of its previously unsent transitive dependencies, does marshalling
|
||||
// on them, and returns the marshalled result.
|
||||
func (s *serverReflectionServer) fileDescEncodingByFilename(name string, sentFileDescriptors map[string]bool) ([][]byte, error) {
|
||||
enc := proto.FileDescriptor(name)
|
||||
if enc == nil {
|
||||
return nil, fmt.Errorf("unknown file: %v", name)
|
||||
}
|
||||
fd, err := decodeFileDesc(enc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return fileDescWithDependencies(fd, sentFileDescriptors)
|
||||
}
|
||||
|
||||
// parseMetadata finds the file descriptor bytes specified meta.
|
||||
// For SupportPackageIsVersion4, m is the name of the proto file, we
|
||||
// call proto.FileDescriptor to get the byte slice.
|
||||
// For SupportPackageIsVersion3, m is a byte slice itself.
|
||||
func parseMetadata(meta interface{}) ([]byte, bool) {
|
||||
// Check if meta is the file name.
|
||||
if fileNameForMeta, ok := meta.(string); ok {
|
||||
return proto.FileDescriptor(fileNameForMeta), true
|
||||
}
|
||||
|
||||
// Check if meta is the byte slice.
|
||||
if enc, ok := meta.([]byte); ok {
|
||||
return enc, true
|
||||
}
|
||||
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// fileDescEncodingContainingSymbol finds the file descriptor containing the
|
||||
// given symbol, finds all of its previously unsent transitive dependencies,
|
||||
// does marshalling on them, and returns the marshalled result. The given symbol
|
||||
// can be a type, a service or a method.
|
||||
func (s *serverReflectionServer) fileDescEncodingContainingSymbol(name string, sentFileDescriptors map[string]bool) ([][]byte, error) {
|
||||
_, symbols := s.getSymbols()
|
||||
fd := symbols[name]
|
||||
if fd == nil {
|
||||
// Check if it's a type name that was not present in the
|
||||
// transitive dependencies of the registered services.
|
||||
if st, err := typeForName(name); err == nil {
|
||||
fd, err = s.fileDescForType(st)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if fd == nil {
|
||||
return nil, fmt.Errorf("unknown symbol: %v", name)
|
||||
}
|
||||
|
||||
return fileDescWithDependencies(fd, sentFileDescriptors)
|
||||
}
|
||||
|
||||
// fileDescEncodingContainingExtension finds the file descriptor containing
|
||||
// given extension, finds all of its previously unsent transitive dependencies,
|
||||
// does marshalling on them, and returns the marshalled result.
|
||||
func (s *serverReflectionServer) fileDescEncodingContainingExtension(typeName string, extNum int32, sentFileDescriptors map[string]bool) ([][]byte, error) {
|
||||
st, err := typeForName(typeName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fd, err := fileDescContainingExtension(st, extNum)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return fileDescWithDependencies(fd, sentFileDescriptors)
|
||||
}
|
||||
|
||||
// allExtensionNumbersForTypeName returns all extension numbers for the given type.
|
||||
func (s *serverReflectionServer) allExtensionNumbersForTypeName(name string) ([]int32, error) {
|
||||
st, err := typeForName(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
extNums, err := s.allExtensionNumbersForType(st)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return extNums, nil
|
||||
}
|
||||
|
||||
// ServerReflectionInfo is the reflection service handler.
|
||||
func (s *serverReflectionServer) ServerReflectionInfo(stream rpb.ServerReflection_ServerReflectionInfoServer) error {
|
||||
sentFileDescriptors := make(map[string]bool)
|
||||
for {
|
||||
in, err := stream.Recv()
|
||||
if err == io.EOF {
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out := &rpb.ServerReflectionResponse{
|
||||
ValidHost: in.Host,
|
||||
OriginalRequest: in,
|
||||
}
|
||||
switch req := in.MessageRequest.(type) {
|
||||
case *rpb.ServerReflectionRequest_FileByFilename:
|
||||
b, err := s.fileDescEncodingByFilename(req.FileByFilename, sentFileDescriptors)
|
||||
if err != nil {
|
||||
out.MessageResponse = &rpb.ServerReflectionResponse_ErrorResponse{
|
||||
ErrorResponse: &rpb.ErrorResponse{
|
||||
ErrorCode: int32(codes.NotFound),
|
||||
ErrorMessage: err.Error(),
|
||||
},
|
||||
}
|
||||
} else {
|
||||
out.MessageResponse = &rpb.ServerReflectionResponse_FileDescriptorResponse{
|
||||
FileDescriptorResponse: &rpb.FileDescriptorResponse{FileDescriptorProto: b},
|
||||
}
|
||||
}
|
||||
case *rpb.ServerReflectionRequest_FileContainingSymbol:
|
||||
b, err := s.fileDescEncodingContainingSymbol(req.FileContainingSymbol, sentFileDescriptors)
|
||||
if err != nil {
|
||||
out.MessageResponse = &rpb.ServerReflectionResponse_ErrorResponse{
|
||||
ErrorResponse: &rpb.ErrorResponse{
|
||||
ErrorCode: int32(codes.NotFound),
|
||||
ErrorMessage: err.Error(),
|
||||
},
|
||||
}
|
||||
} else {
|
||||
out.MessageResponse = &rpb.ServerReflectionResponse_FileDescriptorResponse{
|
||||
FileDescriptorResponse: &rpb.FileDescriptorResponse{FileDescriptorProto: b},
|
||||
}
|
||||
}
|
||||
case *rpb.ServerReflectionRequest_FileContainingExtension:
|
||||
typeName := req.FileContainingExtension.ContainingType
|
||||
extNum := req.FileContainingExtension.ExtensionNumber
|
||||
b, err := s.fileDescEncodingContainingExtension(typeName, extNum, sentFileDescriptors)
|
||||
if err != nil {
|
||||
out.MessageResponse = &rpb.ServerReflectionResponse_ErrorResponse{
|
||||
ErrorResponse: &rpb.ErrorResponse{
|
||||
ErrorCode: int32(codes.NotFound),
|
||||
ErrorMessage: err.Error(),
|
||||
},
|
||||
}
|
||||
} else {
|
||||
out.MessageResponse = &rpb.ServerReflectionResponse_FileDescriptorResponse{
|
||||
FileDescriptorResponse: &rpb.FileDescriptorResponse{FileDescriptorProto: b},
|
||||
}
|
||||
}
|
||||
case *rpb.ServerReflectionRequest_AllExtensionNumbersOfType:
|
||||
extNums, err := s.allExtensionNumbersForTypeName(req.AllExtensionNumbersOfType)
|
||||
if err != nil {
|
||||
out.MessageResponse = &rpb.ServerReflectionResponse_ErrorResponse{
|
||||
ErrorResponse: &rpb.ErrorResponse{
|
||||
ErrorCode: int32(codes.NotFound),
|
||||
ErrorMessage: err.Error(),
|
||||
},
|
||||
}
|
||||
} else {
|
||||
out.MessageResponse = &rpb.ServerReflectionResponse_AllExtensionNumbersResponse{
|
||||
AllExtensionNumbersResponse: &rpb.ExtensionNumberResponse{
|
||||
BaseTypeName: req.AllExtensionNumbersOfType,
|
||||
ExtensionNumber: extNums,
|
||||
},
|
||||
}
|
||||
}
|
||||
case *rpb.ServerReflectionRequest_ListServices:
|
||||
svcNames, _ := s.getSymbols()
|
||||
serviceResponses := make([]*rpb.ServiceResponse, len(svcNames))
|
||||
for i, n := range svcNames {
|
||||
serviceResponses[i] = &rpb.ServiceResponse{
|
||||
Name: n,
|
||||
}
|
||||
}
|
||||
out.MessageResponse = &rpb.ServerReflectionResponse_ListServicesResponse{
|
||||
ListServicesResponse: &rpb.ListServiceResponse{
|
||||
Service: serviceResponses,
|
||||
},
|
||||
}
|
||||
default:
|
||||
return status.Errorf(codes.InvalidArgument, "invalid MessageRequest: %v", in.MessageRequest)
|
||||
}
|
||||
|
||||
if err := stream.Send(out); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
810
vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go
сгенерированный
поставляемый
Normal file
810
vendor/google.golang.org/protobuf/types/known/structpb/struct.pb.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,810 @@
|
|||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
// https://developers.google.com/protocol-buffers/
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: google/protobuf/struct.proto
|
||||
|
||||
// Package structpb contains generated types for google/protobuf/struct.proto.
|
||||
//
|
||||
// The messages (i.e., Value, Struct, and ListValue) defined in struct.proto are
|
||||
// used to represent arbitrary JSON. The Value message represents a JSON value,
|
||||
// the Struct message represents a JSON object, and the ListValue message
|
||||
// represents a JSON array. See https://json.org for more information.
|
||||
//
|
||||
// The Value, Struct, and ListValue types have generated MarshalJSON and
|
||||
// UnmarshalJSON methods such that they serialize JSON equivalent to what the
|
||||
// messages themselves represent. Use of these types with the
|
||||
// "google.golang.org/protobuf/encoding/protojson" package
|
||||
// ensures that they will be serialized as their JSON equivalent.
|
||||
//
|
||||
//
|
||||
// Conversion to and from a Go interface
|
||||
//
|
||||
// The standard Go "encoding/json" package has functionality to serialize
|
||||
// arbitrary types to a large degree. The Value.AsInterface, Struct.AsMap, and
|
||||
// ListValue.AsSlice methods can convert the protobuf message representation into
|
||||
// a form represented by interface{}, map[string]interface{}, and []interface{}.
|
||||
// This form can be used with other packages that operate on such data structures
|
||||
// and also directly with the standard json package.
|
||||
//
|
||||
// In order to convert the interface{}, map[string]interface{}, and []interface{}
|
||||
// forms back as Value, Struct, and ListValue messages, use the NewStruct,
|
||||
// NewList, and NewValue constructor functions.
|
||||
//
|
||||
//
|
||||
// Example usage
|
||||
//
|
||||
// Consider the following example JSON object:
|
||||
//
|
||||
// {
|
||||
// "firstName": "John",
|
||||
// "lastName": "Smith",
|
||||
// "isAlive": true,
|
||||
// "age": 27,
|
||||
// "address": {
|
||||
// "streetAddress": "21 2nd Street",
|
||||
// "city": "New York",
|
||||
// "state": "NY",
|
||||
// "postalCode": "10021-3100"
|
||||
// },
|
||||
// "phoneNumbers": [
|
||||
// {
|
||||
// "type": "home",
|
||||
// "number": "212 555-1234"
|
||||
// },
|
||||
// {
|
||||
// "type": "office",
|
||||
// "number": "646 555-4567"
|
||||
// }
|
||||
// ],
|
||||
// "children": [],
|
||||
// "spouse": null
|
||||
// }
|
||||
//
|
||||
// To construct a Value message representing the above JSON object:
|
||||
//
|
||||
// m, err := structpb.NewValue(map[string]interface{}{
|
||||
// "firstName": "John",
|
||||
// "lastName": "Smith",
|
||||
// "isAlive": true,
|
||||
// "age": 27,
|
||||
// "address": map[string]interface{}{
|
||||
// "streetAddress": "21 2nd Street",
|
||||
// "city": "New York",
|
||||
// "state": "NY",
|
||||
// "postalCode": "10021-3100",
|
||||
// },
|
||||
// "phoneNumbers": []interface{}{
|
||||
// map[string]interface{}{
|
||||
// "type": "home",
|
||||
// "number": "212 555-1234",
|
||||
// },
|
||||
// map[string]interface{}{
|
||||
// "type": "office",
|
||||
// "number": "646 555-4567",
|
||||
// },
|
||||
// },
|
||||
// "children": []interface{}{},
|
||||
// "spouse": nil,
|
||||
// })
|
||||
// if err != nil {
|
||||
// ... // handle error
|
||||
// }
|
||||
// ... // make use of m as a *structpb.Value
|
||||
//
|
||||
package structpb
|
||||
|
||||
import (
|
||||
base64 "encoding/base64"
|
||||
protojson "google.golang.org/protobuf/encoding/protojson"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
math "math"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
utf8 "unicode/utf8"
|
||||
)
|
||||
|
||||
// `NullValue` is a singleton enumeration to represent the null value for the
|
||||
// `Value` type union.
|
||||
//
|
||||
// The JSON representation for `NullValue` is JSON `null`.
|
||||
type NullValue int32
|
||||
|
||||
const (
|
||||
// Null value.
|
||||
NullValue_NULL_VALUE NullValue = 0
|
||||
)
|
||||
|
||||
// Enum value maps for NullValue.
|
||||
var (
|
||||
NullValue_name = map[int32]string{
|
||||
0: "NULL_VALUE",
|
||||
}
|
||||
NullValue_value = map[string]int32{
|
||||
"NULL_VALUE": 0,
|
||||
}
|
||||
)
|
||||
|
||||
func (x NullValue) Enum() *NullValue {
|
||||
p := new(NullValue)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x NullValue) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (NullValue) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_google_protobuf_struct_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (NullValue) Type() protoreflect.EnumType {
|
||||
return &file_google_protobuf_struct_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x NullValue) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use NullValue.Descriptor instead.
|
||||
func (NullValue) EnumDescriptor() ([]byte, []int) {
|
||||
return file_google_protobuf_struct_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
// `Struct` represents a structured data value, consisting of fields
|
||||
// which map to dynamically typed values. In some languages, `Struct`
|
||||
// might be supported by a native representation. For example, in
|
||||
// scripting languages like JS a struct is represented as an
|
||||
// object. The details of that representation are described together
|
||||
// with the proto support for the language.
|
||||
//
|
||||
// The JSON representation for `Struct` is JSON object.
|
||||
type Struct struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Unordered map of dynamically typed values.
|
||||
Fields map[string]*Value `protobuf:"bytes,1,rep,name=fields,proto3" json:"fields,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
}
|
||||
|
||||
// NewStruct constructs a Struct from a general-purpose Go map.
|
||||
// The map keys must be valid UTF-8.
|
||||
// The map values are converted using NewValue.
|
||||
func NewStruct(v map[string]interface{}) (*Struct, error) {
|
||||
x := &Struct{Fields: make(map[string]*Value, len(v))}
|
||||
for k, v := range v {
|
||||
if !utf8.ValidString(k) {
|
||||
return nil, protoimpl.X.NewError("invalid UTF-8 in string: %q", k)
|
||||
}
|
||||
var err error
|
||||
x.Fields[k], err = NewValue(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
// AsMap converts x to a general-purpose Go map.
|
||||
// The map values are converted by calling Value.AsInterface.
|
||||
func (x *Struct) AsMap() map[string]interface{} {
|
||||
vs := make(map[string]interface{})
|
||||
for k, v := range x.GetFields() {
|
||||
vs[k] = v.AsInterface()
|
||||
}
|
||||
return vs
|
||||
}
|
||||
|
||||
func (x *Struct) MarshalJSON() ([]byte, error) {
|
||||
return protojson.Marshal(x)
|
||||
}
|
||||
|
||||
func (x *Struct) UnmarshalJSON(b []byte) error {
|
||||
return protojson.Unmarshal(b, x)
|
||||
}
|
||||
|
||||
func (x *Struct) Reset() {
|
||||
*x = Struct{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_google_protobuf_struct_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Struct) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Struct) ProtoMessage() {}
|
||||
|
||||
func (x *Struct) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_google_protobuf_struct_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Struct.ProtoReflect.Descriptor instead.
|
||||
func (*Struct) Descriptor() ([]byte, []int) {
|
||||
return file_google_protobuf_struct_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Struct) GetFields() map[string]*Value {
|
||||
if x != nil {
|
||||
return x.Fields
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// `Value` represents a dynamically typed value which can be either
|
||||
// null, a number, a string, a boolean, a recursive struct value, or a
|
||||
// list of values. A producer of value is expected to set one of that
|
||||
// variants, absence of any variant indicates an error.
|
||||
//
|
||||
// The JSON representation for `Value` is JSON value.
|
||||
type Value struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// The kind of value.
|
||||
//
|
||||
// Types that are assignable to Kind:
|
||||
// *Value_NullValue
|
||||
// *Value_NumberValue
|
||||
// *Value_StringValue
|
||||
// *Value_BoolValue
|
||||
// *Value_StructValue
|
||||
// *Value_ListValue
|
||||
Kind isValue_Kind `protobuf_oneof:"kind"`
|
||||
}
|
||||
|
||||
// NewValue constructs a Value from a general-purpose Go interface.
|
||||
//
|
||||
// ╔════════════════════════╤════════════════════════════════════════════╗
|
||||
// ║ Go type │ Conversion ║
|
||||
// ╠════════════════════════╪════════════════════════════════════════════╣
|
||||
// ║ nil │ stored as NullValue ║
|
||||
// ║ bool │ stored as BoolValue ║
|
||||
// ║ int, int32, int64 │ stored as NumberValue ║
|
||||
// ║ uint, uint32, uint64 │ stored as NumberValue ║
|
||||
// ║ float32, float64 │ stored as NumberValue ║
|
||||
// ║ string │ stored as StringValue; must be valid UTF-8 ║
|
||||
// ║ []byte │ stored as StringValue; base64-encoded ║
|
||||
// ║ map[string]interface{} │ stored as StructValue ║
|
||||
// ║ []interface{} │ stored as ListValue ║
|
||||
// ╚════════════════════════╧════════════════════════════════════════════╝
|
||||
//
|
||||
// When converting an int64 or uint64 to a NumberValue, numeric precision loss
|
||||
// is possible since they are stored as a float64.
|
||||
func NewValue(v interface{}) (*Value, error) {
|
||||
switch v := v.(type) {
|
||||
case nil:
|
||||
return NewNullValue(), nil
|
||||
case bool:
|
||||
return NewBoolValue(v), nil
|
||||
case int:
|
||||
return NewNumberValue(float64(v)), nil
|
||||
case int32:
|
||||
return NewNumberValue(float64(v)), nil
|
||||
case int64:
|
||||
return NewNumberValue(float64(v)), nil
|
||||
case uint:
|
||||
return NewNumberValue(float64(v)), nil
|
||||
case uint32:
|
||||
return NewNumberValue(float64(v)), nil
|
||||
case uint64:
|
||||
return NewNumberValue(float64(v)), nil
|
||||
case float32:
|
||||
return NewNumberValue(float64(v)), nil
|
||||
case float64:
|
||||
return NewNumberValue(float64(v)), nil
|
||||
case string:
|
||||
if !utf8.ValidString(v) {
|
||||
return nil, protoimpl.X.NewError("invalid UTF-8 in string: %q", v)
|
||||
}
|
||||
return NewStringValue(v), nil
|
||||
case []byte:
|
||||
s := base64.StdEncoding.EncodeToString(v)
|
||||
return NewStringValue(s), nil
|
||||
case map[string]interface{}:
|
||||
v2, err := NewStruct(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewStructValue(v2), nil
|
||||
case []interface{}:
|
||||
v2, err := NewList(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewListValue(v2), nil
|
||||
default:
|
||||
return nil, protoimpl.X.NewError("invalid type: %T", v)
|
||||
}
|
||||
}
|
||||
|
||||
// NewNullValue constructs a new null Value.
|
||||
func NewNullValue() *Value {
|
||||
return &Value{Kind: &Value_NullValue{NullValue: NullValue_NULL_VALUE}}
|
||||
}
|
||||
|
||||
// NewBoolValue constructs a new boolean Value.
|
||||
func NewBoolValue(v bool) *Value {
|
||||
return &Value{Kind: &Value_BoolValue{BoolValue: v}}
|
||||
}
|
||||
|
||||
// NewNumberValue constructs a new number Value.
|
||||
func NewNumberValue(v float64) *Value {
|
||||
return &Value{Kind: &Value_NumberValue{NumberValue: v}}
|
||||
}
|
||||
|
||||
// NewStringValue constructs a new string Value.
|
||||
func NewStringValue(v string) *Value {
|
||||
return &Value{Kind: &Value_StringValue{StringValue: v}}
|
||||
}
|
||||
|
||||
// NewStructValue constructs a new struct Value.
|
||||
func NewStructValue(v *Struct) *Value {
|
||||
return &Value{Kind: &Value_StructValue{StructValue: v}}
|
||||
}
|
||||
|
||||
// NewListValue constructs a new list Value.
|
||||
func NewListValue(v *ListValue) *Value {
|
||||
return &Value{Kind: &Value_ListValue{ListValue: v}}
|
||||
}
|
||||
|
||||
// AsInterface converts x to a general-purpose Go interface.
|
||||
//
|
||||
// Calling Value.MarshalJSON and "encoding/json".Marshal on this output produce
|
||||
// semantically equivalent JSON (assuming no errors occur).
|
||||
//
|
||||
// Floating-point values (i.e., "NaN", "Infinity", and "-Infinity") are
|
||||
// converted as strings to remain compatible with MarshalJSON.
|
||||
func (x *Value) AsInterface() interface{} {
|
||||
switch v := x.GetKind().(type) {
|
||||
case *Value_NumberValue:
|
||||
if v != nil {
|
||||
switch {
|
||||
case math.IsNaN(v.NumberValue):
|
||||
return "NaN"
|
||||
case math.IsInf(v.NumberValue, +1):
|
||||
return "Infinity"
|
||||
case math.IsInf(v.NumberValue, -1):
|
||||
return "-Infinity"
|
||||
default:
|
||||
return v.NumberValue
|
||||
}
|
||||
}
|
||||
case *Value_StringValue:
|
||||
if v != nil {
|
||||
return v.StringValue
|
||||
}
|
||||
case *Value_BoolValue:
|
||||
if v != nil {
|
||||
return v.BoolValue
|
||||
}
|
||||
case *Value_StructValue:
|
||||
if v != nil {
|
||||
return v.StructValue.AsMap()
|
||||
}
|
||||
case *Value_ListValue:
|
||||
if v != nil {
|
||||
return v.ListValue.AsSlice()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Value) MarshalJSON() ([]byte, error) {
|
||||
return protojson.Marshal(x)
|
||||
}
|
||||
|
||||
func (x *Value) UnmarshalJSON(b []byte) error {
|
||||
return protojson.Unmarshal(b, x)
|
||||
}
|
||||
|
||||
func (x *Value) Reset() {
|
||||
*x = Value{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_google_protobuf_struct_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Value) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Value) ProtoMessage() {}
|
||||
|
||||
func (x *Value) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_google_protobuf_struct_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Value.ProtoReflect.Descriptor instead.
|
||||
func (*Value) Descriptor() ([]byte, []int) {
|
||||
return file_google_protobuf_struct_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (m *Value) GetKind() isValue_Kind {
|
||||
if m != nil {
|
||||
return m.Kind
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Value) GetNullValue() NullValue {
|
||||
if x, ok := x.GetKind().(*Value_NullValue); ok {
|
||||
return x.NullValue
|
||||
}
|
||||
return NullValue_NULL_VALUE
|
||||
}
|
||||
|
||||
func (x *Value) GetNumberValue() float64 {
|
||||
if x, ok := x.GetKind().(*Value_NumberValue); ok {
|
||||
return x.NumberValue
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Value) GetStringValue() string {
|
||||
if x, ok := x.GetKind().(*Value_StringValue); ok {
|
||||
return x.StringValue
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Value) GetBoolValue() bool {
|
||||
if x, ok := x.GetKind().(*Value_BoolValue); ok {
|
||||
return x.BoolValue
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *Value) GetStructValue() *Struct {
|
||||
if x, ok := x.GetKind().(*Value_StructValue); ok {
|
||||
return x.StructValue
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Value) GetListValue() *ListValue {
|
||||
if x, ok := x.GetKind().(*Value_ListValue); ok {
|
||||
return x.ListValue
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type isValue_Kind interface {
|
||||
isValue_Kind()
|
||||
}
|
||||
|
||||
type Value_NullValue struct {
|
||||
// Represents a null value.
|
||||
NullValue NullValue `protobuf:"varint,1,opt,name=null_value,json=nullValue,proto3,enum=google.protobuf.NullValue,oneof"`
|
||||
}
|
||||
|
||||
type Value_NumberValue struct {
|
||||
// Represents a double value.
|
||||
NumberValue float64 `protobuf:"fixed64,2,opt,name=number_value,json=numberValue,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Value_StringValue struct {
|
||||
// Represents a string value.
|
||||
StringValue string `protobuf:"bytes,3,opt,name=string_value,json=stringValue,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Value_BoolValue struct {
|
||||
// Represents a boolean value.
|
||||
BoolValue bool `protobuf:"varint,4,opt,name=bool_value,json=boolValue,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Value_StructValue struct {
|
||||
// Represents a structured value.
|
||||
StructValue *Struct `protobuf:"bytes,5,opt,name=struct_value,json=structValue,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Value_ListValue struct {
|
||||
// Represents a repeated `Value`.
|
||||
ListValue *ListValue `protobuf:"bytes,6,opt,name=list_value,json=listValue,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*Value_NullValue) isValue_Kind() {}
|
||||
|
||||
func (*Value_NumberValue) isValue_Kind() {}
|
||||
|
||||
func (*Value_StringValue) isValue_Kind() {}
|
||||
|
||||
func (*Value_BoolValue) isValue_Kind() {}
|
||||
|
||||
func (*Value_StructValue) isValue_Kind() {}
|
||||
|
||||
func (*Value_ListValue) isValue_Kind() {}
|
||||
|
||||
// `ListValue` is a wrapper around a repeated field of values.
|
||||
//
|
||||
// The JSON representation for `ListValue` is JSON array.
|
||||
type ListValue struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Repeated field of dynamically typed values.
|
||||
Values []*Value `protobuf:"bytes,1,rep,name=values,proto3" json:"values,omitempty"`
|
||||
}
|
||||
|
||||
// NewList constructs a ListValue from a general-purpose Go slice.
|
||||
// The slice elements are converted using NewValue.
|
||||
func NewList(v []interface{}) (*ListValue, error) {
|
||||
x := &ListValue{Values: make([]*Value, len(v))}
|
||||
for i, v := range v {
|
||||
var err error
|
||||
x.Values[i], err = NewValue(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
// AsSlice converts x to a general-purpose Go slice.
|
||||
// The slice elements are converted by calling Value.AsInterface.
|
||||
func (x *ListValue) AsSlice() []interface{} {
|
||||
vs := make([]interface{}, len(x.GetValues()))
|
||||
for i, v := range x.GetValues() {
|
||||
vs[i] = v.AsInterface()
|
||||
}
|
||||
return vs
|
||||
}
|
||||
|
||||
func (x *ListValue) MarshalJSON() ([]byte, error) {
|
||||
return protojson.Marshal(x)
|
||||
}
|
||||
|
||||
func (x *ListValue) UnmarshalJSON(b []byte) error {
|
||||
return protojson.Unmarshal(b, x)
|
||||
}
|
||||
|
||||
func (x *ListValue) Reset() {
|
||||
*x = ListValue{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_google_protobuf_struct_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ListValue) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListValue) ProtoMessage() {}
|
||||
|
||||
func (x *ListValue) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_google_protobuf_struct_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListValue.ProtoReflect.Descriptor instead.
|
||||
func (*ListValue) Descriptor() ([]byte, []int) {
|
||||
return file_google_protobuf_struct_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *ListValue) GetValues() []*Value {
|
||||
if x != nil {
|
||||
return x.Values
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_google_protobuf_struct_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_google_protobuf_struct_proto_rawDesc = []byte{
|
||||
0x0a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
||||
0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f,
|
||||
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22,
|
||||
0x98, 0x01, 0x0a, 0x06, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x12, 0x3b, 0x0a, 0x06, 0x66, 0x69,
|
||||
0x65, 0x6c, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x67, 0x6f, 0x6f,
|
||||
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72,
|
||||
0x75, 0x63, 0x74, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52,
|
||||
0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x1a, 0x51, 0x0a, 0x0b, 0x46, 0x69, 0x65, 0x6c, 0x64,
|
||||
0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75,
|
||||
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52,
|
||||
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xb2, 0x02, 0x0a, 0x05, 0x56,
|
||||
0x61, 0x6c, 0x75, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x6e, 0x75, 0x6c, 0x6c, 0x5f, 0x76, 0x61, 0x6c,
|
||||
0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4e, 0x75, 0x6c, 0x6c, 0x56,
|
||||
0x61, 0x6c, 0x75, 0x65, 0x48, 0x00, 0x52, 0x09, 0x6e, 0x75, 0x6c, 0x6c, 0x56, 0x61, 0x6c, 0x75,
|
||||
0x65, 0x12, 0x23, 0x0a, 0x0c, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x76, 0x61, 0x6c, 0x75,
|
||||
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, 0x48, 0x00, 0x52, 0x0b, 0x6e, 0x75, 0x6d, 0x62, 0x65,
|
||||
0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67,
|
||||
0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b,
|
||||
0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0a, 0x62,
|
||||
0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x48,
|
||||
0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3c, 0x0a, 0x0c,
|
||||
0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01,
|
||||
0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x48, 0x00, 0x52, 0x0b, 0x73,
|
||||
0x74, 0x72, 0x75, 0x63, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x6c, 0x69,
|
||||
0x73, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a,
|
||||
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
|
||||
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x48, 0x00, 0x52, 0x09, 0x6c, 0x69,
|
||||
0x73, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x06, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x22,
|
||||
0x3b, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2e, 0x0a, 0x06,
|
||||
0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67,
|
||||
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56,
|
||||
0x61, 0x6c, 0x75, 0x65, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x2a, 0x1b, 0x0a, 0x09,
|
||||
0x4e, 0x75, 0x6c, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x55, 0x4c,
|
||||
0x4c, 0x5f, 0x56, 0x41, 0x4c, 0x55, 0x45, 0x10, 0x00, 0x42, 0x7f, 0x0a, 0x13, 0x63, 0x6f, 0x6d,
|
||||
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
|
||||
0x42, 0x0b, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a,
|
||||
0x2f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f,
|
||||
0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65,
|
||||
0x73, 0x2f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x70, 0x62,
|
||||
0xf8, 0x01, 0x01, 0xa2, 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, 0x1e, 0x47, 0x6f, 0x6f, 0x67,
|
||||
0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x57, 0x65, 0x6c, 0x6c,
|
||||
0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_google_protobuf_struct_proto_rawDescOnce sync.Once
|
||||
file_google_protobuf_struct_proto_rawDescData = file_google_protobuf_struct_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_google_protobuf_struct_proto_rawDescGZIP() []byte {
|
||||
file_google_protobuf_struct_proto_rawDescOnce.Do(func() {
|
||||
file_google_protobuf_struct_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_struct_proto_rawDescData)
|
||||
})
|
||||
return file_google_protobuf_struct_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_google_protobuf_struct_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_google_protobuf_struct_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_google_protobuf_struct_proto_goTypes = []interface{}{
|
||||
(NullValue)(0), // 0: google.protobuf.NullValue
|
||||
(*Struct)(nil), // 1: google.protobuf.Struct
|
||||
(*Value)(nil), // 2: google.protobuf.Value
|
||||
(*ListValue)(nil), // 3: google.protobuf.ListValue
|
||||
nil, // 4: google.protobuf.Struct.FieldsEntry
|
||||
}
|
||||
var file_google_protobuf_struct_proto_depIdxs = []int32{
|
||||
4, // 0: google.protobuf.Struct.fields:type_name -> google.protobuf.Struct.FieldsEntry
|
||||
0, // 1: google.protobuf.Value.null_value:type_name -> google.protobuf.NullValue
|
||||
1, // 2: google.protobuf.Value.struct_value:type_name -> google.protobuf.Struct
|
||||
3, // 3: google.protobuf.Value.list_value:type_name -> google.protobuf.ListValue
|
||||
2, // 4: google.protobuf.ListValue.values:type_name -> google.protobuf.Value
|
||||
2, // 5: google.protobuf.Struct.FieldsEntry.value:type_name -> google.protobuf.Value
|
||||
6, // [6:6] is the sub-list for method output_type
|
||||
6, // [6:6] is the sub-list for method input_type
|
||||
6, // [6:6] is the sub-list for extension type_name
|
||||
6, // [6:6] is the sub-list for extension extendee
|
||||
0, // [0:6] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_google_protobuf_struct_proto_init() }
|
||||
func file_google_protobuf_struct_proto_init() {
|
||||
if File_google_protobuf_struct_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_google_protobuf_struct_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Struct); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_google_protobuf_struct_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Value); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_google_protobuf_struct_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ListValue); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
file_google_protobuf_struct_proto_msgTypes[1].OneofWrappers = []interface{}{
|
||||
(*Value_NullValue)(nil),
|
||||
(*Value_NumberValue)(nil),
|
||||
(*Value_StringValue)(nil),
|
||||
(*Value_BoolValue)(nil),
|
||||
(*Value_StructValue)(nil),
|
||||
(*Value_ListValue)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_google_protobuf_struct_proto_rawDesc,
|
||||
NumEnums: 1,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_google_protobuf_struct_proto_goTypes,
|
||||
DependencyIndexes: file_google_protobuf_struct_proto_depIdxs,
|
||||
EnumInfos: file_google_protobuf_struct_proto_enumTypes,
|
||||
MessageInfos: file_google_protobuf_struct_proto_msgTypes,
|
||||
}.Build()
|
||||
File_google_protobuf_struct_proto = out.File
|
||||
file_google_protobuf_struct_proto_rawDesc = nil
|
||||
file_google_protobuf_struct_proto_goTypes = nil
|
||||
file_google_protobuf_struct_proto_depIdxs = nil
|
||||
}
|
|
@ -84,6 +84,9 @@ github.com/docker/libnetwork/types
|
|||
# github.com/evanphx/json-patch v4.11.0+incompatible
|
||||
## explicit
|
||||
github.com/evanphx/json-patch
|
||||
# github.com/fatih/structs v1.1.0
|
||||
## explicit
|
||||
github.com/fatih/structs
|
||||
# github.com/fsnotify/fsnotify v1.5.1
|
||||
## explicit; go 1.13
|
||||
github.com/fsnotify/fsnotify
|
||||
|
@ -108,6 +111,7 @@ github.com/golang/mock/gomock
|
|||
# github.com/golang/protobuf v1.5.2
|
||||
## explicit; go 1.9
|
||||
github.com/golang/protobuf/proto
|
||||
github.com/golang/protobuf/protoc-gen-go/descriptor
|
||||
github.com/golang/protobuf/ptypes
|
||||
github.com/golang/protobuf/ptypes/any
|
||||
github.com/golang/protobuf/ptypes/duration
|
||||
|
@ -434,6 +438,8 @@ google.golang.org/grpc/internal/transport/networktype
|
|||
google.golang.org/grpc/keepalive
|
||||
google.golang.org/grpc/metadata
|
||||
google.golang.org/grpc/peer
|
||||
google.golang.org/grpc/reflection
|
||||
google.golang.org/grpc/reflection/grpc_reflection_v1alpha
|
||||
google.golang.org/grpc/resolver
|
||||
google.golang.org/grpc/serviceconfig
|
||||
google.golang.org/grpc/stats
|
||||
|
@ -472,6 +478,7 @@ google.golang.org/protobuf/runtime/protoimpl
|
|||
google.golang.org/protobuf/types/descriptorpb
|
||||
google.golang.org/protobuf/types/known/anypb
|
||||
google.golang.org/protobuf/types/known/durationpb
|
||||
google.golang.org/protobuf/types/known/structpb
|
||||
google.golang.org/protobuf/types/known/timestamppb
|
||||
# gopkg.in/fsnotify.v1 v1.4.7
|
||||
## explicit
|
||||
|
|
Загрузка…
Ссылка в новой задаче