github.com/kaisenlinux/docker@v0.0.0-20230510090727-ea55db55fac7/swarmkit/api/resource.pb.go (about)

     1  // Code generated by protoc-gen-gogo. DO NOT EDIT.
     2  // source: github.com/docker/swarmkit/api/resource.proto
     3  
     4  package api
     5  
     6  import (
     7  	context "context"
     8  	fmt "fmt"
     9  	github_com_docker_swarmkit_api_deepcopy "github.com/docker/swarmkit/api/deepcopy"
    10  	raftselector "github.com/docker/swarmkit/manager/raftselector"
    11  	_ "github.com/docker/swarmkit/protobuf/plugin"
    12  	_ "github.com/gogo/protobuf/gogoproto"
    13  	proto "github.com/gogo/protobuf/proto"
    14  	grpc "google.golang.org/grpc"
    15  	codes "google.golang.org/grpc/codes"
    16  	metadata "google.golang.org/grpc/metadata"
    17  	peer "google.golang.org/grpc/peer"
    18  	status "google.golang.org/grpc/status"
    19  	io "io"
    20  	math "math"
    21  	reflect "reflect"
    22  	strings "strings"
    23  	rafttime "time"
    24  )
    25  
    26  // Reference imports to suppress errors if they are not otherwise used.
    27  var _ = proto.Marshal
    28  var _ = fmt.Errorf
    29  var _ = math.Inf
    30  
    31  // This is a compile-time assertion to ensure that this generated file
    32  // is compatible with the proto package it is being compiled against.
    33  // A compilation error at this line likely means your copy of the
    34  // proto package needs to be updated.
    35  const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
    36  
    37  type AttachNetworkRequest struct {
    38  	Config      *NetworkAttachmentConfig `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"`
    39  	ContainerID string                   `protobuf:"bytes,2,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"`
    40  }
    41  
    42  func (m *AttachNetworkRequest) Reset()      { *m = AttachNetworkRequest{} }
    43  func (*AttachNetworkRequest) ProtoMessage() {}
    44  func (*AttachNetworkRequest) Descriptor() ([]byte, []int) {
    45  	return fileDescriptor_909455b1b868ddb9, []int{0}
    46  }
    47  func (m *AttachNetworkRequest) XXX_Unmarshal(b []byte) error {
    48  	return m.Unmarshal(b)
    49  }
    50  func (m *AttachNetworkRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
    51  	if deterministic {
    52  		return xxx_messageInfo_AttachNetworkRequest.Marshal(b, m, deterministic)
    53  	} else {
    54  		b = b[:cap(b)]
    55  		n, err := m.MarshalTo(b)
    56  		if err != nil {
    57  			return nil, err
    58  		}
    59  		return b[:n], nil
    60  	}
    61  }
    62  func (m *AttachNetworkRequest) XXX_Merge(src proto.Message) {
    63  	xxx_messageInfo_AttachNetworkRequest.Merge(m, src)
    64  }
    65  func (m *AttachNetworkRequest) XXX_Size() int {
    66  	return m.Size()
    67  }
    68  func (m *AttachNetworkRequest) XXX_DiscardUnknown() {
    69  	xxx_messageInfo_AttachNetworkRequest.DiscardUnknown(m)
    70  }
    71  
    72  var xxx_messageInfo_AttachNetworkRequest proto.InternalMessageInfo
    73  
    74  type AttachNetworkResponse struct {
    75  	AttachmentID string `protobuf:"bytes,1,opt,name=attachment_id,json=attachmentId,proto3" json:"attachment_id,omitempty"`
    76  }
    77  
    78  func (m *AttachNetworkResponse) Reset()      { *m = AttachNetworkResponse{} }
    79  func (*AttachNetworkResponse) ProtoMessage() {}
    80  func (*AttachNetworkResponse) Descriptor() ([]byte, []int) {
    81  	return fileDescriptor_909455b1b868ddb9, []int{1}
    82  }
    83  func (m *AttachNetworkResponse) XXX_Unmarshal(b []byte) error {
    84  	return m.Unmarshal(b)
    85  }
    86  func (m *AttachNetworkResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
    87  	if deterministic {
    88  		return xxx_messageInfo_AttachNetworkResponse.Marshal(b, m, deterministic)
    89  	} else {
    90  		b = b[:cap(b)]
    91  		n, err := m.MarshalTo(b)
    92  		if err != nil {
    93  			return nil, err
    94  		}
    95  		return b[:n], nil
    96  	}
    97  }
    98  func (m *AttachNetworkResponse) XXX_Merge(src proto.Message) {
    99  	xxx_messageInfo_AttachNetworkResponse.Merge(m, src)
   100  }
   101  func (m *AttachNetworkResponse) XXX_Size() int {
   102  	return m.Size()
   103  }
   104  func (m *AttachNetworkResponse) XXX_DiscardUnknown() {
   105  	xxx_messageInfo_AttachNetworkResponse.DiscardUnknown(m)
   106  }
   107  
   108  var xxx_messageInfo_AttachNetworkResponse proto.InternalMessageInfo
   109  
   110  type DetachNetworkRequest struct {
   111  	AttachmentID string `protobuf:"bytes,1,opt,name=attachment_id,json=attachmentId,proto3" json:"attachment_id,omitempty"`
   112  }
   113  
   114  func (m *DetachNetworkRequest) Reset()      { *m = DetachNetworkRequest{} }
   115  func (*DetachNetworkRequest) ProtoMessage() {}
   116  func (*DetachNetworkRequest) Descriptor() ([]byte, []int) {
   117  	return fileDescriptor_909455b1b868ddb9, []int{2}
   118  }
   119  func (m *DetachNetworkRequest) XXX_Unmarshal(b []byte) error {
   120  	return m.Unmarshal(b)
   121  }
   122  func (m *DetachNetworkRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
   123  	if deterministic {
   124  		return xxx_messageInfo_DetachNetworkRequest.Marshal(b, m, deterministic)
   125  	} else {
   126  		b = b[:cap(b)]
   127  		n, err := m.MarshalTo(b)
   128  		if err != nil {
   129  			return nil, err
   130  		}
   131  		return b[:n], nil
   132  	}
   133  }
   134  func (m *DetachNetworkRequest) XXX_Merge(src proto.Message) {
   135  	xxx_messageInfo_DetachNetworkRequest.Merge(m, src)
   136  }
   137  func (m *DetachNetworkRequest) XXX_Size() int {
   138  	return m.Size()
   139  }
   140  func (m *DetachNetworkRequest) XXX_DiscardUnknown() {
   141  	xxx_messageInfo_DetachNetworkRequest.DiscardUnknown(m)
   142  }
   143  
   144  var xxx_messageInfo_DetachNetworkRequest proto.InternalMessageInfo
   145  
   146  type DetachNetworkResponse struct {
   147  }
   148  
   149  func (m *DetachNetworkResponse) Reset()      { *m = DetachNetworkResponse{} }
   150  func (*DetachNetworkResponse) ProtoMessage() {}
   151  func (*DetachNetworkResponse) Descriptor() ([]byte, []int) {
   152  	return fileDescriptor_909455b1b868ddb9, []int{3}
   153  }
   154  func (m *DetachNetworkResponse) XXX_Unmarshal(b []byte) error {
   155  	return m.Unmarshal(b)
   156  }
   157  func (m *DetachNetworkResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
   158  	if deterministic {
   159  		return xxx_messageInfo_DetachNetworkResponse.Marshal(b, m, deterministic)
   160  	} else {
   161  		b = b[:cap(b)]
   162  		n, err := m.MarshalTo(b)
   163  		if err != nil {
   164  			return nil, err
   165  		}
   166  		return b[:n], nil
   167  	}
   168  }
   169  func (m *DetachNetworkResponse) XXX_Merge(src proto.Message) {
   170  	xxx_messageInfo_DetachNetworkResponse.Merge(m, src)
   171  }
   172  func (m *DetachNetworkResponse) XXX_Size() int {
   173  	return m.Size()
   174  }
   175  func (m *DetachNetworkResponse) XXX_DiscardUnknown() {
   176  	xxx_messageInfo_DetachNetworkResponse.DiscardUnknown(m)
   177  }
   178  
   179  var xxx_messageInfo_DetachNetworkResponse proto.InternalMessageInfo
   180  
   181  func init() {
   182  	proto.RegisterType((*AttachNetworkRequest)(nil), "docker.swarmkit.v1.AttachNetworkRequest")
   183  	proto.RegisterType((*AttachNetworkResponse)(nil), "docker.swarmkit.v1.AttachNetworkResponse")
   184  	proto.RegisterType((*DetachNetworkRequest)(nil), "docker.swarmkit.v1.DetachNetworkRequest")
   185  	proto.RegisterType((*DetachNetworkResponse)(nil), "docker.swarmkit.v1.DetachNetworkResponse")
   186  }
   187  
   188  func init() {
   189  	proto.RegisterFile("github.com/docker/swarmkit/api/resource.proto", fileDescriptor_909455b1b868ddb9)
   190  }
   191  
   192  var fileDescriptor_909455b1b868ddb9 = []byte{
   193  	// 411 bytes of a gzipped FileDescriptorProto
   194  	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x3f, 0x6f, 0xda, 0x40,
   195  	0x18, 0xc6, 0x7d, 0x0c, 0x48, 0x3d, 0x8c, 0xda, 0x5a, 0xa0, 0x22, 0xa4, 0x1e, 0xc8, 0xed, 0x40,
   196  	0x5b, 0x61, 0xab, 0x54, 0x55, 0x67, 0xfe, 0x2c, 0x1e, 0xca, 0xe0, 0x2f, 0x50, 0x1d, 0xf6, 0x61,
   197  	0x2c, 0xb0, 0xcf, 0x3d, 0x9f, 0x83, 0xb2, 0x65, 0xcd, 0x94, 0x8c, 0xf9, 0x0e, 0x91, 0xf2, 0x39,
   198  	0x50, 0x26, 0x46, 0x26, 0x14, 0xcc, 0x9e, 0xcf, 0x10, 0xe1, 0x33, 0x20, 0x88, 0x95, 0xa0, 0x4c,
   199  	0x3e, 0x9f, 0x9f, 0xe7, 0x79, 0x7f, 0xef, 0xfb, 0x1a, 0x36, 0x1d, 0x97, 0x8f, 0xa2, 0x81, 0x66,
   200  	0x51, 0x4f, 0xb7, 0xa9, 0x35, 0x26, 0x4c, 0x0f, 0xa7, 0x98, 0x79, 0x63, 0x97, 0xeb, 0x38, 0x70,
   201  	0x75, 0x46, 0x42, 0x1a, 0x31, 0x8b, 0x68, 0x01, 0xa3, 0x9c, 0x2a, 0x8a, 0xd0, 0x68, 0x5b, 0x8d,
   202  	0x76, 0xf6, 0xb3, 0xfa, 0xfd, 0x95, 0x08, 0x7e, 0x1e, 0x90, 0x50, 0xf8, 0xab, 0x25, 0x87, 0x3a,
   203  	0x34, 0x39, 0xea, 0x9b, 0x53, 0x7a, 0xfb, 0xe7, 0x85, 0x84, 0x44, 0x31, 0x88, 0x86, 0x7a, 0x30,
   204  	0x89, 0x1c, 0xd7, 0x4f, 0x1f, 0xc2, 0xa8, 0x5e, 0x01, 0x58, 0x6a, 0x73, 0x8e, 0xad, 0x51, 0x9f,
   205  	0xf0, 0x29, 0x65, 0x63, 0x93, 0xfc, 0x8f, 0x48, 0xc8, 0x95, 0x2e, 0xcc, 0x5b, 0xd4, 0x1f, 0xba,
   206  	0x4e, 0x05, 0xd4, 0x41, 0xa3, 0xd0, 0xfa, 0xa1, 0x3d, 0x07, 0xd7, 0x52, 0x8f, 0x08, 0xf0, 0x88,
   207  	0xcf, 0xbb, 0x89, 0xc5, 0x4c, 0xad, 0x4a, 0x0b, 0xca, 0x16, 0xf5, 0x39, 0x76, 0x7d, 0xc2, 0xfe,
   208  	0xb9, 0x76, 0x25, 0x57, 0x07, 0x8d, 0x77, 0x9d, 0xf7, 0xf1, 0xb2, 0x56, 0xe8, 0x6e, 0xef, 0x8d,
   209  	0x9e, 0x59, 0xd8, 0x89, 0x0c, 0x5b, 0xed, 0xc3, 0xf2, 0x11, 0x50, 0x18, 0x50, 0x3f, 0x24, 0xca,
   210  	0x6f, 0x58, 0xc4, 0xbb, 0x42, 0x9b, 0x34, 0x90, 0xa4, 0x7d, 0x88, 0x97, 0x35, 0x79, 0x4f, 0x60,
   211  	0xf4, 0x4c, 0x79, 0x2f, 0x33, 0x6c, 0xf5, 0x2f, 0x2c, 0xf5, 0x48, 0x46, 0x83, 0x6f, 0x8c, 0xfb,
   212  	0x04, 0xcb, 0x47, 0x71, 0x02, 0xaf, 0x75, 0x9b, 0x83, 0x1f, 0xcd, 0x74, 0xd7, 0xed, 0xc9, 0x84,
   213  	0x5a, 0x98, 0x53, 0xa6, 0x5c, 0x02, 0x58, 0x3c, 0x68, 0x47, 0x69, 0x64, 0x0d, 0x32, 0x6b, 0x05,
   214  	0xd5, 0x6f, 0x27, 0x28, 0x45, 0x71, 0xf5, 0xcb, 0xfd, 0xdd, 0xe3, 0x4d, 0xee, 0x33, 0x94, 0x13,
   215  	0x69, 0x73, 0xf3, 0x8d, 0x30, 0x58, 0x14, 0x6f, 0x1e, 0xf6, 0xb1, 0x43, 0x04, 0xcb, 0x01, 0x7b,
   216  	0x36, 0x4b, 0xd6, 0xb4, 0xb2, 0x59, 0x32, 0x07, 0x71, 0x12, 0x4b, 0xe7, 0xeb, 0x6c, 0x85, 0xa4,
   217  	0xc5, 0x0a, 0x49, 0x17, 0x31, 0x02, 0xb3, 0x18, 0x81, 0x79, 0x8c, 0xc0, 0x43, 0x8c, 0xc0, 0xf5,
   218  	0x1a, 0x49, 0xf3, 0x35, 0x92, 0x16, 0x6b, 0x24, 0x0d, 0xf2, 0xc9, 0x4f, 0xfa, 0xeb, 0x29, 0x00,
   219  	0x00, 0xff, 0xff, 0x9d, 0x2f, 0x31, 0x83, 0x64, 0x03, 0x00, 0x00,
   220  }
   221  
   222  type authenticatedWrapperResourceAllocatorServer struct {
   223  	local     ResourceAllocatorServer
   224  	authorize func(context.Context, []string) error
   225  }
   226  
   227  func NewAuthenticatedWrapperResourceAllocatorServer(local ResourceAllocatorServer, authorize func(context.Context, []string) error) ResourceAllocatorServer {
   228  	return &authenticatedWrapperResourceAllocatorServer{
   229  		local:     local,
   230  		authorize: authorize,
   231  	}
   232  }
   233  
   234  func (p *authenticatedWrapperResourceAllocatorServer) AttachNetwork(ctx context.Context, r *AttachNetworkRequest) (*AttachNetworkResponse, error) {
   235  
   236  	if err := p.authorize(ctx, []string{"swarm-worker", "swarm-manager"}); err != nil {
   237  		return nil, err
   238  	}
   239  	return p.local.AttachNetwork(ctx, r)
   240  }
   241  
   242  func (p *authenticatedWrapperResourceAllocatorServer) DetachNetwork(ctx context.Context, r *DetachNetworkRequest) (*DetachNetworkResponse, error) {
   243  
   244  	if err := p.authorize(ctx, []string{"swarm-worker", "swarm-manager"}); err != nil {
   245  		return nil, err
   246  	}
   247  	return p.local.DetachNetwork(ctx, r)
   248  }
   249  
   250  func (m *AttachNetworkRequest) Copy() *AttachNetworkRequest {
   251  	if m == nil {
   252  		return nil
   253  	}
   254  	o := &AttachNetworkRequest{}
   255  	o.CopyFrom(m)
   256  	return o
   257  }
   258  
   259  func (m *AttachNetworkRequest) CopyFrom(src interface{}) {
   260  
   261  	o := src.(*AttachNetworkRequest)
   262  	*m = *o
   263  	if o.Config != nil {
   264  		m.Config = &NetworkAttachmentConfig{}
   265  		github_com_docker_swarmkit_api_deepcopy.Copy(m.Config, o.Config)
   266  	}
   267  }
   268  
   269  func (m *AttachNetworkResponse) Copy() *AttachNetworkResponse {
   270  	if m == nil {
   271  		return nil
   272  	}
   273  	o := &AttachNetworkResponse{}
   274  	o.CopyFrom(m)
   275  	return o
   276  }
   277  
   278  func (m *AttachNetworkResponse) CopyFrom(src interface{}) {
   279  
   280  	o := src.(*AttachNetworkResponse)
   281  	*m = *o
   282  }
   283  
   284  func (m *DetachNetworkRequest) Copy() *DetachNetworkRequest {
   285  	if m == nil {
   286  		return nil
   287  	}
   288  	o := &DetachNetworkRequest{}
   289  	o.CopyFrom(m)
   290  	return o
   291  }
   292  
   293  func (m *DetachNetworkRequest) CopyFrom(src interface{}) {
   294  
   295  	o := src.(*DetachNetworkRequest)
   296  	*m = *o
   297  }
   298  
   299  func (m *DetachNetworkResponse) Copy() *DetachNetworkResponse {
   300  	if m == nil {
   301  		return nil
   302  	}
   303  	o := &DetachNetworkResponse{}
   304  	o.CopyFrom(m)
   305  	return o
   306  }
   307  
   308  func (m *DetachNetworkResponse) CopyFrom(src interface{}) {}
   309  
   310  // Reference imports to suppress errors if they are not otherwise used.
   311  var _ context.Context
   312  var _ grpc.ClientConn
   313  
   314  // This is a compile-time assertion to ensure that this generated file
   315  // is compatible with the grpc package it is being compiled against.
   316  const _ = grpc.SupportPackageIsVersion4
   317  
   318  // ResourceAllocatorClient is the client API for ResourceAllocator service.
   319  //
   320  // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
   321  type ResourceAllocatorClient interface {
   322  	AttachNetwork(ctx context.Context, in *AttachNetworkRequest, opts ...grpc.CallOption) (*AttachNetworkResponse, error)
   323  	DetachNetwork(ctx context.Context, in *DetachNetworkRequest, opts ...grpc.CallOption) (*DetachNetworkResponse, error)
   324  }
   325  
   326  type resourceAllocatorClient struct {
   327  	cc *grpc.ClientConn
   328  }
   329  
   330  func NewResourceAllocatorClient(cc *grpc.ClientConn) ResourceAllocatorClient {
   331  	return &resourceAllocatorClient{cc}
   332  }
   333  
   334  func (c *resourceAllocatorClient) AttachNetwork(ctx context.Context, in *AttachNetworkRequest, opts ...grpc.CallOption) (*AttachNetworkResponse, error) {
   335  	out := new(AttachNetworkResponse)
   336  	err := c.cc.Invoke(ctx, "/docker.swarmkit.v1.ResourceAllocator/AttachNetwork", in, out, opts...)
   337  	if err != nil {
   338  		return nil, err
   339  	}
   340  	return out, nil
   341  }
   342  
   343  func (c *resourceAllocatorClient) DetachNetwork(ctx context.Context, in *DetachNetworkRequest, opts ...grpc.CallOption) (*DetachNetworkResponse, error) {
   344  	out := new(DetachNetworkResponse)
   345  	err := c.cc.Invoke(ctx, "/docker.swarmkit.v1.ResourceAllocator/DetachNetwork", in, out, opts...)
   346  	if err != nil {
   347  		return nil, err
   348  	}
   349  	return out, nil
   350  }
   351  
   352  // ResourceAllocatorServer is the server API for ResourceAllocator service.
   353  type ResourceAllocatorServer interface {
   354  	AttachNetwork(context.Context, *AttachNetworkRequest) (*AttachNetworkResponse, error)
   355  	DetachNetwork(context.Context, *DetachNetworkRequest) (*DetachNetworkResponse, error)
   356  }
   357  
   358  func RegisterResourceAllocatorServer(s *grpc.Server, srv ResourceAllocatorServer) {
   359  	s.RegisterService(&_ResourceAllocator_serviceDesc, srv)
   360  }
   361  
   362  func _ResourceAllocator_AttachNetwork_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
   363  	in := new(AttachNetworkRequest)
   364  	if err := dec(in); err != nil {
   365  		return nil, err
   366  	}
   367  	if interceptor == nil {
   368  		return srv.(ResourceAllocatorServer).AttachNetwork(ctx, in)
   369  	}
   370  	info := &grpc.UnaryServerInfo{
   371  		Server:     srv,
   372  		FullMethod: "/docker.swarmkit.v1.ResourceAllocator/AttachNetwork",
   373  	}
   374  	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
   375  		return srv.(ResourceAllocatorServer).AttachNetwork(ctx, req.(*AttachNetworkRequest))
   376  	}
   377  	return interceptor(ctx, in, info, handler)
   378  }
   379  
   380  func _ResourceAllocator_DetachNetwork_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
   381  	in := new(DetachNetworkRequest)
   382  	if err := dec(in); err != nil {
   383  		return nil, err
   384  	}
   385  	if interceptor == nil {
   386  		return srv.(ResourceAllocatorServer).DetachNetwork(ctx, in)
   387  	}
   388  	info := &grpc.UnaryServerInfo{
   389  		Server:     srv,
   390  		FullMethod: "/docker.swarmkit.v1.ResourceAllocator/DetachNetwork",
   391  	}
   392  	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
   393  		return srv.(ResourceAllocatorServer).DetachNetwork(ctx, req.(*DetachNetworkRequest))
   394  	}
   395  	return interceptor(ctx, in, info, handler)
   396  }
   397  
   398  var _ResourceAllocator_serviceDesc = grpc.ServiceDesc{
   399  	ServiceName: "docker.swarmkit.v1.ResourceAllocator",
   400  	HandlerType: (*ResourceAllocatorServer)(nil),
   401  	Methods: []grpc.MethodDesc{
   402  		{
   403  			MethodName: "AttachNetwork",
   404  			Handler:    _ResourceAllocator_AttachNetwork_Handler,
   405  		},
   406  		{
   407  			MethodName: "DetachNetwork",
   408  			Handler:    _ResourceAllocator_DetachNetwork_Handler,
   409  		},
   410  	},
   411  	Streams:  []grpc.StreamDesc{},
   412  	Metadata: "github.com/docker/swarmkit/api/resource.proto",
   413  }
   414  
   415  func (m *AttachNetworkRequest) Marshal() (dAtA []byte, err error) {
   416  	size := m.Size()
   417  	dAtA = make([]byte, size)
   418  	n, err := m.MarshalTo(dAtA)
   419  	if err != nil {
   420  		return nil, err
   421  	}
   422  	return dAtA[:n], nil
   423  }
   424  
   425  func (m *AttachNetworkRequest) MarshalTo(dAtA []byte) (int, error) {
   426  	var i int
   427  	_ = i
   428  	var l int
   429  	_ = l
   430  	if m.Config != nil {
   431  		dAtA[i] = 0xa
   432  		i++
   433  		i = encodeVarintResource(dAtA, i, uint64(m.Config.Size()))
   434  		n1, err := m.Config.MarshalTo(dAtA[i:])
   435  		if err != nil {
   436  			return 0, err
   437  		}
   438  		i += n1
   439  	}
   440  	if len(m.ContainerID) > 0 {
   441  		dAtA[i] = 0x12
   442  		i++
   443  		i = encodeVarintResource(dAtA, i, uint64(len(m.ContainerID)))
   444  		i += copy(dAtA[i:], m.ContainerID)
   445  	}
   446  	return i, nil
   447  }
   448  
   449  func (m *AttachNetworkResponse) Marshal() (dAtA []byte, err error) {
   450  	size := m.Size()
   451  	dAtA = make([]byte, size)
   452  	n, err := m.MarshalTo(dAtA)
   453  	if err != nil {
   454  		return nil, err
   455  	}
   456  	return dAtA[:n], nil
   457  }
   458  
   459  func (m *AttachNetworkResponse) MarshalTo(dAtA []byte) (int, error) {
   460  	var i int
   461  	_ = i
   462  	var l int
   463  	_ = l
   464  	if len(m.AttachmentID) > 0 {
   465  		dAtA[i] = 0xa
   466  		i++
   467  		i = encodeVarintResource(dAtA, i, uint64(len(m.AttachmentID)))
   468  		i += copy(dAtA[i:], m.AttachmentID)
   469  	}
   470  	return i, nil
   471  }
   472  
   473  func (m *DetachNetworkRequest) Marshal() (dAtA []byte, err error) {
   474  	size := m.Size()
   475  	dAtA = make([]byte, size)
   476  	n, err := m.MarshalTo(dAtA)
   477  	if err != nil {
   478  		return nil, err
   479  	}
   480  	return dAtA[:n], nil
   481  }
   482  
   483  func (m *DetachNetworkRequest) MarshalTo(dAtA []byte) (int, error) {
   484  	var i int
   485  	_ = i
   486  	var l int
   487  	_ = l
   488  	if len(m.AttachmentID) > 0 {
   489  		dAtA[i] = 0xa
   490  		i++
   491  		i = encodeVarintResource(dAtA, i, uint64(len(m.AttachmentID)))
   492  		i += copy(dAtA[i:], m.AttachmentID)
   493  	}
   494  	return i, nil
   495  }
   496  
   497  func (m *DetachNetworkResponse) Marshal() (dAtA []byte, err error) {
   498  	size := m.Size()
   499  	dAtA = make([]byte, size)
   500  	n, err := m.MarshalTo(dAtA)
   501  	if err != nil {
   502  		return nil, err
   503  	}
   504  	return dAtA[:n], nil
   505  }
   506  
   507  func (m *DetachNetworkResponse) MarshalTo(dAtA []byte) (int, error) {
   508  	var i int
   509  	_ = i
   510  	var l int
   511  	_ = l
   512  	return i, nil
   513  }
   514  
   515  func encodeVarintResource(dAtA []byte, offset int, v uint64) int {
   516  	for v >= 1<<7 {
   517  		dAtA[offset] = uint8(v&0x7f | 0x80)
   518  		v >>= 7
   519  		offset++
   520  	}
   521  	dAtA[offset] = uint8(v)
   522  	return offset + 1
   523  }
   524  
   525  type raftProxyResourceAllocatorServer struct {
   526  	local                       ResourceAllocatorServer
   527  	connSelector                raftselector.ConnProvider
   528  	localCtxMods, remoteCtxMods []func(context.Context) (context.Context, error)
   529  }
   530  
   531  func NewRaftProxyResourceAllocatorServer(local ResourceAllocatorServer, connSelector raftselector.ConnProvider, localCtxMod, remoteCtxMod func(context.Context) (context.Context, error)) ResourceAllocatorServer {
   532  	redirectChecker := func(ctx context.Context) (context.Context, error) {
   533  		p, ok := peer.FromContext(ctx)
   534  		if !ok {
   535  			return ctx, status.Errorf(codes.InvalidArgument, "remote addr is not found in context")
   536  		}
   537  		addr := p.Addr.String()
   538  		md, ok := metadata.FromIncomingContext(ctx)
   539  		if ok && len(md["redirect"]) != 0 {
   540  			return ctx, status.Errorf(codes.ResourceExhausted, "more than one redirect to leader from: %s", md["redirect"])
   541  		}
   542  		if !ok {
   543  			md = metadata.New(map[string]string{})
   544  		}
   545  		md["redirect"] = append(md["redirect"], addr)
   546  		return metadata.NewOutgoingContext(ctx, md), nil
   547  	}
   548  	remoteMods := []func(context.Context) (context.Context, error){redirectChecker}
   549  	remoteMods = append(remoteMods, remoteCtxMod)
   550  
   551  	var localMods []func(context.Context) (context.Context, error)
   552  	if localCtxMod != nil {
   553  		localMods = []func(context.Context) (context.Context, error){localCtxMod}
   554  	}
   555  
   556  	return &raftProxyResourceAllocatorServer{
   557  		local:         local,
   558  		connSelector:  connSelector,
   559  		localCtxMods:  localMods,
   560  		remoteCtxMods: remoteMods,
   561  	}
   562  }
   563  func (p *raftProxyResourceAllocatorServer) runCtxMods(ctx context.Context, ctxMods []func(context.Context) (context.Context, error)) (context.Context, error) {
   564  	var err error
   565  	for _, mod := range ctxMods {
   566  		ctx, err = mod(ctx)
   567  		if err != nil {
   568  			return ctx, err
   569  		}
   570  	}
   571  	return ctx, nil
   572  }
   573  func (p *raftProxyResourceAllocatorServer) pollNewLeaderConn(ctx context.Context) (*grpc.ClientConn, error) {
   574  	ticker := rafttime.NewTicker(500 * rafttime.Millisecond)
   575  	defer ticker.Stop()
   576  	for {
   577  		select {
   578  		case <-ticker.C:
   579  			conn, err := p.connSelector.LeaderConn(ctx)
   580  			if err != nil {
   581  				return nil, err
   582  			}
   583  
   584  			client := NewHealthClient(conn)
   585  
   586  			resp, err := client.Check(ctx, &HealthCheckRequest{Service: "Raft"})
   587  			if err != nil || resp.Status != HealthCheckResponse_SERVING {
   588  				continue
   589  			}
   590  			return conn, nil
   591  		case <-ctx.Done():
   592  			return nil, ctx.Err()
   593  		}
   594  	}
   595  }
   596  
   597  func (p *raftProxyResourceAllocatorServer) AttachNetwork(ctx context.Context, r *AttachNetworkRequest) (*AttachNetworkResponse, error) {
   598  
   599  	conn, err := p.connSelector.LeaderConn(ctx)
   600  	if err != nil {
   601  		if err == raftselector.ErrIsLeader {
   602  			ctx, err = p.runCtxMods(ctx, p.localCtxMods)
   603  			if err != nil {
   604  				return nil, err
   605  			}
   606  			return p.local.AttachNetwork(ctx, r)
   607  		}
   608  		return nil, err
   609  	}
   610  	modCtx, err := p.runCtxMods(ctx, p.remoteCtxMods)
   611  	if err != nil {
   612  		return nil, err
   613  	}
   614  
   615  	resp, err := NewResourceAllocatorClient(conn).AttachNetwork(modCtx, r)
   616  	if err != nil {
   617  		if !strings.Contains(err.Error(), "is closing") && !strings.Contains(err.Error(), "the connection is unavailable") && !strings.Contains(err.Error(), "connection error") {
   618  			return resp, err
   619  		}
   620  		conn, err := p.pollNewLeaderConn(ctx)
   621  		if err != nil {
   622  			if err == raftselector.ErrIsLeader {
   623  				return p.local.AttachNetwork(ctx, r)
   624  			}
   625  			return nil, err
   626  		}
   627  		return NewResourceAllocatorClient(conn).AttachNetwork(modCtx, r)
   628  	}
   629  	return resp, err
   630  }
   631  
   632  func (p *raftProxyResourceAllocatorServer) DetachNetwork(ctx context.Context, r *DetachNetworkRequest) (*DetachNetworkResponse, error) {
   633  
   634  	conn, err := p.connSelector.LeaderConn(ctx)
   635  	if err != nil {
   636  		if err == raftselector.ErrIsLeader {
   637  			ctx, err = p.runCtxMods(ctx, p.localCtxMods)
   638  			if err != nil {
   639  				return nil, err
   640  			}
   641  			return p.local.DetachNetwork(ctx, r)
   642  		}
   643  		return nil, err
   644  	}
   645  	modCtx, err := p.runCtxMods(ctx, p.remoteCtxMods)
   646  	if err != nil {
   647  		return nil, err
   648  	}
   649  
   650  	resp, err := NewResourceAllocatorClient(conn).DetachNetwork(modCtx, r)
   651  	if err != nil {
   652  		if !strings.Contains(err.Error(), "is closing") && !strings.Contains(err.Error(), "the connection is unavailable") && !strings.Contains(err.Error(), "connection error") {
   653  			return resp, err
   654  		}
   655  		conn, err := p.pollNewLeaderConn(ctx)
   656  		if err != nil {
   657  			if err == raftselector.ErrIsLeader {
   658  				return p.local.DetachNetwork(ctx, r)
   659  			}
   660  			return nil, err
   661  		}
   662  		return NewResourceAllocatorClient(conn).DetachNetwork(modCtx, r)
   663  	}
   664  	return resp, err
   665  }
   666  
   667  func (m *AttachNetworkRequest) Size() (n int) {
   668  	if m == nil {
   669  		return 0
   670  	}
   671  	var l int
   672  	_ = l
   673  	if m.Config != nil {
   674  		l = m.Config.Size()
   675  		n += 1 + l + sovResource(uint64(l))
   676  	}
   677  	l = len(m.ContainerID)
   678  	if l > 0 {
   679  		n += 1 + l + sovResource(uint64(l))
   680  	}
   681  	return n
   682  }
   683  
   684  func (m *AttachNetworkResponse) Size() (n int) {
   685  	if m == nil {
   686  		return 0
   687  	}
   688  	var l int
   689  	_ = l
   690  	l = len(m.AttachmentID)
   691  	if l > 0 {
   692  		n += 1 + l + sovResource(uint64(l))
   693  	}
   694  	return n
   695  }
   696  
   697  func (m *DetachNetworkRequest) Size() (n int) {
   698  	if m == nil {
   699  		return 0
   700  	}
   701  	var l int
   702  	_ = l
   703  	l = len(m.AttachmentID)
   704  	if l > 0 {
   705  		n += 1 + l + sovResource(uint64(l))
   706  	}
   707  	return n
   708  }
   709  
   710  func (m *DetachNetworkResponse) Size() (n int) {
   711  	if m == nil {
   712  		return 0
   713  	}
   714  	var l int
   715  	_ = l
   716  	return n
   717  }
   718  
   719  func sovResource(x uint64) (n int) {
   720  	for {
   721  		n++
   722  		x >>= 7
   723  		if x == 0 {
   724  			break
   725  		}
   726  	}
   727  	return n
   728  }
   729  func sozResource(x uint64) (n int) {
   730  	return sovResource(uint64((x << 1) ^ uint64((int64(x) >> 63))))
   731  }
   732  func (this *AttachNetworkRequest) String() string {
   733  	if this == nil {
   734  		return "nil"
   735  	}
   736  	s := strings.Join([]string{`&AttachNetworkRequest{`,
   737  		`Config:` + strings.Replace(fmt.Sprintf("%v", this.Config), "NetworkAttachmentConfig", "NetworkAttachmentConfig", 1) + `,`,
   738  		`ContainerID:` + fmt.Sprintf("%v", this.ContainerID) + `,`,
   739  		`}`,
   740  	}, "")
   741  	return s
   742  }
   743  func (this *AttachNetworkResponse) String() string {
   744  	if this == nil {
   745  		return "nil"
   746  	}
   747  	s := strings.Join([]string{`&AttachNetworkResponse{`,
   748  		`AttachmentID:` + fmt.Sprintf("%v", this.AttachmentID) + `,`,
   749  		`}`,
   750  	}, "")
   751  	return s
   752  }
   753  func (this *DetachNetworkRequest) String() string {
   754  	if this == nil {
   755  		return "nil"
   756  	}
   757  	s := strings.Join([]string{`&DetachNetworkRequest{`,
   758  		`AttachmentID:` + fmt.Sprintf("%v", this.AttachmentID) + `,`,
   759  		`}`,
   760  	}, "")
   761  	return s
   762  }
   763  func (this *DetachNetworkResponse) String() string {
   764  	if this == nil {
   765  		return "nil"
   766  	}
   767  	s := strings.Join([]string{`&DetachNetworkResponse{`,
   768  		`}`,
   769  	}, "")
   770  	return s
   771  }
   772  func valueToStringResource(v interface{}) string {
   773  	rv := reflect.ValueOf(v)
   774  	if rv.IsNil() {
   775  		return "nil"
   776  	}
   777  	pv := reflect.Indirect(rv).Interface()
   778  	return fmt.Sprintf("*%v", pv)
   779  }
   780  func (m *AttachNetworkRequest) Unmarshal(dAtA []byte) error {
   781  	l := len(dAtA)
   782  	iNdEx := 0
   783  	for iNdEx < l {
   784  		preIndex := iNdEx
   785  		var wire uint64
   786  		for shift := uint(0); ; shift += 7 {
   787  			if shift >= 64 {
   788  				return ErrIntOverflowResource
   789  			}
   790  			if iNdEx >= l {
   791  				return io.ErrUnexpectedEOF
   792  			}
   793  			b := dAtA[iNdEx]
   794  			iNdEx++
   795  			wire |= uint64(b&0x7F) << shift
   796  			if b < 0x80 {
   797  				break
   798  			}
   799  		}
   800  		fieldNum := int32(wire >> 3)
   801  		wireType := int(wire & 0x7)
   802  		if wireType == 4 {
   803  			return fmt.Errorf("proto: AttachNetworkRequest: wiretype end group for non-group")
   804  		}
   805  		if fieldNum <= 0 {
   806  			return fmt.Errorf("proto: AttachNetworkRequest: illegal tag %d (wire type %d)", fieldNum, wire)
   807  		}
   808  		switch fieldNum {
   809  		case 1:
   810  			if wireType != 2 {
   811  				return fmt.Errorf("proto: wrong wireType = %d for field Config", wireType)
   812  			}
   813  			var msglen int
   814  			for shift := uint(0); ; shift += 7 {
   815  				if shift >= 64 {
   816  					return ErrIntOverflowResource
   817  				}
   818  				if iNdEx >= l {
   819  					return io.ErrUnexpectedEOF
   820  				}
   821  				b := dAtA[iNdEx]
   822  				iNdEx++
   823  				msglen |= int(b&0x7F) << shift
   824  				if b < 0x80 {
   825  					break
   826  				}
   827  			}
   828  			if msglen < 0 {
   829  				return ErrInvalidLengthResource
   830  			}
   831  			postIndex := iNdEx + msglen
   832  			if postIndex < 0 {
   833  				return ErrInvalidLengthResource
   834  			}
   835  			if postIndex > l {
   836  				return io.ErrUnexpectedEOF
   837  			}
   838  			if m.Config == nil {
   839  				m.Config = &NetworkAttachmentConfig{}
   840  			}
   841  			if err := m.Config.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
   842  				return err
   843  			}
   844  			iNdEx = postIndex
   845  		case 2:
   846  			if wireType != 2 {
   847  				return fmt.Errorf("proto: wrong wireType = %d for field ContainerID", wireType)
   848  			}
   849  			var stringLen uint64
   850  			for shift := uint(0); ; shift += 7 {
   851  				if shift >= 64 {
   852  					return ErrIntOverflowResource
   853  				}
   854  				if iNdEx >= l {
   855  					return io.ErrUnexpectedEOF
   856  				}
   857  				b := dAtA[iNdEx]
   858  				iNdEx++
   859  				stringLen |= uint64(b&0x7F) << shift
   860  				if b < 0x80 {
   861  					break
   862  				}
   863  			}
   864  			intStringLen := int(stringLen)
   865  			if intStringLen < 0 {
   866  				return ErrInvalidLengthResource
   867  			}
   868  			postIndex := iNdEx + intStringLen
   869  			if postIndex < 0 {
   870  				return ErrInvalidLengthResource
   871  			}
   872  			if postIndex > l {
   873  				return io.ErrUnexpectedEOF
   874  			}
   875  			m.ContainerID = string(dAtA[iNdEx:postIndex])
   876  			iNdEx = postIndex
   877  		default:
   878  			iNdEx = preIndex
   879  			skippy, err := skipResource(dAtA[iNdEx:])
   880  			if err != nil {
   881  				return err
   882  			}
   883  			if skippy < 0 {
   884  				return ErrInvalidLengthResource
   885  			}
   886  			if (iNdEx + skippy) < 0 {
   887  				return ErrInvalidLengthResource
   888  			}
   889  			if (iNdEx + skippy) > l {
   890  				return io.ErrUnexpectedEOF
   891  			}
   892  			iNdEx += skippy
   893  		}
   894  	}
   895  
   896  	if iNdEx > l {
   897  		return io.ErrUnexpectedEOF
   898  	}
   899  	return nil
   900  }
   901  func (m *AttachNetworkResponse) Unmarshal(dAtA []byte) error {
   902  	l := len(dAtA)
   903  	iNdEx := 0
   904  	for iNdEx < l {
   905  		preIndex := iNdEx
   906  		var wire uint64
   907  		for shift := uint(0); ; shift += 7 {
   908  			if shift >= 64 {
   909  				return ErrIntOverflowResource
   910  			}
   911  			if iNdEx >= l {
   912  				return io.ErrUnexpectedEOF
   913  			}
   914  			b := dAtA[iNdEx]
   915  			iNdEx++
   916  			wire |= uint64(b&0x7F) << shift
   917  			if b < 0x80 {
   918  				break
   919  			}
   920  		}
   921  		fieldNum := int32(wire >> 3)
   922  		wireType := int(wire & 0x7)
   923  		if wireType == 4 {
   924  			return fmt.Errorf("proto: AttachNetworkResponse: wiretype end group for non-group")
   925  		}
   926  		if fieldNum <= 0 {
   927  			return fmt.Errorf("proto: AttachNetworkResponse: illegal tag %d (wire type %d)", fieldNum, wire)
   928  		}
   929  		switch fieldNum {
   930  		case 1:
   931  			if wireType != 2 {
   932  				return fmt.Errorf("proto: wrong wireType = %d for field AttachmentID", wireType)
   933  			}
   934  			var stringLen uint64
   935  			for shift := uint(0); ; shift += 7 {
   936  				if shift >= 64 {
   937  					return ErrIntOverflowResource
   938  				}
   939  				if iNdEx >= l {
   940  					return io.ErrUnexpectedEOF
   941  				}
   942  				b := dAtA[iNdEx]
   943  				iNdEx++
   944  				stringLen |= uint64(b&0x7F) << shift
   945  				if b < 0x80 {
   946  					break
   947  				}
   948  			}
   949  			intStringLen := int(stringLen)
   950  			if intStringLen < 0 {
   951  				return ErrInvalidLengthResource
   952  			}
   953  			postIndex := iNdEx + intStringLen
   954  			if postIndex < 0 {
   955  				return ErrInvalidLengthResource
   956  			}
   957  			if postIndex > l {
   958  				return io.ErrUnexpectedEOF
   959  			}
   960  			m.AttachmentID = string(dAtA[iNdEx:postIndex])
   961  			iNdEx = postIndex
   962  		default:
   963  			iNdEx = preIndex
   964  			skippy, err := skipResource(dAtA[iNdEx:])
   965  			if err != nil {
   966  				return err
   967  			}
   968  			if skippy < 0 {
   969  				return ErrInvalidLengthResource
   970  			}
   971  			if (iNdEx + skippy) < 0 {
   972  				return ErrInvalidLengthResource
   973  			}
   974  			if (iNdEx + skippy) > l {
   975  				return io.ErrUnexpectedEOF
   976  			}
   977  			iNdEx += skippy
   978  		}
   979  	}
   980  
   981  	if iNdEx > l {
   982  		return io.ErrUnexpectedEOF
   983  	}
   984  	return nil
   985  }
   986  func (m *DetachNetworkRequest) Unmarshal(dAtA []byte) error {
   987  	l := len(dAtA)
   988  	iNdEx := 0
   989  	for iNdEx < l {
   990  		preIndex := iNdEx
   991  		var wire uint64
   992  		for shift := uint(0); ; shift += 7 {
   993  			if shift >= 64 {
   994  				return ErrIntOverflowResource
   995  			}
   996  			if iNdEx >= l {
   997  				return io.ErrUnexpectedEOF
   998  			}
   999  			b := dAtA[iNdEx]
  1000  			iNdEx++
  1001  			wire |= uint64(b&0x7F) << shift
  1002  			if b < 0x80 {
  1003  				break
  1004  			}
  1005  		}
  1006  		fieldNum := int32(wire >> 3)
  1007  		wireType := int(wire & 0x7)
  1008  		if wireType == 4 {
  1009  			return fmt.Errorf("proto: DetachNetworkRequest: wiretype end group for non-group")
  1010  		}
  1011  		if fieldNum <= 0 {
  1012  			return fmt.Errorf("proto: DetachNetworkRequest: illegal tag %d (wire type %d)", fieldNum, wire)
  1013  		}
  1014  		switch fieldNum {
  1015  		case 1:
  1016  			if wireType != 2 {
  1017  				return fmt.Errorf("proto: wrong wireType = %d for field AttachmentID", wireType)
  1018  			}
  1019  			var stringLen uint64
  1020  			for shift := uint(0); ; shift += 7 {
  1021  				if shift >= 64 {
  1022  					return ErrIntOverflowResource
  1023  				}
  1024  				if iNdEx >= l {
  1025  					return io.ErrUnexpectedEOF
  1026  				}
  1027  				b := dAtA[iNdEx]
  1028  				iNdEx++
  1029  				stringLen |= uint64(b&0x7F) << shift
  1030  				if b < 0x80 {
  1031  					break
  1032  				}
  1033  			}
  1034  			intStringLen := int(stringLen)
  1035  			if intStringLen < 0 {
  1036  				return ErrInvalidLengthResource
  1037  			}
  1038  			postIndex := iNdEx + intStringLen
  1039  			if postIndex < 0 {
  1040  				return ErrInvalidLengthResource
  1041  			}
  1042  			if postIndex > l {
  1043  				return io.ErrUnexpectedEOF
  1044  			}
  1045  			m.AttachmentID = string(dAtA[iNdEx:postIndex])
  1046  			iNdEx = postIndex
  1047  		default:
  1048  			iNdEx = preIndex
  1049  			skippy, err := skipResource(dAtA[iNdEx:])
  1050  			if err != nil {
  1051  				return err
  1052  			}
  1053  			if skippy < 0 {
  1054  				return ErrInvalidLengthResource
  1055  			}
  1056  			if (iNdEx + skippy) < 0 {
  1057  				return ErrInvalidLengthResource
  1058  			}
  1059  			if (iNdEx + skippy) > l {
  1060  				return io.ErrUnexpectedEOF
  1061  			}
  1062  			iNdEx += skippy
  1063  		}
  1064  	}
  1065  
  1066  	if iNdEx > l {
  1067  		return io.ErrUnexpectedEOF
  1068  	}
  1069  	return nil
  1070  }
  1071  func (m *DetachNetworkResponse) Unmarshal(dAtA []byte) error {
  1072  	l := len(dAtA)
  1073  	iNdEx := 0
  1074  	for iNdEx < l {
  1075  		preIndex := iNdEx
  1076  		var wire uint64
  1077  		for shift := uint(0); ; shift += 7 {
  1078  			if shift >= 64 {
  1079  				return ErrIntOverflowResource
  1080  			}
  1081  			if iNdEx >= l {
  1082  				return io.ErrUnexpectedEOF
  1083  			}
  1084  			b := dAtA[iNdEx]
  1085  			iNdEx++
  1086  			wire |= uint64(b&0x7F) << shift
  1087  			if b < 0x80 {
  1088  				break
  1089  			}
  1090  		}
  1091  		fieldNum := int32(wire >> 3)
  1092  		wireType := int(wire & 0x7)
  1093  		if wireType == 4 {
  1094  			return fmt.Errorf("proto: DetachNetworkResponse: wiretype end group for non-group")
  1095  		}
  1096  		if fieldNum <= 0 {
  1097  			return fmt.Errorf("proto: DetachNetworkResponse: illegal tag %d (wire type %d)", fieldNum, wire)
  1098  		}
  1099  		switch fieldNum {
  1100  		default:
  1101  			iNdEx = preIndex
  1102  			skippy, err := skipResource(dAtA[iNdEx:])
  1103  			if err != nil {
  1104  				return err
  1105  			}
  1106  			if skippy < 0 {
  1107  				return ErrInvalidLengthResource
  1108  			}
  1109  			if (iNdEx + skippy) < 0 {
  1110  				return ErrInvalidLengthResource
  1111  			}
  1112  			if (iNdEx + skippy) > l {
  1113  				return io.ErrUnexpectedEOF
  1114  			}
  1115  			iNdEx += skippy
  1116  		}
  1117  	}
  1118  
  1119  	if iNdEx > l {
  1120  		return io.ErrUnexpectedEOF
  1121  	}
  1122  	return nil
  1123  }
  1124  func skipResource(dAtA []byte) (n int, err error) {
  1125  	l := len(dAtA)
  1126  	iNdEx := 0
  1127  	for iNdEx < l {
  1128  		var wire uint64
  1129  		for shift := uint(0); ; shift += 7 {
  1130  			if shift >= 64 {
  1131  				return 0, ErrIntOverflowResource
  1132  			}
  1133  			if iNdEx >= l {
  1134  				return 0, io.ErrUnexpectedEOF
  1135  			}
  1136  			b := dAtA[iNdEx]
  1137  			iNdEx++
  1138  			wire |= (uint64(b) & 0x7F) << shift
  1139  			if b < 0x80 {
  1140  				break
  1141  			}
  1142  		}
  1143  		wireType := int(wire & 0x7)
  1144  		switch wireType {
  1145  		case 0:
  1146  			for shift := uint(0); ; shift += 7 {
  1147  				if shift >= 64 {
  1148  					return 0, ErrIntOverflowResource
  1149  				}
  1150  				if iNdEx >= l {
  1151  					return 0, io.ErrUnexpectedEOF
  1152  				}
  1153  				iNdEx++
  1154  				if dAtA[iNdEx-1] < 0x80 {
  1155  					break
  1156  				}
  1157  			}
  1158  			return iNdEx, nil
  1159  		case 1:
  1160  			iNdEx += 8
  1161  			return iNdEx, nil
  1162  		case 2:
  1163  			var length int
  1164  			for shift := uint(0); ; shift += 7 {
  1165  				if shift >= 64 {
  1166  					return 0, ErrIntOverflowResource
  1167  				}
  1168  				if iNdEx >= l {
  1169  					return 0, io.ErrUnexpectedEOF
  1170  				}
  1171  				b := dAtA[iNdEx]
  1172  				iNdEx++
  1173  				length |= (int(b) & 0x7F) << shift
  1174  				if b < 0x80 {
  1175  					break
  1176  				}
  1177  			}
  1178  			if length < 0 {
  1179  				return 0, ErrInvalidLengthResource
  1180  			}
  1181  			iNdEx += length
  1182  			if iNdEx < 0 {
  1183  				return 0, ErrInvalidLengthResource
  1184  			}
  1185  			return iNdEx, nil
  1186  		case 3:
  1187  			for {
  1188  				var innerWire uint64
  1189  				var start int = iNdEx
  1190  				for shift := uint(0); ; shift += 7 {
  1191  					if shift >= 64 {
  1192  						return 0, ErrIntOverflowResource
  1193  					}
  1194  					if iNdEx >= l {
  1195  						return 0, io.ErrUnexpectedEOF
  1196  					}
  1197  					b := dAtA[iNdEx]
  1198  					iNdEx++
  1199  					innerWire |= (uint64(b) & 0x7F) << shift
  1200  					if b < 0x80 {
  1201  						break
  1202  					}
  1203  				}
  1204  				innerWireType := int(innerWire & 0x7)
  1205  				if innerWireType == 4 {
  1206  					break
  1207  				}
  1208  				next, err := skipResource(dAtA[start:])
  1209  				if err != nil {
  1210  					return 0, err
  1211  				}
  1212  				iNdEx = start + next
  1213  				if iNdEx < 0 {
  1214  					return 0, ErrInvalidLengthResource
  1215  				}
  1216  			}
  1217  			return iNdEx, nil
  1218  		case 4:
  1219  			return iNdEx, nil
  1220  		case 5:
  1221  			iNdEx += 4
  1222  			return iNdEx, nil
  1223  		default:
  1224  			return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
  1225  		}
  1226  	}
  1227  	panic("unreachable")
  1228  }
  1229  
  1230  var (
  1231  	ErrInvalidLengthResource = fmt.Errorf("proto: negative length found during unmarshaling")
  1232  	ErrIntOverflowResource   = fmt.Errorf("proto: integer overflow")
  1233  )