You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* This program is free software: you can redistribute it and/or modify
5
+
* it under the terms of the GNU General Public License as published by
6
+
* the Free Software Foundation, either version 3 of the License, or
7
+
* (at your option) any later version.
8
+
*
9
+
* This program is distributed in the hope that it will be useful,
10
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+
* GNU General Public License for more details.
13
+
*
14
+
* You should have received a copy of the GNU General Public License
15
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
*/
17
+
18
+
packagecom.lambda.config.settings
19
+
20
+
importcom.lambda.util.extension.highestUnit
21
+
importcom.lambda.util.extension.symbol
22
+
importkotlin.time.Duration
23
+
importkotlin.time.DurationUnit
24
+
importkotlin.time.toDuration
25
+
26
+
classDurationSetting(
27
+
overridevalname:String,
28
+
privatevaldefaultValue:Duration,
29
+
overridevalrange:ClosedRange<Duration>,
30
+
overridevalstep:Duration = 1.toDuration(defaultValue.highestUnit), // FixMe: Causes issues if the lower bound of the range is less than the step duration unit
31
+
// Ex: 60.microseconds..10.minutes will have a step of 1 minute
32
+
// Maybe we should leave this as is for the default behavior
33
+
description:String,
34
+
visibility: () ->Boolean,
35
+
) : NumericSetting<Duration>(
36
+
defaultValue,
37
+
range,
38
+
step,
39
+
description,
40
+
visibility,
41
+
"",
42
+
) {
43
+
// ToDo:
44
+
// Should we determine the unit from the step since this is the in/decrement value within the range so it would make sense to use that for the unit inference
privateval limit by setting("Limit", 99, 1..100, 1, "The maximum amount of packets to send per given time interval", unit =" packets")
38
40
.onValueChange { _, to -> packetQueue.setSizeLimit(to) }
39
41
40
-
privateval interval by setting("Duration", 4000L, 1L..10000L, 50L, "The interval / duration in milliseconds to limit packets for", unit =" ms")
42
+
privateval interval by setting("Duration", 4.seconds, 1.milliseconds..10.seconds, 50.milliseconds, "The interval / duration in milliseconds to limit packets for")
41
43
.onValueChange { _, to -> packetQueue.setDecayTime(to) }
0 commit comments