github.com/searKing/golang/go@v1.2.117/time/exponentialbackoff_options.go (about)

     1  // Copyright 2020 The searKing Author. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Code generated by "go-option -type ExponentialBackOff"; DO NOT EDIT.
     6  
     7  package time
     8  
     9  var _default_ExponentialBackOff_value = func() (val ExponentialBackOff) { return }()
    10  
    11  // A ExponentialBackOffOption sets options.
    12  type ExponentialBackOffOption interface {
    13  	apply(*ExponentialBackOff)
    14  }
    15  
    16  // EmptyExponentialBackOffOption does not alter the configuration. It can be embedded
    17  // in another structure to build custom options.
    18  //
    19  // This API is EXPERIMENTAL.
    20  type EmptyExponentialBackOffOption struct{}
    21  
    22  func (EmptyExponentialBackOffOption) apply(*ExponentialBackOff) {}
    23  
    24  // ExponentialBackOffOptionFunc wraps a function that modifies ExponentialBackOff into an
    25  // implementation of the ExponentialBackOffOption interface.
    26  type ExponentialBackOffOptionFunc func(*ExponentialBackOff)
    27  
    28  func (f ExponentialBackOffOptionFunc) apply(do *ExponentialBackOff) {
    29  	f(do)
    30  }
    31  
    32  // sample code for option, default for nothing to change
    33  func _ExponentialBackOffOptionWithDefault() ExponentialBackOffOption {
    34  	return ExponentialBackOffOptionFunc(func(*ExponentialBackOff) {
    35  		// nothing to change
    36  	})
    37  }
    38  
    39  func (o *ExponentialBackOff) ApplyOptions(options ...ExponentialBackOffOption) *ExponentialBackOff {
    40  	for _, opt := range options {
    41  		if opt == nil {
    42  			continue
    43  		}
    44  		opt.apply(o)
    45  	}
    46  	return o
    47  }