resource.pb.go 33 KB

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