Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config[PT item[T], T any] struct { Logger logger.Logger // CreateFunc is used to create pool item. // Timeout is not set as context.WithTimeout // because this is running context for long-lived item. // Timeout itself should limit only creation steps, // and it is responsibility of CreateFunc to handle it appropriately. CreateFunc func(ctx context.Context, createTimeout time.Duration) (PT, error) // CreateTimeout limits runtime for CreateFunc. // This timeout cannot be less than a second (minCreateTimeout). // Default is 3 seconds (defaultCreateTimeout). CreateTimeout time.Duration // Lifetime specifies item lifetime after which it will be closed // and new item will be created instead. // 0 lifetime means item has infinite lifetime and item recycling // is not running. // Lifetime cannot be greater than 0 and less than 5 seconds (minItemLifetime). Lifetime time.Duration // RecycleWindow specifies time interval for item recycling: // [Lifetime-RecycleWindow;Lifetime+RecycleWindow] // This prevents items to all be recycled in the same time. RecycleWindow time.Duration // PoolSize specifies amount of items in pool. PoolSize uint }
Config holds pool configuration.
Click to show internal directories.
Click to hide internal directories.