1// Copyright 2021 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// https://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// Code generated by protoc-gen-go_gapic. DO NOT EDIT. 16 17package transcoder 18 19import ( 20 "context" 21 "fmt" 22 "math" 23 "net/url" 24 "time" 25 26 gax "github.com/googleapis/gax-go/v2" 27 "google.golang.org/api/iterator" 28 "google.golang.org/api/option" 29 "google.golang.org/api/option/internaloption" 30 gtransport "google.golang.org/api/transport/grpc" 31 transcoderpb "google.golang.org/genproto/googleapis/cloud/video/transcoder/v1" 32 "google.golang.org/grpc" 33 "google.golang.org/grpc/metadata" 34 "google.golang.org/protobuf/proto" 35) 36 37var newClientHook clientHook 38 39// CallOptions contains the retry settings for each method of Client. 40type CallOptions struct { 41 CreateJob []gax.CallOption 42 ListJobs []gax.CallOption 43 GetJob []gax.CallOption 44 DeleteJob []gax.CallOption 45 CreateJobTemplate []gax.CallOption 46 ListJobTemplates []gax.CallOption 47 GetJobTemplate []gax.CallOption 48 DeleteJobTemplate []gax.CallOption 49} 50 51func defaultGRPCClientOptions() []option.ClientOption { 52 return []option.ClientOption{ 53 internaloption.WithDefaultEndpoint("transcoder.googleapis.com:443"), 54 internaloption.WithDefaultMTLSEndpoint("transcoder.mtls.googleapis.com:443"), 55 internaloption.WithDefaultAudience("https://transcoder.googleapis.com/"), 56 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 57 internaloption.EnableJwtWithScope(), 58 option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), 59 option.WithGRPCDialOption(grpc.WithDefaultCallOptions( 60 grpc.MaxCallRecvMsgSize(math.MaxInt32))), 61 } 62} 63 64func defaultCallOptions() *CallOptions { 65 return &CallOptions{ 66 CreateJob: []gax.CallOption{}, 67 ListJobs: []gax.CallOption{}, 68 GetJob: []gax.CallOption{}, 69 DeleteJob: []gax.CallOption{}, 70 CreateJobTemplate: []gax.CallOption{}, 71 ListJobTemplates: []gax.CallOption{}, 72 GetJobTemplate: []gax.CallOption{}, 73 DeleteJobTemplate: []gax.CallOption{}, 74 } 75} 76 77// internalClient is an interface that defines the methods availaible from Transcoder API. 78type internalClient interface { 79 Close() error 80 setGoogleClientInfo(...string) 81 Connection() *grpc.ClientConn 82 CreateJob(context.Context, *transcoderpb.CreateJobRequest, ...gax.CallOption) (*transcoderpb.Job, error) 83 ListJobs(context.Context, *transcoderpb.ListJobsRequest, ...gax.CallOption) *JobIterator 84 GetJob(context.Context, *transcoderpb.GetJobRequest, ...gax.CallOption) (*transcoderpb.Job, error) 85 DeleteJob(context.Context, *transcoderpb.DeleteJobRequest, ...gax.CallOption) error 86 CreateJobTemplate(context.Context, *transcoderpb.CreateJobTemplateRequest, ...gax.CallOption) (*transcoderpb.JobTemplate, error) 87 ListJobTemplates(context.Context, *transcoderpb.ListJobTemplatesRequest, ...gax.CallOption) *JobTemplateIterator 88 GetJobTemplate(context.Context, *transcoderpb.GetJobTemplateRequest, ...gax.CallOption) (*transcoderpb.JobTemplate, error) 89 DeleteJobTemplate(context.Context, *transcoderpb.DeleteJobTemplateRequest, ...gax.CallOption) error 90} 91 92// Client is a client for interacting with Transcoder API. 93// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 94// 95// Using the Transcoder API, you can queue asynchronous jobs for transcoding 96// media into various output formats. Output formats may include different 97// streaming standards such as HTTP Live Streaming (HLS) and Dynamic Adaptive 98// Streaming over HTTP (DASH). You can also customize jobs using advanced 99// features such as Digital Rights Management (DRM), audio equalization, content 100// concatenation, and digital ad-stitch ready content generation. 101type Client struct { 102 // The internal transport-dependent client. 103 internalClient internalClient 104 105 // The call options for this service. 106 CallOptions *CallOptions 107} 108 109// Wrapper methods routed to the internal client. 110 111// Close closes the connection to the API service. The user should invoke this when 112// the client is no longer required. 113func (c *Client) Close() error { 114 return c.internalClient.Close() 115} 116 117// setGoogleClientInfo sets the name and version of the application in 118// the `x-goog-api-client` header passed on each request. Intended for 119// use by Google-written clients. 120func (c *Client) setGoogleClientInfo(keyval ...string) { 121 c.internalClient.setGoogleClientInfo(keyval...) 122} 123 124// Connection returns a connection to the API service. 125// 126// Deprecated. 127func (c *Client) Connection() *grpc.ClientConn { 128 return c.internalClient.Connection() 129} 130 131// CreateJob creates a job in the specified region. 132func (c *Client) CreateJob(ctx context.Context, req *transcoderpb.CreateJobRequest, opts ...gax.CallOption) (*transcoderpb.Job, error) { 133 return c.internalClient.CreateJob(ctx, req, opts...) 134} 135 136// ListJobs lists jobs in the specified region. 137func (c *Client) ListJobs(ctx context.Context, req *transcoderpb.ListJobsRequest, opts ...gax.CallOption) *JobIterator { 138 return c.internalClient.ListJobs(ctx, req, opts...) 139} 140 141// GetJob returns the job data. 142func (c *Client) GetJob(ctx context.Context, req *transcoderpb.GetJobRequest, opts ...gax.CallOption) (*transcoderpb.Job, error) { 143 return c.internalClient.GetJob(ctx, req, opts...) 144} 145 146// DeleteJob deletes a job. 147func (c *Client) DeleteJob(ctx context.Context, req *transcoderpb.DeleteJobRequest, opts ...gax.CallOption) error { 148 return c.internalClient.DeleteJob(ctx, req, opts...) 149} 150 151// CreateJobTemplate creates a job template in the specified region. 152func (c *Client) CreateJobTemplate(ctx context.Context, req *transcoderpb.CreateJobTemplateRequest, opts ...gax.CallOption) (*transcoderpb.JobTemplate, error) { 153 return c.internalClient.CreateJobTemplate(ctx, req, opts...) 154} 155 156// ListJobTemplates lists job templates in the specified region. 157func (c *Client) ListJobTemplates(ctx context.Context, req *transcoderpb.ListJobTemplatesRequest, opts ...gax.CallOption) *JobTemplateIterator { 158 return c.internalClient.ListJobTemplates(ctx, req, opts...) 159} 160 161// GetJobTemplate returns the job template data. 162func (c *Client) GetJobTemplate(ctx context.Context, req *transcoderpb.GetJobTemplateRequest, opts ...gax.CallOption) (*transcoderpb.JobTemplate, error) { 163 return c.internalClient.GetJobTemplate(ctx, req, opts...) 164} 165 166// DeleteJobTemplate deletes a job template. 167func (c *Client) DeleteJobTemplate(ctx context.Context, req *transcoderpb.DeleteJobTemplateRequest, opts ...gax.CallOption) error { 168 return c.internalClient.DeleteJobTemplate(ctx, req, opts...) 169} 170 171// gRPCClient is a client for interacting with Transcoder API over gRPC transport. 172// 173// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 174type gRPCClient struct { 175 // Connection pool of gRPC connections to the service. 176 connPool gtransport.ConnPool 177 178 // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE 179 disableDeadlines bool 180 181 // Points back to the CallOptions field of the containing Client 182 CallOptions **CallOptions 183 184 // The gRPC API client. 185 client transcoderpb.TranscoderServiceClient 186 187 // The x-goog-* metadata to be sent with each request. 188 xGoogMetadata metadata.MD 189} 190 191// NewClient creates a new transcoder service client based on gRPC. 192// The returned client must be Closed when it is done being used to clean up its underlying connections. 193// 194// Using the Transcoder API, you can queue asynchronous jobs for transcoding 195// media into various output formats. Output formats may include different 196// streaming standards such as HTTP Live Streaming (HLS) and Dynamic Adaptive 197// Streaming over HTTP (DASH). You can also customize jobs using advanced 198// features such as Digital Rights Management (DRM), audio equalization, content 199// concatenation, and digital ad-stitch ready content generation. 200func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error) { 201 clientOpts := defaultGRPCClientOptions() 202 if newClientHook != nil { 203 hookOpts, err := newClientHook(ctx, clientHookParams{}) 204 if err != nil { 205 return nil, err 206 } 207 clientOpts = append(clientOpts, hookOpts...) 208 } 209 210 disableDeadlines, err := checkDisableDeadlines() 211 if err != nil { 212 return nil, err 213 } 214 215 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) 216 if err != nil { 217 return nil, err 218 } 219 client := Client{CallOptions: defaultCallOptions()} 220 221 c := &gRPCClient{ 222 connPool: connPool, 223 disableDeadlines: disableDeadlines, 224 client: transcoderpb.NewTranscoderServiceClient(connPool), 225 CallOptions: &client.CallOptions, 226 } 227 c.setGoogleClientInfo() 228 229 client.internalClient = c 230 231 return &client, nil 232} 233 234// Connection returns a connection to the API service. 235// 236// Deprecated. 237func (c *gRPCClient) Connection() *grpc.ClientConn { 238 return c.connPool.Conn() 239} 240 241// setGoogleClientInfo sets the name and version of the application in 242// the `x-goog-api-client` header passed on each request. Intended for 243// use by Google-written clients. 244func (c *gRPCClient) setGoogleClientInfo(keyval ...string) { 245 kv := append([]string{"gl-go", versionGo()}, keyval...) 246 kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) 247 c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) 248} 249 250// Close closes the connection to the API service. The user should invoke this when 251// the client is no longer required. 252func (c *gRPCClient) Close() error { 253 return c.connPool.Close() 254} 255 256func (c *gRPCClient) CreateJob(ctx context.Context, req *transcoderpb.CreateJobRequest, opts ...gax.CallOption) (*transcoderpb.Job, error) { 257 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 258 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 259 defer cancel() 260 ctx = cctx 261 } 262 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 263 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 264 opts = append((*c.CallOptions).CreateJob[0:len((*c.CallOptions).CreateJob):len((*c.CallOptions).CreateJob)], opts...) 265 var resp *transcoderpb.Job 266 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 267 var err error 268 resp, err = c.client.CreateJob(ctx, req, settings.GRPC...) 269 return err 270 }, opts...) 271 if err != nil { 272 return nil, err 273 } 274 return resp, nil 275} 276 277func (c *gRPCClient) ListJobs(ctx context.Context, req *transcoderpb.ListJobsRequest, opts ...gax.CallOption) *JobIterator { 278 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 279 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 280 opts = append((*c.CallOptions).ListJobs[0:len((*c.CallOptions).ListJobs):len((*c.CallOptions).ListJobs)], opts...) 281 it := &JobIterator{} 282 req = proto.Clone(req).(*transcoderpb.ListJobsRequest) 283 it.InternalFetch = func(pageSize int, pageToken string) ([]*transcoderpb.Job, string, error) { 284 resp := &transcoderpb.ListJobsResponse{} 285 if pageToken != "" { 286 req.PageToken = pageToken 287 } 288 if pageSize > math.MaxInt32 { 289 req.PageSize = math.MaxInt32 290 } else if pageSize != 0 { 291 req.PageSize = int32(pageSize) 292 } 293 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 294 var err error 295 resp, err = c.client.ListJobs(ctx, req, settings.GRPC...) 296 return err 297 }, opts...) 298 if err != nil { 299 return nil, "", err 300 } 301 302 it.Response = resp 303 return resp.GetJobs(), resp.GetNextPageToken(), nil 304 } 305 fetch := func(pageSize int, pageToken string) (string, error) { 306 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 307 if err != nil { 308 return "", err 309 } 310 it.items = append(it.items, items...) 311 return nextPageToken, nil 312 } 313 314 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 315 it.pageInfo.MaxSize = int(req.GetPageSize()) 316 it.pageInfo.Token = req.GetPageToken() 317 318 return it 319} 320 321func (c *gRPCClient) GetJob(ctx context.Context, req *transcoderpb.GetJobRequest, opts ...gax.CallOption) (*transcoderpb.Job, error) { 322 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 323 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 324 defer cancel() 325 ctx = cctx 326 } 327 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 328 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 329 opts = append((*c.CallOptions).GetJob[0:len((*c.CallOptions).GetJob):len((*c.CallOptions).GetJob)], opts...) 330 var resp *transcoderpb.Job 331 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 332 var err error 333 resp, err = c.client.GetJob(ctx, req, settings.GRPC...) 334 return err 335 }, opts...) 336 if err != nil { 337 return nil, err 338 } 339 return resp, nil 340} 341 342func (c *gRPCClient) DeleteJob(ctx context.Context, req *transcoderpb.DeleteJobRequest, opts ...gax.CallOption) error { 343 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 344 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 345 defer cancel() 346 ctx = cctx 347 } 348 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 349 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 350 opts = append((*c.CallOptions).DeleteJob[0:len((*c.CallOptions).DeleteJob):len((*c.CallOptions).DeleteJob)], opts...) 351 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 352 var err error 353 _, err = c.client.DeleteJob(ctx, req, settings.GRPC...) 354 return err 355 }, opts...) 356 return err 357} 358 359func (c *gRPCClient) CreateJobTemplate(ctx context.Context, req *transcoderpb.CreateJobTemplateRequest, opts ...gax.CallOption) (*transcoderpb.JobTemplate, error) { 360 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 361 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 362 defer cancel() 363 ctx = cctx 364 } 365 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 366 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 367 opts = append((*c.CallOptions).CreateJobTemplate[0:len((*c.CallOptions).CreateJobTemplate):len((*c.CallOptions).CreateJobTemplate)], opts...) 368 var resp *transcoderpb.JobTemplate 369 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 370 var err error 371 resp, err = c.client.CreateJobTemplate(ctx, req, settings.GRPC...) 372 return err 373 }, opts...) 374 if err != nil { 375 return nil, err 376 } 377 return resp, nil 378} 379 380func (c *gRPCClient) ListJobTemplates(ctx context.Context, req *transcoderpb.ListJobTemplatesRequest, opts ...gax.CallOption) *JobTemplateIterator { 381 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 382 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 383 opts = append((*c.CallOptions).ListJobTemplates[0:len((*c.CallOptions).ListJobTemplates):len((*c.CallOptions).ListJobTemplates)], opts...) 384 it := &JobTemplateIterator{} 385 req = proto.Clone(req).(*transcoderpb.ListJobTemplatesRequest) 386 it.InternalFetch = func(pageSize int, pageToken string) ([]*transcoderpb.JobTemplate, string, error) { 387 resp := &transcoderpb.ListJobTemplatesResponse{} 388 if pageToken != "" { 389 req.PageToken = pageToken 390 } 391 if pageSize > math.MaxInt32 { 392 req.PageSize = math.MaxInt32 393 } else if pageSize != 0 { 394 req.PageSize = int32(pageSize) 395 } 396 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 397 var err error 398 resp, err = c.client.ListJobTemplates(ctx, req, settings.GRPC...) 399 return err 400 }, opts...) 401 if err != nil { 402 return nil, "", err 403 } 404 405 it.Response = resp 406 return resp.GetJobTemplates(), resp.GetNextPageToken(), nil 407 } 408 fetch := func(pageSize int, pageToken string) (string, error) { 409 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 410 if err != nil { 411 return "", err 412 } 413 it.items = append(it.items, items...) 414 return nextPageToken, nil 415 } 416 417 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 418 it.pageInfo.MaxSize = int(req.GetPageSize()) 419 it.pageInfo.Token = req.GetPageToken() 420 421 return it 422} 423 424func (c *gRPCClient) GetJobTemplate(ctx context.Context, req *transcoderpb.GetJobTemplateRequest, opts ...gax.CallOption) (*transcoderpb.JobTemplate, error) { 425 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 426 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 427 defer cancel() 428 ctx = cctx 429 } 430 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 431 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 432 opts = append((*c.CallOptions).GetJobTemplate[0:len((*c.CallOptions).GetJobTemplate):len((*c.CallOptions).GetJobTemplate)], opts...) 433 var resp *transcoderpb.JobTemplate 434 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 435 var err error 436 resp, err = c.client.GetJobTemplate(ctx, req, settings.GRPC...) 437 return err 438 }, opts...) 439 if err != nil { 440 return nil, err 441 } 442 return resp, nil 443} 444 445func (c *gRPCClient) DeleteJobTemplate(ctx context.Context, req *transcoderpb.DeleteJobTemplateRequest, opts ...gax.CallOption) error { 446 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 447 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 448 defer cancel() 449 ctx = cctx 450 } 451 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 452 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 453 opts = append((*c.CallOptions).DeleteJobTemplate[0:len((*c.CallOptions).DeleteJobTemplate):len((*c.CallOptions).DeleteJobTemplate)], opts...) 454 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 455 var err error 456 _, err = c.client.DeleteJobTemplate(ctx, req, settings.GRPC...) 457 return err 458 }, opts...) 459 return err 460} 461 462// JobIterator manages a stream of *transcoderpb.Job. 463type JobIterator struct { 464 items []*transcoderpb.Job 465 pageInfo *iterator.PageInfo 466 nextFunc func() error 467 468 // Response is the raw response for the current page. 469 // It must be cast to the RPC response type. 470 // Calling Next() or InternalFetch() updates this value. 471 Response interface{} 472 473 // InternalFetch is for use by the Google Cloud Libraries only. 474 // It is not part of the stable interface of this package. 475 // 476 // InternalFetch returns results from a single call to the underlying RPC. 477 // The number of results is no greater than pageSize. 478 // If there are no more results, nextPageToken is empty and err is nil. 479 InternalFetch func(pageSize int, pageToken string) (results []*transcoderpb.Job, nextPageToken string, err error) 480} 481 482// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 483func (it *JobIterator) PageInfo() *iterator.PageInfo { 484 return it.pageInfo 485} 486 487// Next returns the next result. Its second return value is iterator.Done if there are no more 488// results. Once Next returns Done, all subsequent calls will return Done. 489func (it *JobIterator) Next() (*transcoderpb.Job, error) { 490 var item *transcoderpb.Job 491 if err := it.nextFunc(); err != nil { 492 return item, err 493 } 494 item = it.items[0] 495 it.items = it.items[1:] 496 return item, nil 497} 498 499func (it *JobIterator) bufLen() int { 500 return len(it.items) 501} 502 503func (it *JobIterator) takeBuf() interface{} { 504 b := it.items 505 it.items = nil 506 return b 507} 508 509// JobTemplateIterator manages a stream of *transcoderpb.JobTemplate. 510type JobTemplateIterator struct { 511 items []*transcoderpb.JobTemplate 512 pageInfo *iterator.PageInfo 513 nextFunc func() error 514 515 // Response is the raw response for the current page. 516 // It must be cast to the RPC response type. 517 // Calling Next() or InternalFetch() updates this value. 518 Response interface{} 519 520 // InternalFetch is for use by the Google Cloud Libraries only. 521 // It is not part of the stable interface of this package. 522 // 523 // InternalFetch returns results from a single call to the underlying RPC. 524 // The number of results is no greater than pageSize. 525 // If there are no more results, nextPageToken is empty and err is nil. 526 InternalFetch func(pageSize int, pageToken string) (results []*transcoderpb.JobTemplate, nextPageToken string, err error) 527} 528 529// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 530func (it *JobTemplateIterator) PageInfo() *iterator.PageInfo { 531 return it.pageInfo 532} 533 534// Next returns the next result. Its second return value is iterator.Done if there are no more 535// results. Once Next returns Done, all subsequent calls will return Done. 536func (it *JobTemplateIterator) Next() (*transcoderpb.JobTemplate, error) { 537 var item *transcoderpb.JobTemplate 538 if err := it.nextFunc(); err != nil { 539 return item, err 540 } 541 item = it.items[0] 542 it.items = it.items[1:] 543 return item, nil 544} 545 546func (it *JobTemplateIterator) bufLen() int { 547 return len(it.items) 548} 549 550func (it *JobTemplateIterator) takeBuf() interface{} { 551 b := it.items 552 it.items = nil 553 return b 554} 555