package connmgrimport ()// DecayNone applies no decay.func () DecayFn {returnfunc( DecayingValue) ( int, bool) {return .Value, false }}// DecayFixed subtracts from by the provided minuend, and deletes the tag when// first reaching 0 or negative.func ( int) DecayFn {returnfunc( DecayingValue) ( int, bool) { := .Value - return , <= 0 }}// DecayLinear applies a fractional coefficient to the value of the current tag,// rounding down via math.Floor. It erases the tag when the result is zero.func ( float64) DecayFn {returnfunc( DecayingValue) ( int, bool) { := math.Floor(float64(.Value) * )returnint(), <= 0 }}// DecayExpireWhenInactive expires a tag after a certain period of no bumps.func ( time.Duration) DecayFn {returnfunc( DecayingValue) ( int, bool) { = time.Until(.LastVisit) >= return0, }}// BumpSumUnbounded adds the incoming value to the peer's score.func () BumpFn {returnfunc( DecayingValue, int) ( int) {return .Value + }}// BumpSumBounded keeps summing the incoming score, keeping it within a// [min, max] range.func (, int) BumpFn {returnfunc( DecayingValue, int) ( int) { := .Value + if >= {return } elseif <= {return }return }}// BumpOverwrite replaces the current value of the tag with the incoming one.func () BumpFn {returnfunc( DecayingValue, int) ( int) {return }}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.