9
9
10
10
package it.unibo.alchemist.boundary.monitors
11
11
12
- import io.ktor.server.engine.ApplicationEngine
12
+ import io.ktor.server.engine.EmbeddedServer
13
13
import io.ktor.server.engine.embeddedServer
14
14
import io.ktor.server.netty.Netty
15
+ import io.ktor.server.netty.NettyApplicationEngine
15
16
import it.unibo.alchemist.boundary.OutputMonitor
16
17
import it.unibo.alchemist.boundary.graphql.monitor.EnvironmentSubscriptionMonitor
17
18
import it.unibo.alchemist.boundary.graphql.server.modules.graphQLModule
@@ -36,14 +37,14 @@ private val logger = LoggerFactory.getLogger(GraphQLMonitor::class.java)
36
37
*/
37
38
class GraphQLMonitor <T , P : Position <out P >> @JvmOverloads constructor(
38
39
val environment : Environment <T , P >,
39
- val host : String = DefaultGraphQLSettings .DEFAULT_HOST ,
40
- val port : Int = DefaultGraphQLSettings .DEFAULT_PORT ,
41
- val teardownOnSimulationTermination : Boolean = true ,
40
+ private val host : String = DefaultGraphQLSettings .DEFAULT_HOST ,
41
+ private val port : Int = DefaultGraphQLSettings .DEFAULT_PORT ,
42
+ private val teardownOnSimulationTermination : Boolean = true ,
42
43
private val serverDispatcher : CoroutineDispatcher = Dispatchers .Default ,
43
44
) : OutputMonitor<Any, Nothing> {
44
45
45
46
private val subscriptionMonitor = EnvironmentSubscriptionMonitor <Any , Nothing >()
46
- private lateinit var server: ApplicationEngine
47
+ private lateinit var server: EmbeddedServer < NettyApplicationEngine , NettyApplicationEngine . Configuration >
47
48
48
49
override fun initialized (environment : Environment <Any , Nothing >) {
49
50
environment.simulation.addOutputMonitor(subscriptionMonitor)
@@ -61,7 +62,7 @@ class GraphQLMonitor<T, P : Position<out P>> @JvmOverloads constructor(
61
62
" alchemist-graphql-server@$host :$port " ,
62
63
).start()
63
64
runBlocking {
64
- logger.info(" Starting GraphQL server at $host :${server.resolvedConnectors().first().port} " )
65
+ logger.info(" Starting GraphQL server at $host :${server.engine. resolvedConnectors().first().port} " )
65
66
}
66
67
mutex.acquireUninterruptibly()
67
68
}
@@ -72,14 +73,13 @@ class GraphQLMonitor<T, P : Position<out P>> @JvmOverloads constructor(
72
73
}
73
74
}
74
75
75
- private fun makeServer (): ApplicationEngine =
76
- embeddedServer(
77
- Netty ,
78
- port = port,
79
- host = host,
80
- module = {
81
- graphQLModule(this @GraphQLMonitor.environment)
82
- graphQLRoutingModule()
83
- },
84
- )
76
+ private fun makeServer () = embeddedServer(
77
+ Netty ,
78
+ port = port,
79
+ host = host,
80
+ module = {
81
+ graphQLModule(this @GraphQLMonitor.environment)
82
+ graphQLRoutingModule()
83
+ },
84
+ )
85
85
}
0 commit comments