...

Source file src/edge-infra.dev/pkg/edge/rollouts/options.go

Documentation: edge-infra.dev/pkg/edge/rollouts

     1  package rollouts
     2  
     3  import "time"
     4  
     5  type TimeSource interface {
     6  	Now() time.Time
     7  }
     8  
     9  type Option func(*options)
    10  
    11  func WithTimeSource(ts TimeSource) Option {
    12  	return func(o *options) {
    13  		o.timeSource = ts
    14  	}
    15  }
    16  
    17  type options struct {
    18  	timeSource TimeSource
    19  }
    20  
    21  func makeOptions(opts ...Option) *options {
    22  	o := &options{
    23  		timeSource: defaultTimeSource{},
    24  	}
    25  	for _, opt := range opts {
    26  		opt(o)
    27  	}
    28  	return o
    29  }
    30  
    31  type defaultTimeSource struct{}
    32  
    33  func (d defaultTimeSource) Now() time.Time {
    34  	return time.Now()
    35  }
    36  

View as plain text