Source File
options.go
Belonging Package
github.com/libp2p/go-libp2p/p2p/net/connmgr
package connmgrimport ()// config is the configuration struct for the basic connection manager.type config struct {highWater intlowWater intgracePeriod time.DurationsilencePeriod time.Durationdecayer *DecayerCfgclock clock.Clock}// Option represents an option for the basic connection manager.type Option func(*config) error// DecayerConfig applies a configuration for the decayer.func ( *DecayerCfg) Option {return func( *config) error {.decayer =return nil}}// WithClock sets the internal clock implfunc ( clock.Clock) Option {return func( *config) error {.clock =return nil}}// WithGracePeriod sets the grace period.// The grace period is the time a newly opened connection is given before it becomes// subject to pruning.func ( time.Duration) Option {return func( *config) error {if < 0 {return errors.New("grace period must be non-negative")}.gracePeriod =return nil}}// WithSilencePeriod sets the silence period.// The connection manager will perform a cleanup once per silence period// if the number of connections surpasses the high watermark.func ( time.Duration) Option {return func( *config) error {if <= 0 {return errors.New("silence period must be non-zero")}.silencePeriod =return nil}}
![]() |
The pages are generated with Golds v0.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. |