Skip to content

Commit 87d6a6c

Browse files
authored
Merge pull request #32 from tiarebalbi/version-bump
Chore: version bump Spring boot 3.2.2 Infinitic 0.12.1"
2 parents ce563db + fc6cdc1 commit 87d6a6c

File tree

8 files changed

+76
-53
lines changed

8 files changed

+76
-53
lines changed

infinitic-spring-boot-3-example/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99

1010
group = "com.tiarebalbi.example"
1111
version = "0.0.1-SNAPSHOT"
12-
extra["infiniticVersion"] = "0.11.6"
12+
extra["infiniticVersion"] = "0.11.7"
1313

1414
java {
1515
sourceCompatibility = JavaVersion.VERSION_17

infinitic-spring-boot-3-example/src/main/kotlin/com/tiarebalbi/example/InfiniticSpringBoot3ExampleApplication.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.tiarebalbi.example
22

33
import com.tiarebalbi.example.demo.DemoService
4+
import io.infinitic.clients.InfiniticClient
45
import org.springframework.beans.factory.InitializingBean
56
import org.springframework.boot.autoconfigure.SpringBootApplication
67
import org.springframework.boot.runApplication
@@ -18,7 +19,9 @@ fun main(args: Array<String>) {
1819
class Config {
1920

2021
@Bean
21-
fun initService(demoService: DemoService) = InitializingBean {
22-
demoService.runDemoFlow()
22+
fun initService(demoService: DemoService, client: InfiniticClient) = InitializingBean {
23+
val execution = client.dispatch(demoService::runDemoFlow)
24+
println("Execution id: ${execution.id}")
25+
println("Result: ${execution.await()}")
2326
}
2427
}

infinitic-spring-boot-3-example/src/main/kotlin/com/tiarebalbi/example/demo/DemoService.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import org.springframework.stereotype.Service
55

66
@Service
77
class DemoService(private val infiniticClient: InfiniticClient) {
8-
fun runDemoFlow() {
8+
fun runDemoFlow(): String {
99
val event = this.infiniticClient.newWorkflow(AnnotatedWorkflow::class.java)
1010
val result = event.concatABC("Demo-")
1111
println("Result: $result")
12+
13+
return result
1214
}
1315
}
Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package com.tiarebalbi.infinitic.spring
22

33
import io.infinitic.clients.InfiniticClient
4-
import io.infinitic.pulsar.config.ClientConfig
54
import io.infinitic.workers.InfiniticWorker
6-
import io.infinitic.workers.config.WorkerConfig
75
import org.slf4j.LoggerFactory
8-
import org.springframework.beans.factory.InitializingBean
96
import org.springframework.boot.autoconfigure.AutoConfiguration
107
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
118
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
@@ -17,33 +14,46 @@ import org.springframework.core.io.ResourceLoader
1714
/**
1815
* Configuration class for Infinitic Auto-Configuration.
1916
*
20-
* This class is responsible for configuring the Infinitic library based on the provided application properties.
21-
* It creates an InfiniticClient and configures it with the specified client configuration file.
17+
* This class is responsible for configuring the Infinitic library based on
18+
* the provided application properties. It creates an InfiniticClient and
19+
* configures it with the specified client configuration file.
2220
*
23-
* This class is annotated with `@Configuration` to indicate that it should be processed by Spring's application context.
24-
* It is also annotated with `@ConditionalOnProperty` to conditionally enable this configuration based on the value of the
25-
* "infinitic.enabled" property. If the property is not present or has a value other than "true", this configuration will
21+
* This class is annotated with `@Configuration` to indicate that it should
22+
* be processed by Spring's application context. It is also annotated with
23+
* `@ConditionalOnProperty` to conditionally enable this configuration
24+
* based on the value of the "infinitic.enabled" property. If the property
25+
* is not present or has a value other than "true", this configuration will
2626
* not be loaded.
2727
*
28-
* Configuration properties can be provided using the `InfiniticProperties` class, which is enabled with the
29-
* `@EnableConfigurationProperties` annotation.
28+
* Configuration properties can be provided using the `InfiniticProperties`
29+
* class, which is enabled with the `@EnableConfigurationProperties`
30+
* annotation.
3031
*
31-
* The InfiniticAutoConfiguration class requires two constructor arguments: `InfiniticProperties` and `ResourceLoader`.
32+
* The InfiniticAutoConfiguration class requires two constructor arguments:
33+
* `InfiniticProperties` and `ResourceLoader`.
3234
*
33-
* The `InfiniticProperties` argument is used to access the configuration properties for the Infinitic library,
34-
* including the location of the client configuration file.
35+
* The `InfiniticProperties` argument is used to access the configuration
36+
* properties for the Infinitic library, including the location of the
37+
* client configuration file.
3538
*
36-
* The `ResourceLoader` argument is used to load the client configuration file from the classpath or file system.
39+
* The `ResourceLoader` argument is used to load the client configuration
40+
* file from the classpath or file system.
3741
*
38-
* The `configureClient` method is annotated with `@Bean`, `@ConditionalOnProperty`, and `@ConditionalOnMissingBean`.
39-
* It creates and configures an InfiniticClient bean if the "infinitic.client.enabled" property is present and has a
40-
* value of "true". It uses the `getClientConfig` method to obtain the client configuration.
42+
* The `configureClient` method is annotated with `@Bean`,
43+
* `@ConditionalOnProperty`, and `@ConditionalOnMissingBean`. It creates
44+
* and configures an InfiniticClient bean if the "infinitic.client.enabled"
45+
* property is present and has a value of "true". It uses the
46+
* `getClientConfig` method to obtain the client configuration.
4147
*
42-
* The `getClientConfig` method retrieves the client configuration file location from the `InfiniticProperties` object,
43-
* loads the file using the `ResourceLoader`, and creates a `ClientConfig` object from the loaded file.
48+
* The `getClientConfig` method retrieves the client configuration file
49+
* location from the `InfiniticProperties` object, loads the file using the
50+
* `ResourceLoader`, and creates a `ClientConfig` object from the loaded
51+
* file.
4452
*
45-
* @param properties the InfiniticProperties object containing the configuration properties for the Infinitic library
46-
* @param resourceLoader the ResourceLoader object used to load the client configuration file
53+
* @param properties the InfiniticProperties object containing the
54+
* configuration properties for the Infinitic library
55+
* @param resourceLoader the ResourceLoader object used to load the client
56+
* configuration file
4757
* @author tiare.balbi
4858
*/
4959
@AutoConfiguration
@@ -62,40 +72,42 @@ class InfiniticAutoConfiguration(
6272
@Bean
6373
@ConditionalOnProperty(name = ["infinitic.worker.enabled"], havingValue = "true")
6474
@ConditionalOnMissingBean
65-
fun configureWorker() =
66-
InitializingBean {
67-
val config = getWorkerConfig()
68-
InfiniticWorker.fromConfig(config).use {
69-
logger.info("Starting infinitic worker")
70-
if (properties.worker.executionMode.isAsync()) {
71-
it.startAsync()
72-
} else {
73-
it.start()
74-
}
75+
fun configureWorker(): InfiniticWorker {
76+
val config = getWorkerConfig()
77+
val worker = InfiniticWorker.fromConfigFile(config)
78+
worker.use {
79+
logger.info("Starting infinitic worker")
80+
if (properties.worker.executionMode.isAsync()) {
81+
it.startAsync()
82+
} else {
83+
it.start()
7584
}
7685
}
7786

87+
return worker
88+
}
89+
7890
@Bean
7991
@ConditionalOnProperty(name = ["infinitic.client.enabled"], havingValue = "true")
8092
@ConditionalOnMissingBean
8193
fun configureClient(): InfiniticClient {
8294
logger.info("Configuring infinitic client")
83-
return InfiniticClient.fromConfig(getClientConfig(), getWorkerConfig())
95+
return InfiniticClient.fromConfigFile(getClientConfig(), getWorkerConfig())
8496
}
8597

86-
private fun getClientConfig(): ClientConfig {
98+
private fun getClientConfig(): String {
8799
val configuration =
88100
properties.client.configuration
89101
?: throw IllegalStateException("Unable to find client configuration file for infinitic.")
90102
val configurationFile = resourceLoader.getResource(configuration)
91-
return ClientConfig.fromFile(configurationFile.file.absolutePath)
103+
return configurationFile.file.absolutePath
92104
}
93105

94-
private fun getWorkerConfig(): WorkerConfig {
106+
private fun getWorkerConfig(): String {
95107
val configuration =
96108
properties.worker.configuration
97109
?: throw IllegalStateException("Unable to find worker infinitic configuration")
98110
val configurationFile = resourceLoader.getResource(configuration)
99-
return WorkerConfig.fromFile(configurationFile.file.absolutePath)
111+
return configurationFile.file.absolutePath
100112
}
101113
}

infinitic-spring-boot-3-starter/src/test/kotlin/com/tiarebalbi/infinitic/spring/InfiniticAutoConfigurationTest.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,26 @@ package com.tiarebalbi.infinitic.spring
22

33
import com.tiarebalbi.infinitic.tests.AnnotatedWorkflow
44
import io.infinitic.clients.InfiniticClient
5+
import io.infinitic.workers.InfiniticWorker
56
import org.assertj.core.api.Assertions.assertThat
67
import org.junit.jupiter.api.Test
78
import org.springframework.beans.factory.annotation.Autowired
89
import org.springframework.boot.test.context.SpringBootTest
910

10-
@SpringBootTest(classes = [InfiniticAutoConfiguration::class], properties = ["infinitic.enabled=true"])
11+
@SpringBootTest(classes = [InfiniticAutoConfiguration::class])
1112
class InfiniticAutoConfigurationTest {
1213
@Autowired
1314
private lateinit var infiniticClient: InfiniticClient
1415

16+
@Autowired
17+
private lateinit var infiniticWorker: InfiniticWorker
18+
1519
@Test
1620
fun `should be able to trigger flow`() {
17-
val event = this.infiniticClient.newWorkflow(AnnotatedWorkflow::class.java)
18-
val result = event.concatABC("Demo-")
21+
val event: AnnotatedWorkflow =
22+
this.infiniticClient.newWorkflow(AnnotatedWorkflow::class.java, setOf("unit-test"))
23+
val result = this.infiniticClient.dispatch(event::concatABC, "Demo-")
1924

20-
assertThat(result).isEqualTo("Demo-abc")
25+
assertThat(result.await()).isEqualTo("Demo-abc")
2126
}
2227
}

infinitic-spring-boot-3-starter/src/test/resources/application.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ infinitic.enabled=true
33

44
## Worker Setting
55
infinitic.worker.enabled=true
6-
infinitic.worker.configuration=classpath:infinitic-worker.yml
6+
infinitic.worker.configuration=classpath:infinitic-test.yml
77

88
## Client Setting
99
infinitic.client.enabled=true
10-
infinitic.client.configuration=classpath:infinitic-client.yml
10+
infinitic.client.configuration=classpath:infinitic-test.yml

infinitic-spring-boot-3-starter/src/test/resources/infinitic-client.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

infinitic-spring-boot-3-starter/src/test/resources/infinitic-worker.yml renamed to infinitic-spring-boot-3-starter/src/test/resources/infinitic-test.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,11 @@ services:
1313
workflows:
1414
- name: annotatedWorkflow
1515
class: com.tiarebalbi.infinitic.tests.AnnotatedWorkflowImpl
16-
concurrency: 5
16+
concurrency: 5
17+
18+
workflowDefault:
19+
concurrency: 5
20+
timeoutInSeconds: 30
21+
retry:
22+
maximumRetries: 6
23+
checkMode: strict

0 commit comments

Comments
 (0)