Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EstimateETA ¶ added in v0.1.1
EstimateETA attempts to estimate the remaining time for a job to finish given the [startTime] and it's current progress.
func ProgressFromHash ¶ added in v0.1.1
ProgressFromHash returns the progress out of MaxUint64 assuming [b] is a key in a uniformly distributed sequence that is being iterated lexicographically.
func StoppedTimer ¶ added in v0.1.1
StoppedTimer returns a stopped timer so that there is no entry on the C channel (and there isn't one scheduled to be added).
This means that after calling Reset there will be no events on the channel until the timer fires (at which point there will be exactly one event sent to the channel).
It enables re-using the timer across loop iterations without needing to have the first loop iteration perform any == nil checks to initialize the first invocation.
Types ¶
type AdaptiveTimeoutConfig ¶ added in v0.1.1
type AdaptiveTimeoutConfig struct {
InitialTimeout time.Duration `json:"initialTimeout"`
MinimumTimeout time.Duration `json:"minimumTimeout"`
MaximumTimeout time.Duration `json:"maximumTimeout"`
// Timeout is [timeoutCoefficient] * average response time
// [timeoutCoefficient] must be > 1
TimeoutCoefficient float64 `json:"timeoutCoefficient"`
// Larger halflife --> less volatile timeout
// [timeoutHalfLife] must be positive
TimeoutHalflife time.Duration `json:"timeoutHalflife"`
}
AdaptiveTimeoutConfig contains the parameters provided to the adaptive timeout manager.
type AdaptiveTimeoutManager ¶ added in v0.1.1
type AdaptiveTimeoutManager interface {
// Start the timeout manager.
// Must be called before any other method.
// Must only be called once.
Dispatch()
// Stop the timeout manager.
// Must only be called once.
Stop()
// Returns the current network timeout duration.
TimeoutDuration() time.Duration
// Registers a timeout for the item with the given [id].
// If the timeout occurs before the item is Removed, [timeoutHandler] is called.
Put(id ids.RequestID, measureLatency bool, timeoutHandler func())
// Remove the timeout associated with [id].
// Its timeout handler will not be called.
Remove(id ids.RequestID)
// ObserveLatency manually registers a response latency.
// We use this to pretend that it a query to a benched validator
// timed out when actually, we never even sent them a request.
ObserveLatency(latency time.Duration)
}
func NewAdaptiveTimeoutManager ¶ added in v0.1.1
func NewAdaptiveTimeoutManager( config *AdaptiveTimeoutConfig, reg metric.Registerer, ) (AdaptiveTimeoutManager, error)
type EtaTracker ¶ added in v1.16.56
type EtaTracker struct {
// contains filtered or unexported fields
}
EtaTracker provides exponentially weighted moving average ETA estimates
func NewEtaTracker ¶ added in v1.16.56
func NewEtaTracker(samples int, alpha float64) *EtaTracker
NewEtaTracker creates a new ETA tracker with the given number of samples and alpha
func (*EtaTracker) AddSample ¶ added in v1.16.56
func (e *EtaTracker) AddSample(progress, total uint64, sampleTime time.Time) (*time.Duration, float64)
AddSample adds a sample to the ETA tracker and returns ETA pointer and progress percentage
func (*EtaTracker) ETA ¶ added in v1.16.56
func (e *EtaTracker) ETA(progress, total uint64) time.Duration
ETA returns the estimated time remaining
func (*EtaTracker) Update ¶ added in v1.16.56
func (e *EtaTracker) Update(progress, total uint64)
Update updates the ETA tracker with new progress
type Meter ¶
type Meter interface {
// Notify this meter of a new event for it to rate
Tick()
// Return the number of events this meter is currently tracking
Ticks() int
}
Meter tracks the number of occurrences of a specified event
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer wraps a timer object. This allows a user to specify a handler. Once specifying the handler, the dispatch thread can be called. The dispatcher will only return after calling Stop. SetTimeoutIn will result in calling the handler in the specified amount of time.
func NewStagedTimer
deprecated
added in
v1.1.11
NewStagedTimer returns a timer that will execute [f] when a timeout occurs and execute an additional timeout after the returned duration if [f] returns true and some duration.
Deprecated: NewStagedTimer exists for historical compatibility and should not be used.
func (*Timer) SetTimeoutIn ¶
SetTimeoutIn will set the timer to fire the handler in [duration]