Skip to content

Commit 633731a

Browse files
committed
Refactor InternalResultServices
- Deleted RabbitMQ-related configurations, services, models, listeners, and associated event handling logic. - Removed AMQP client implementation, event bus dependencies, and integration tests. - Refactored remaining components to eliminate references to `InternalResultServices`, `eventBus`, and AMQP-related environments. - Replace property `internalResultServices` by `databases` that now include `twincache` configuration and `storage` configuration - Adjust configurations
1 parent cfc2c38 commit 633731a

File tree

37 files changed

+504
-962
lines changed

37 files changed

+504
-962
lines changed

api/src/integrationTest/kotlin/com/cosmotech/api/home/ControllerTestBase.kt

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -150,28 +150,14 @@ abstract class ControllerTestBase : AbstractTestcontainersRedisTestBase() {
150150
}
151151

152152
private fun initPostgresConfiguration(registry: DynamicPropertyRegistry) {
153-
registry.add("csm.platform.internalResultServices.storage.host") { postgres.host }
154-
registry.add("csm.platform.internalResultServices.storage.port") {
155-
postgres.getMappedPort(POSTGRESQL_PORT)
156-
}
157-
registry.add("csm.platform.internalResultServices.storage.admin.username") {
158-
ADMIN_USER_CREDENTIALS
159-
}
160-
registry.add("csm.platform.internalResultServices.storage.admin.password") {
161-
ADMIN_USER_CREDENTIALS
162-
}
163-
registry.add("csm.platform.internalResultServices.storage.writer.username") {
164-
WRITER_USER_CREDENTIALS
165-
}
166-
registry.add("csm.platform.internalResultServices.storage.writer.password") {
167-
WRITER_USER_CREDENTIALS
168-
}
169-
registry.add("csm.platform.internalResultServices.storage.reader.username") {
170-
READER_USER_CREDENTIALS
171-
}
172-
registry.add("csm.platform.internalResultServices.storage.reader.password") {
173-
READER_USER_CREDENTIALS
174-
}
153+
registry.add("csm.platform.databases.data.host") { postgres.host }
154+
registry.add("csm.platform.databases.data.port") { postgres.getMappedPort(POSTGRESQL_PORT) }
155+
registry.add("csm.platform.databases.data.admin.username") { ADMIN_USER_CREDENTIALS }
156+
registry.add("csm.platform.databases.data.admin.password") { ADMIN_USER_CREDENTIALS }
157+
registry.add("csm.platform.databases.data.writer.username") { WRITER_USER_CREDENTIALS }
158+
registry.add("csm.platform.databases.data.writer.password") { WRITER_USER_CREDENTIALS }
159+
registry.add("csm.platform.databases.data.reader.username") { READER_USER_CREDENTIALS }
160+
registry.add("csm.platform.databases.data.reader.password") { READER_USER_CREDENTIALS }
175161
}
176162
}
177163

api/src/integrationTest/resources/application-test.yml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,9 @@ spring:
2929

3030
csm:
3131
platform:
32-
internalResultServices:
33-
enabled: true
34-
eventBus:
35-
enabled: false
3632
containerRegistry:
3733
checkSolutionImage: false
3834
identityProvider:
39-
code: keycloak
4035
authorizationUrl: "http://fake_url:8080/authorize"
4136
tokenUrl: "http://fake_url:8080/token"
4237
containerScopes:
@@ -102,17 +97,30 @@ csm:
10297
- ReadWriteOnce
10398
requests:
10499
storage: 1Gi
105-
twincache:
106-
host: "localhost"
107-
port: "6379"
108-
username: "default"
109-
# Leave it as blank as there's no auth with test container
110-
password:
111-
tls:
112-
enabled: false
113-
bundle: ""
114-
connector:
115-
default-page-size: 5
100+
databases:
101+
resources:
102+
host: "localhost"
103+
port: "6379"
104+
username: "default"
105+
# Leave it as blank as there's no auth with test container
106+
password:
107+
tls:
108+
enabled: false
109+
bundle: ""
110+
connector:
111+
default-page-size: 5
112+
data:
113+
admin:
114+
password: "password"
115+
username: cosmotech_api_admin
116+
host: "localhost"
117+
port: 5432
118+
reader:
119+
password: "password"
120+
username: cosmotech_api_reader
121+
writer:
122+
password: "password"
123+
username: cosmotech_api_writer
116124
rbac:
117125
enabled: true
118126
s3:

api/src/main/resources/application.yml

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,14 @@ logging:
55
OkHttpClient: WARN
66

