1 /*
2  *  Make.org Core API
3  *  Copyright (C) 2018 Make.org
4  *
5  * This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU Affero General Public License as
7  *  published by the Free Software Foundation, either version 3 of the
8  *  License, or (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU Affero General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Affero General Public License
16  *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  *
18  */
19 
20 package org.make.api.technical.sequence
21 
22 import com.typesafe.config.Config
23 import eu.timepit.refined.numeric.Positive
24 import eu.timepit.refined.refineV
25 import eu.timepit.refined.types.numeric.PosInt
26 
27 import java.util.concurrent.TimeUnit
28 import scala.concurrent.duration.{Duration, FiniteDuration}
29 
30 class SequenceCacheConfiguration(config: Config) {
31   val inactivityTimeout: FiniteDuration =
32     FiniteDuration(Duration(config.getString("inactivity-timeout")).toMillis, TimeUnit.MILLISECONDS)
33   val checkInactivityTimer: FiniteDuration =
34     FiniteDuration(Duration(config.getString("check-inactivity-timer")).toMillis, TimeUnit.MILLISECONDS)
35   val proposalsPoolSize: PosInt = refineV[Positive].unsafeFrom(config.getInt("proposals-pool-size"))
36   val cacheRefreshCycles: Int = config.getInt("cache-refresh-cycles")
37 }
38 
39 trait SequenceCacheConfigurationComponent {
40   def sequenceCacheConfiguration: SequenceCacheConfiguration
41 }
Line Stmt Id Pos Tree Symbol Tests Code
32 307 1164 - 1202 Apply com.typesafe.config.Config.getString org.make.api.sequence.sequencecacheactortest SequenceCacheConfiguration.this.config.getString("inactivity-timeout")
32 121 1214 - 1235 Literal <nosymbol> org.make.api.sequence.sequencecacheactortest MILLISECONDS
32 180 1155 - 1212 Select scala.concurrent.duration.Duration.toMillis org.make.api.sequence.sequencecacheactortest scala.concurrent.duration.Duration.apply(SequenceCacheConfiguration.this.config.getString("inactivity-timeout")).toMillis
32 314 1140 - 1236 Apply scala.concurrent.duration.FiniteDuration.apply org.make.api.sequence.sequencecacheactortest scala.concurrent.duration.FiniteDuration.apply(scala.concurrent.duration.Duration.apply(SequenceCacheConfiguration.this.config.getString("inactivity-timeout")).toMillis, MILLISECONDS)
34 227 1286 - 1386 Apply scala.concurrent.duration.FiniteDuration.apply org.make.api.sequence.sequencecacheactortest scala.concurrent.duration.FiniteDuration.apply(scala.concurrent.duration.Duration.apply(SequenceCacheConfiguration.this.config.getString("check-inactivity-timer")).toMillis, MILLISECONDS)
34 80 1301 - 1362 Select scala.concurrent.duration.Duration.toMillis org.make.api.sequence.sequencecacheactortest scala.concurrent.duration.Duration.apply(SequenceCacheConfiguration.this.config.getString("check-inactivity-timer")).toMillis
34 199 1310 - 1352 Apply com.typesafe.config.Config.getString org.make.api.sequence.sequencecacheactortest SequenceCacheConfiguration.this.config.getString("check-inactivity-timer")
34 272 1364 - 1385 Literal <nosymbol> org.make.api.sequence.sequencecacheactortest MILLISECONDS
35 200 1449 - 1449 Select scala.math.Numeric.IntIsIntegral org.make.api.sequence.sequencecacheactortest math.this.Numeric.IntIsIntegral
35 176 1449 - 1449 Select shapeless.ops.nat.ToInt.toInt0 org.make.api.sequence.sequencecacheactortest nat.this.ToInt.toInt0
35 283 1421 - 1487 ApplyToImplicitArgs eu.timepit.refined.internal.RefinePartiallyApplied.unsafeFrom org.make.api.sequence.sequencecacheactortest eu.timepit.refined.`package`.refineV[eu.timepit.refined.numeric.Positive].unsafeFrom[Int](SequenceCacheConfiguration.this.config.getInt("proposals-pool-size"))(numeric.this.Greater.greaterValidate[Int, shapeless.nat._0](internal.this.WitnessAs.natWitnessAs[Int, shapeless.nat._0](shapeless.this.Witness.witness0, nat.this.ToInt.toInt0, math.this.Numeric.IntIsIntegral), math.this.Numeric.IntIsIntegral))
35 328 1449 - 1449 ApplyToImplicitArgs eu.timepit.refined.internal.WitnessAs.natWitnessAs org.make.api.sequence.sequencecacheactortest internal.this.WitnessAs.natWitnessAs[Int, shapeless.nat._0](shapeless.this.Witness.witness0, nat.this.ToInt.toInt0, math.this.Numeric.IntIsIntegral)
35 94 1450 - 1486 Apply com.typesafe.config.Config.getInt org.make.api.sequence.sequencecacheactortest SequenceCacheConfiguration.this.config.getInt("proposals-pool-size")
35 103 1449 - 1449 Select scala.math.Numeric.IntIsIntegral org.make.api.sequence.sequencecacheactortest math.this.Numeric.IntIsIntegral
35 81 1449 - 1449 ApplyToImplicitArgs eu.timepit.refined.numeric.Greater.greaterValidate org.make.api.sequence.sequencecacheactortest numeric.this.Greater.greaterValidate[Int, shapeless.nat._0](internal.this.WitnessAs.natWitnessAs[Int, shapeless.nat._0](shapeless.this.Witness.witness0, nat.this.ToInt.toInt0, math.this.Numeric.IntIsIntegral), math.this.Numeric.IntIsIntegral)
35 302 1449 - 1449 Select shapeless.Witness.witness0 org.make.api.sequence.sequencecacheactortest shapeless.this.Witness.witness0
36 208 1520 - 1557 Apply com.typesafe.config.Config.getInt org.make.api.sequence.sequencecacheactortest SequenceCacheConfiguration.this.config.getInt("cache-refresh-cycles")