@@ -11,71 +11,34 @@ import io.ktor.server.routing.get
11
11
import io.ktor.server.routing.post
12
12
import io.ktor.server.routing.route
13
13
import io.ktor.server.routing.routing
14
+ import no.java.conf.config.SearchClientConfig
15
+ import no.java.conf.config.SearchServiceConfig
14
16
import no.java.conf.model.search.TextSearchRequest
15
17
import no.java.conf.service.SearchService
16
- import no.java.conf.service.search.ElasticIndexer
17
- import no.java.conf.service.search.ElasticIngester
18
- import no.java.conf.service.search.ElasticSearcher
19
18
20
19
private val logger = KotlinLogging .logger {}
21
20
22
- fun searchClient (
23
- host : String ,
24
- port : Int ,
25
- username : String ,
26
- password : String
27
- ): SearchClient {
28
- logger.info { " Connection Info: $host :$port with $username " }
21
+ fun searchClient (config : SearchClientConfig ): SearchClient {
22
+ logger.info { " Connection Info: $config " }
29
23
30
24
return SearchClient (
31
25
KtorRestClient (
32
- host = host,
33
- port = port,
34
- user = username,
35
- password = password,
26
+ host = config. host,
27
+ port = config. port,
28
+ user = config. username,
29
+ password = config. password,
36
30
),
37
31
)
38
32
}
39
33
40
- fun Application.searchClient () =
41
- searchClient(
42
- host = environment.config.property(" elastic.host" ).getString(),
43
- port =
44
- environment.config
45
- .property(" elastic.port" )
46
- .getString()
47
- .toInt(),
48
- username = environment.config.property(" elastic.username" ).getString(),
49
- password = environment.config.property(" elastic.password" ).getString(),
34
+ fun searchService (config : SearchServiceConfig ) =
35
+ SearchService (
36
+ indexer = config.indexer,
37
+ ingester = config.ingester,
38
+ searcher = config.searcher,
39
+ skipIndex = config.skipIndex,
50
40
)
51
41
52
- fun searchService (
53
- indexer : ElasticIndexer ,
54
- ingester : ElasticIngester ,
55
- searcher : ElasticSearcher ,
56
- skipIndex : Boolean
57
- ) = SearchService (
58
- indexer = indexer,
59
- ingester = ingester,
60
- searcher = searcher,
61
- skipIndex = skipIndex,
62
- )
63
-
64
- fun Application.searchService (): SearchService {
65
- val searchClient = searchClient()
66
-
67
- return searchService(
68
- indexer = ElasticIndexer (searchClient),
69
- ingester = ElasticIngester (searchClient),
70
- searcher = ElasticSearcher (searchClient),
71
- skipIndex =
72
- environment.config
73
- .property(" elastic.skipindex" )
74
- .getString()
75
- .toBoolean()
76
- )
77
- }
78
-
79
42
fun Application.configureSearchRouting (service : SearchService ) {
80
43
routing {
81
44
route(" /api/search" ) {
0 commit comments