File tree Expand file tree Collapse file tree
modules/server/src/main/scala/es/weso/rdfshape/server
api/routes/schema/logic/operations/stream/transformations Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -179,6 +179,11 @@ object Server {
179179 */
180180 val defaultVerbosity = 0
181181
182+ /** Environment variable checked by the app to know how long to keep waiting for
183+ * items coming via stream
184+ */
185+ val envVarStreamTimeout = " STREAM_TIMEOUT"
186+
182187 /** System property checked by the app to know how long to keep waiting for
183188 * items coming via stream
184189 */
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import cats.effect.IO
44import com .typesafe .scalalogging .LazyLogging
55import es .weso .rdfshape .server .Server .{
66 defaultStreamTimeout ,
7+ envVarStreamTimeout ,
78 systemPropertyStreamTimeout
89}
910import es .weso .rdfshape .server .api .routes .schema .logic .operations .stream .configuration .{
@@ -56,10 +57,19 @@ private[schema] object CometTransformations extends LazyLogging {
5657 * Retrieved from a system property which can be overridden by CLI args.
5758 */
5859 private lazy val timeout = {
59- val timeoutFromSystemProp =
60- Integer
61- .getInteger(systemPropertyStreamTimeout, defaultStreamTimeout)
62- .toLong
60+ val timeoutFromSystemProp = {
61+ // Try to fetch in env vars
62+ Option (System .getenv(envVarStreamTimeout))
63+ .flatMap(_.toIntOption)
64+ .map(_.toLong)
65+ // Else fetch from system properties, resorting to the default value
66+ // if none is found/parseable
67+ .getOrElse(
68+ Integer
69+ .getInteger(systemPropertyStreamTimeout, defaultStreamTimeout)
70+ .toLong
71+ )
72+ }
6373
6474 FiniteDuration (timeoutFromSystemProp, SECONDS )
6575 }
You can’t perform that action at this time.
0 commit comments