Skip to content

Commit

Permalink
Add more type
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuancelin committed Nov 22, 2023
1 parent 24da5dc commit d7769cc
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion src/main/scala/io/otoroshi/wasm4s/scaladsl/integration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class BasicWasmIntegrationContextWithNoHttpClient[A <: WasmConfiguration](name:
Executors.newWorkStealingPool(Math.max(32, (Runtime.getRuntime.availableProcessors * 4) + 1))
)

override def url(path: String, tlsConfigOpt: Option[TlsConfig] = None): WSRequest = ???
override def url(path: String, tlsConfigOpt: Option[TlsConfig] = None): WSRequest = throw new RuntimeException("BasicWasmIntegrationContextWithNoHttpClient does not provide an httpclient implementation")

override def wasmConfigSync(path: String): Option[WasmConfiguration] = store.wasmConfiguration(path)
override def wasmConfigs(): Future[Seq[WasmConfiguration]] = store.wasmConfigurations().vfuture
Expand Down Expand Up @@ -198,3 +198,42 @@ class WasmIntegration(ic: WasmIntegrationContext) {
().vfuture
}
}

abstract class DefaultWasmIntegrationContext[A <: WasmConfiguration](
val name: String,
val wasmCacheTtl: Long = 30000,
val wasmQueueBufferSize: Int = 100,
val maxWorkers: Int = Math.max(32, (Runtime.getRuntime.availableProcessors * 4) + 1),
val selfRefreshingPools: Boolean = false,
val wasmoSettings: Option[WasmManagerSettings] = None,
) extends WasmIntegrationContext {
val system = ActorSystem(name)
val materializer: Materializer = Materializer(system)
val executionContext: ExecutionContext = system.dispatcher
val logger: Logger = Logger(name)
val wasmManagerSettings: Future[Option[WasmManagerSettings]] = Future.successful(wasmoSettings)
val wasmScriptCache: TrieMap[String, CacheableWasmScript] = new TrieMap[String, CacheableWasmScript]()
val wasmExecutor: ExecutionContext = ExecutionContext.fromExecutorService(
Executors.newWorkStealingPool(maxWorkers)
)
}

abstract class DefaultWasmIntegrationContextWithNoHttpClient[A <: WasmConfiguration](
val name: String,
val wasmCacheTtl: Long = 30000,
val wasmQueueBufferSize: Int = 100,
val maxWorkers: Int = Math.max(32, (Runtime.getRuntime.availableProcessors * 4) + 1),
val selfRefreshingPools: Boolean = false,
val wasmoSettings: Option[WasmManagerSettings] = None,
) extends WasmIntegrationContext {
val system = ActorSystem(name)
val materializer: Materializer = Materializer(system)
val executionContext: ExecutionContext = system.dispatcher
val logger: Logger = Logger(name)
val wasmManagerSettings: Future[Option[WasmManagerSettings]] = Future.successful(wasmoSettings)
val wasmScriptCache: TrieMap[String, CacheableWasmScript] = new TrieMap[String, CacheableWasmScript]()
val wasmExecutor: ExecutionContext = ExecutionContext.fromExecutorService(
Executors.newWorkStealingPool(maxWorkers)
)
override def url(path: String, tlsConfigOpt: Option[TlsConfig] = None): WSRequest = throw new RuntimeException("DefaultWasmIntegrationContextWithNoHttpClient does not provide an httpclient implementation")
}

0 comments on commit d7769cc

Please sign in to comment.