77
spring:
8-
rabbitmq:
9-
host: ${csm.platform.internalResultServices.eventBus.host}
10-
port: ${csm.platform.internalResultServices.eventBus.port}
11-
password: ${csm.platform.internalResultServices.eventBus.listener.password}
12-
username: ${csm.platform.internalResultServices.eventBus.listener.username}
13-
ssl:
14-
enabled: ${csm.platform.internalResultServices.eventBus.tls.enabled}
158
data:
169
redis:
17-
host: ${csm.platform.twincache.host}
18-
port: ${csm.platform.twincache.port}
10+
host: ${csm.platform.databases.resources.host}
11+
port: ${csm.platform.databases.resources.port}
1912
ssl:
20-
enabled: ${csm.platform.twincache.tls.enabled}
21-
password: ${csm.platform.twincache.password}
22-
username: ${csm.platform.twincache.username}
13+
enabled: ${csm.platform.databases.resources.tls.enabled}
14+
password: ${csm.platform.databases.resources.password}
15+
username: ${csm.platform.databases.resources.username}
2316
timeout: 60000
2417
client-type: jedis
2518
servlet:
@@ -86,23 +79,23 @@ csm:
8679
downSamplingDefaultEnabled: false
8780
downSamplingRetentionDays: 400
8881
downSamplingBucketDurationMs: 3600000
89-
twincache:
90-
host: "localhost"
91-
port: "6379"
92-
username: "default_user"
93-
password: "default_password"
94-
tls:
95-
enabled: false
96-
bundle: ""
97-
run:
98-
maxResult: 200
99-
runner:
100-
maxResult: 200
101-
internalResultServices:
102-
enabled: false
103-
storage:
82+
databases:
83+
resources:
84+
host: "localhost"
85+
port: "6379"
86+
username: "default_user"
87+
password: "default_password"
88+
tls:
89+
enabled: false
90+
bundle: ""
91+
run:
92+
defaultPageSize: 200
93+
runner:
94+
defaultPageSize: 200
95+
data:
10496
host: "localhost"
10597
port: 5432
98+
schema: "cosmotech"
10699
reader:
107100
username: "storage_reader_username"
108101
password: "storage_reader_password"
@@ -112,22 +105,6 @@ csm:
112105
admin:
113106
username: "storage_admin_username"
114107
password: "storage_admin_password"
115-
eventBus:
116-
enabled: true
117-
tls:
118-
enabled: false
119-
bundle: ""
120-
host: "localhost"
121-
port: 5672
122-
default-exchange: "csm-exchange"
123-
default-queue: "csm"
124-
default-routing-key: "csm"
125-
listener:
126-
username: "eventbus_admin_username"
127-
password: "eventbus_admin_password"
128-
sender:
129-
username: "eventbus_sender_username"
130-
password: "eventbus_sender_password"
131108
s3:
132109
endpointUrl: "http://localhost:9000"
133110
bucketName: "cosmotech-api"

common/src/main/kotlin/com/cosmotech/common/config/CsmPlatformProperties.kt

Lines changed: 66 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package com.cosmotech.common.config
44

55
import com.cosmotech.common.security.ROLE_ORGANIZATION_USER
6-
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
76
import org.springframework.boot.context.properties.ConfigurationProperties
87

