Documentation ¶
Index ¶
- type AdaptiveTimeoutConfig
- type AdaptiveTimeoutManager
- func (tm *AdaptiveTimeoutManager) Dispatch()
- func (tm *AdaptiveTimeoutManager) Initialize(config *AdaptiveTimeoutConfig, metricsNamespace string, ...) error
- func (tm *AdaptiveTimeoutManager) ObserveLatency(latency time.Duration)
- func (tm *AdaptiveTimeoutManager) Put(id ids.ID, op message.Op, timeoutHandler func()) time.Time
- func (tm *AdaptiveTimeoutManager) Remove(id ids.ID)
- func (tm *AdaptiveTimeoutManager) Stop()
- func (tm *AdaptiveTimeoutManager) Timeout()
- func (tm *AdaptiveTimeoutManager) TimeoutDuration() time.Duration
- type Meter
- type Repeater
- type TimedMeter
- type TimeoutManager
- type Timer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdaptiveTimeoutConfig ¶ added in v0.8.0
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.8.0
type AdaptiveTimeoutManager struct {
// contains filtered or unexported fields
}
AdaptiveTimeoutManager is a manager for timeouts.
func (*AdaptiveTimeoutManager) Dispatch ¶ added in v0.8.0
func (tm *AdaptiveTimeoutManager) Dispatch()
func (*AdaptiveTimeoutManager) Initialize ¶ added in v0.8.0
func (tm *AdaptiveTimeoutManager) Initialize( config *AdaptiveTimeoutConfig, metricsNamespace string, metricsRegister prometheus.Registerer, ) error
Initialize this timeout manager with the provided config
func (*AdaptiveTimeoutManager) ObserveLatency ¶ added in v1.2.1
func (tm *AdaptiveTimeoutManager) ObserveLatency(latency time.Duration)
ObserveLatency allows the caller to manually register 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.
func (*AdaptiveTimeoutManager) Put ¶ added in v0.8.0
Put registers a timeout for [id]. If the timeout occurs, [timeoutHandler] is called. Returns the time at which the timeout will fire if it is not first removed by calling [tm.Remove].
func (*AdaptiveTimeoutManager) Remove ¶ added in v0.8.0
func (tm *AdaptiveTimeoutManager) Remove(id ids.ID)
Remove the timeout associated with [id]. Its timeout handler will not be called.
func (*AdaptiveTimeoutManager) Stop ¶ added in v0.8.0
func (tm *AdaptiveTimeoutManager) Stop()
Stop executing timeouts
func (*AdaptiveTimeoutManager) Timeout ¶ added in v0.8.0
func (tm *AdaptiveTimeoutManager) Timeout()
Timeout registers a timeout
func (*AdaptiveTimeoutManager) TimeoutDuration ¶ added in v1.2.1
func (tm *AdaptiveTimeoutManager) TimeoutDuration() time.Duration
TimeoutDuration returns the current network timeout duration
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 Repeater ¶
type Repeater struct {
// contains filtered or unexported fields
}
func NewRepeater ¶
type TimedMeter ¶
type TimedMeter struct { // Can be used to fake time in tests Clock *mockable.Clock // Amount of time to keep a tick Duration time.Duration // contains filtered or unexported fields }
TimedMeter is a meter that discards old events
type TimeoutManager ¶
type TimeoutManager struct {
// contains filtered or unexported fields
}
TimeoutManager is a manager for timeouts.
func (*TimeoutManager) Dispatch ¶
func (tm *TimeoutManager) Dispatch()
func (*TimeoutManager) Initialize ¶
func (tm *TimeoutManager) Initialize(duration time.Duration)
Initialize is a constructor b/c Golang, in its wisdom, doesn't ... have them?
func (*TimeoutManager) Put ¶
func (tm *TimeoutManager) Put(id ids.ID, handler func())
Put puts hash into the hash map
func (*TimeoutManager) Remove ¶
func (tm *TimeoutManager) Remove(id ids.ID)
Remove the item that no longer needs to be there.
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 ¶ added in v1.4.5
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.
func (*Timer) SetTimeoutIn ¶
SetTimeoutIn will set the timer to fire the handler in [duration]