| 57 | } |
| 58 | |
| 59 | func validateVMPoolConfig(config *VMPoolConfig) { |
| 60 | if config == nil { |
| 61 | panic("VM pool config is required") |
| 62 | } |
| 63 | if config.MaxTotal <= 0 { |
| 64 | panic("MaxTotal must be greater than zero") |
| 65 | } |
| 66 | if config.MaxIdle < 0 { |
| 67 | panic("MaxIdle must not be negative") |
| 68 | } |
| 69 | if config.MinIdle < 0 { |
| 70 | panic("MinIdle must not be negative") |
| 71 | } |
| 72 | if config.MaxIdle < config.MinIdle { |
| 73 | panic("MaxIdle must be greater than or equal to MinIdle") |
| 74 | } |
| 75 | if config.MaxTotal < config.MinIdle { |
| 76 | panic("MaxTotal must be greater than or equal to MinIdle") |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | func cleanPeriod(idleTime time.Duration) time.Duration { |
| 81 | period := idleTime / 2 |