98
/** Configuration Properties for the Cosmo Tech Platform */
@@ -33,8 +32,8 @@ data class CsmPlatformProperties(
3332
/** Identity provider used if openapi default configuration needs to be overwritten */
3433
val identityProvider: CsmIdentityProvider,
3534

36-
/** Twin Data Layer configuration */
37-
val twincache: CsmTwinCacheProperties,
35+
/** Data Layer configuration */
36+
val databases: CsmDatabasesProperties,
3837

3938
/** RBAC / ACL configuration */
4039
val rbac: CsmRbac = CsmRbac(),
@@ -46,78 +45,8 @@ data class CsmPlatformProperties(
4645
val namespace: String = "phoenix",
4746

4847
/** Persistent metrics configuration */
49-
val metrics: Metrics = Metrics(),
50-
51-
/** Internal result data service configuration */
52-
val internalResultServices: CsmServiceResult?,
48+
val metrics: Metrics = Metrics()
5349
) {
54-
@ConditionalOnProperty(
55-
prefix = "csm.platform.internalResultServices.enabled",
56-
havingValue = "true",
57-
matchIfMissing = false)
58-
data class CsmServiceResult(
59-
/** Define if current API use internal result data service or cloud one */
60-
val enabled: Boolean = false,
61-
62-
/** Storage configuration */
63-
val storage: CsmStorage,
64-
65-
/** Queue configuration */
66-
val eventBus: CsmEventBus
67-
) {
68-
data class CsmStorage(
69-
/** Define if current API use internal storage for probes or not */
70-
val enabled: Boolean = true,
71-
72-
/** Storage host */
73-
val host: String,
74-
75-
/** Storage port */
76-
val port: Int = 5432,
77-
78-
/** Storage reader user configuration */
79-
val reader: CsmStorageUser,
80-
81-
/** Storage writer user configuration */
82-
val writer: CsmStorageUser,
83-
84-
/** Storage admin user configuration */
85-
val admin: CsmStorageUser
86-
) {
87-
data class CsmStorageUser(val username: String, val password: String)
88-
}
89-
90-
data class CsmEventBus(
91-
/** Define if current API use event bus within internal result data service or not */
92-
val enabled: Boolean = true,
93-
94-
/** TLS Platform bundle config */
95-
val tls: TLSConfig = TLSConfig(),
96-
97-
/** EventBus host */
98-
val host: String,
99-
100-
/** EventBus port */
101-
val port: Int = 5672,
102-
103-
/** EventBus default exchange */
104-
val defaultExchange: String = "csm-exchange",
105-
106-
/** EventBus default queue */
107-
val defaultQueue: String = "csm",
108-
109-
/** EventBus default routing key */
110-
val defaultRoutingKey: String = "csm",
111-
112-
/** EventBus listener user configuration */
113-
val listener: CsmEventBusUser,
114-
115-
/** EventBus sender user configuration */
116-
val sender: CsmEventBusUser
117-
) {
118-
data class CsmEventBusUser(val username: String, val password: String)
119-
}
120-
}
12150

12251
data class Metrics(
12352
/** Enable Metrics service */
@@ -340,54 +269,82 @@ data class CsmPlatformProperties(
340269
)
341270
}
342271

343-
data class CsmTwinCacheProperties(
344-
/** Twin cache host */
345-
val host: String,
272+
data class CsmDatabasesProperties(
273+
val resources: CsmResourcesProperties,
274+
val data: CsmDataIOProperties
275+
) {
346276

347-
/** Twin cache port */
348-
val port: String = "6379",
277+
data class CsmResourcesProperties(
278+
/** Host */
279+
val host: String,
349280

350-
/** Twin cache user */
351-
val username: String = "default",
281+
/** Port */
282+
val port: String = "6379",
352283

353-
/** Twin cache password */
354-
val password: String,
284+
/** User */
285+
val username: String = "default",
355286

356-
/** Twin cache query timeout. Kill a query after specified timeout (in millis) default 5000 */
357-
val queryTimeout: Long = 5000,
287+
/** Password */
288+
val password: String,
358289

359-
/**
360-
* After specified timeout the query bulk will be deleted from Redis (in seconds) default
361-
* 86400 = 24h
362-
*/
363-
val queryBulkTTL: Long = 86400,
290+
/** Query timeout. Kill a query after specified timeout (in millis) default 5000 */
291+
val queryTimeout: Long = 5000,
364292

365-
/** Twin cache query page information for organization */
366-
val organization: PageSizing = PageSizing(),
293+
/**
294+
* After specified timeout the query bulk will be deleted from Redis (in seconds) default
295+
* 86400 = 24h
296+
*/
297+
val queryBulkTTL: Long = 86400,
367298

368-
/** Twin cache query page information for workspace */
369-
val workspace: PageSizing = PageSizing(),
299+
/** Organization's resource query page information */
300+
val organization: PageSizing = PageSizing(),
370301

371-
/** Twin cache query page information for runner */
372-
val runner: PageSizing = PageSizing(),
302+
/** Workspace's resource query page information */
303+
val workspace: PageSizing = PageSizing(),
373304

374-
/** Twin cache query page information for dataset */
375-
val dataset: PageSizing = PageSizing(),
305+
/** Runner's resource query page information */
306+
val runner: PageSizing = PageSizing(),
376307

377-
/** Twin cache query page information for run */
378-
val run: PageSizing = PageSizing(),
308+
/** Dataset's resource query page information */
309+
val dataset: PageSizing = PageSizing(),
379310

380-
/** Twin cache query page information for solution */
381-
val solution: PageSizing = PageSizing(),
311+
/** Run's resource query page information */
312+
val run: PageSizing = PageSizing(),
382313

383-
/** TLS Platform bundle config */
384-
val tls: TLSConfig = TLSConfig()
385-
) {
314+
/** Solution's resource query page information */
315+
val solution: PageSizing = PageSizing(),
386316

387-
data class PageSizing(
388-
/** Max result for a single page */
389-
val defaultPageSize: Int = 50
390-
)
317+
/** TLS Platform bundle config */
318+
val tls: TLSConfig = TLSConfig()
319+
) {
320+
321+
data class PageSizing(
322+
/** Max result for a single page */
323+
val defaultPageSize: Int = 50
324+
)
325+
}
326+
327+
data class CsmDataIOProperties(
328+
/** Storage host */
329+
val host: String,
330+
331+
/** Storage port */
332+
val port: Int = 5432,
333+
334+
/** Storage schema */
335+
val schema: String = "cosmotech",
336+
337+
/** Storage reader user configuration */
338+
val reader: CsmStorageUser,
339+
340+
/** Storage writer user configuration */
341+
val writer: CsmStorageUser,
342+
343+
/** Storage admin user configuration */
344+
val admin: CsmStorageUser
345+
) {
346+
data class CsmStorageUser(val username: String, val password: String)
347+
}
391348
}
392349

393350
data class CsmRbac(

0 commit comments

Comments
 (0)