File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
openai-guice/src/main/scala/io/cequence/openaiscala/service Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -3,21 +3,17 @@ package io.cequence.openaiscala.service
3
3
import akka .actor .ActorSystem
4
4
import com .google .inject .{Guice , Injector , Module }
5
5
import com .typesafe .config .Config
6
- import net .codingwell .scalaguice .InjectorExtensions ._
7
- import scala .concurrent .duration ._
8
6
7
+ import scala .concurrent .duration ._
9
8
import scala .concurrent .{Await , Future }
9
+ import scala .reflect .ClassTag
10
10
11
11
trait GuiceContainer {
12
12
13
- protected def modules : Seq [Module ]
14
-
15
13
protected lazy val injector : Injector = Guice .createInjector(modules : _* )
16
-
17
14
protected lazy val config : Config = instance[Config ]
18
15
19
- // TODO: for Scala3 this function has to be "inlined"
20
- protected def instance [T : Manifest ]: T = injector.instance[T ]
16
+ protected def modules : Seq [Module ]
21
17
22
18
protected def result [T ](future : Future [T ]): T =
23
19
Await .result(future, 100 .minutes)
@@ -27,4 +23,8 @@ trait GuiceContainer {
27
23
system.terminate
28
24
Await .result(system.whenTerminated, 1 .day)
29
25
}
26
+
27
+ protected def instance [T : ClassTag ]: T = injector.getInstance(
28
+ implicitly[ClassTag [T ]].runtimeClass.asInstanceOf [Class [T ]]
29
+ )
30
30
}
You can’t perform that action at this time.
0 commit comments