Skip to content

Commit f94fe3e

Browse files
committed
Mostly clean the code, fix tests, add additional-spring-configuration-metadata.json to each autoconfigure module that has properties.
1 parent 9f42ffb commit f94fe3e

File tree

67 files changed

+1015
-298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1015
-298
lines changed

cache/spring-boot-python-executor-cache-autoconfigure/src/main/java/io/w4t3rcs/python/autoconfigure/PythonCacheProperties.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,21 @@
4747
@Getter @Setter
4848
@ConfigurationProperties(prefix = "spring.python.cache")
4949
public class PythonCacheProperties {
50+
/**
51+
* Whether the Python cache autoconfiguration is enabled.
52+
*/
5053
private boolean enabled = true;
54+
/**
55+
* Defines which parts of the Python processing flow are cached.
56+
*/
5157
private PythonCacheLevel[] levels = new PythonCacheLevel[]{PythonCacheLevel.FILE, PythonCacheLevel.PROCESSOR};
58+
/**
59+
* Configuration properties defining cache names for each cache segment.
60+
*/
5261
private NameProperties name = new NameProperties();
62+
/**
63+
* Configuration properties defining cache key generation behavior.
64+
*/
5365
private KeyProperties key = new KeyProperties();
5466

5567
/**
@@ -70,10 +82,25 @@ public enum PythonCacheLevel {
7082
*/
7183
@Getter @Setter
7284
public static class NameProperties {
85+
/**
86+
* Cache name for storing resolved Python file paths.
87+
*/
7388
private String filePaths = "pythonFilePathsCache";
89+
/**
90+
* Cache name for storing Python file contents.
91+
*/
7492
private String fileBodies = "pythonFileBodiesCache";
93+
/**
94+
* Cache name for storing resolved Python scripts.
95+
*/
7596
private String resolver = "pythonResolverCache";
97+
/**
98+
* Cache name for storing Python executor cached responses.
99+
*/
76100
private String executor = "pythonExecutorCache";
101+
/**
102+
* Cache name for storing Python processor cached responses.
103+
*/
77104
private String processor = "pythonProcessorCache";
78105
}
79106

@@ -85,8 +112,17 @@ public static class NameProperties {
85112
*/
86113
@Getter @Setter
87114
public static class KeyProperties {
115+
/**
116+
* Hash algorithm used to generate cache keys (e.g., SHA-256, MD5).
117+
*/
88118
private String hashAlgorithm = "SHA-256";
119+
/**
120+
* Charset used to encode cache key components before hashing.
121+
*/
89122
private String charset = "UTF-8";
123+
/**
124+
* Delimiter used between cache key parts during concatenation.
125+
*/
90126
private String delimiter = "_";
91127
}
92128
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
{
2+
"groups": [
3+
{
4+
"name": "spring.python.cache",
5+
"description": "Configuration properties for Python caching mechanism across executors and resolvers.",
6+
"type": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties",
7+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties"
8+
},
9+
{
10+
"name": "spring.python.cache.name",
11+
"description": "Configuration properties defining cache names for each cache segment.",
12+
"type": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties$NameProperties",
13+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties"
14+
},
15+
{
16+
"name": "spring.python.cache.key",
17+
"description": "Configuration properties defining cache key generation behavior.",
18+
"type": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties$KeyProperties",
19+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties"
20+
}
21+
],
22+
"properties": [
23+
{
24+
"name": "spring.python.cache.enabled",
25+
"description": "Whether the Python cache autoconfiguration is enabled.",
26+
"defaultValue": true,
27+
"type": "java.lang.Boolean",
28+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties"
29+
},
30+
{
31+
"name": "spring.python.cache.levels",
32+
"description": "Defines which parts of the Python processing flow are cached.",
33+
"defaultValue": [
34+
"file",
35+
"processor"
36+
],
37+
"type": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties$PythonCacheLevel[]",
38+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties"
39+
},
40+
{
41+
"name": "spring.python.cache.name.file-paths",
42+
"description": "Cache name for storing resolved Python file paths.",
43+
"defaultValue": "pythonFilePathsCache",
44+
"type": "java.lang.String",
45+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties$NameProperties"
46+
},
47+
{
48+
"name": "spring.python.cache.name.file-bodies",
49+
"description": "Cache name for storing Python file contents (script bodies).",
50+
"defaultValue": "pythonFileBodiesCache",
51+
"type": "java.lang.String",
52+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties$NameProperties"
53+
},
54+
{
55+
"name": "spring.python.cache.name.resolver",
56+
"description": "Cache name for storing resolved Python scripts",
57+
"defaultValue": "pythonResolverCache",
58+
"type": "java.lang.String",
59+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties$NameProperties"
60+
},
61+
{
62+
"name": "spring.python.cache.name.executor",
63+
"description": "Cache name for storing Python executor cached responses.",
64+
"defaultValue": "pythonExecutorCache",
65+
"type": "java.lang.String",
66+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties$NameProperties"
67+
},
68+
{
69+
"name": "spring.python.cache.name.processor",
70+
"description": "Cache name for storing Python processor cached responses.",
71+
"defaultValue": "pythonProcessorCache",
72+
"type": "java.lang.String",
73+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties$NameProperties"
74+
},
75+
{
76+
"name": "spring.python.cache.key.hash-algorithm",
77+
"description": "Hash algorithm used to generate cache keys (e.g., SHA-256, MD5).",
78+
"defaultValue": "SHA-256",
79+
"type": "java.lang.String",
80+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties$KeyProperties"
81+
},
82+
{
83+
"name": "spring.python.cache.key.charset",
84+
"description": "Charset used to encode cache key components before hashing.",
85+
"defaultValue": "UTF-8",
86+
"type": "java.lang.String",
87+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties$KeyProperties"
88+
},
89+
{
90+
"name": "spring.python.cache.key.delimiter",
91+
"description": "Delimiter used between cache key parts during concatenation.",
92+
"defaultValue": "_",
93+
"type": "java.lang.String",
94+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonCacheProperties$KeyProperties"
95+
}
96+
],
97+
"hints": [
98+
{
99+
"name": "spring.python.cache.levels",
100+
"values": [
101+
{
102+
"value": "file",
103+
"description": "Caches Python inside the PythonFileReader."
104+
},
105+
{
106+
"value": "resolver",
107+
"description": "Caches Python inside the PythonResolverHolder."
108+
},
109+
{
110+
"value": "executor",
111+
"description": "Caches Python inside the PythonExecutor."
112+
},
113+
{
114+
"value": "processor",
115+
"description": "Caches Python inside the PythonProcessor."
116+
}
117+
]
118+
}
119+
]
120+
}

cache/spring-boot-python-executor-cache-autoconfigure/src/test/java/io/w4t3rcs/python/CachingPythonLevelConfigurationTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727

2828
@SpringBootTest
2929
@AutoConfigureJson
30-
@ContextConfiguration(classes = {CachingPythonLevelConfigurationTests.TestBeansConfiguration.class, PythonCacheAutoConfiguration.class})
30+
@ContextConfiguration(classes = {
31+
CachingPythonLevelConfigurationTests.TestBeansConfiguration.class,
32+
PythonCacheAutoConfiguration.class
33+
})
3134
@TestPropertySource(properties = "spring.python.cache.enabled=true")
3235
class CachingPythonLevelConfigurationTests {
3336
@MockitoBean

core/spring-boot-python-executor-autoconfigure/src/main/java/io/w4t3rcs/python/autoconfigure/PythonAspectProperties.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@
2929
* python:
3030
* aspect:
3131
* async:
32+
* enabled: true
3233
* scopes: before, after
3334
* core-pool-size: 10
34-
* max-pool-size: 20
35-
* queue-capacity: 50
35+
* max-pool-size: 50
36+
* queue-capacity: 100
3637
* thread-name-prefix: AsyncPythonAspect-
3738
* rejection-policy: caller_runs
3839
* }</pre>
@@ -57,12 +58,33 @@ public class PythonAspectProperties {
5758
*/
5859
@Getter @Setter
5960
public static class AsyncProperties {
61+
/**
62+
* Whether asynchronous aspect execution is enabled.
63+
*/
6064
private boolean enabled = false;
65+
/**
66+
* Defines when asynchronous execution should be applied (before or after method execution).
67+
*/
6168
private Scope[] scopes = new Scope[]{Scope.BEFORE, Scope.AFTER};
69+
/**
70+
* Core number of threads to keep in the async thread pool.
71+
*/
6272
private int corePoolSize = 10;
73+
/**
74+
* Maximum number of threads allowed in the async thread pool.
75+
*/
6376
private int maxPoolSize = 50;
77+
/**
78+
* Capacity of the task queue used by the async executor.
79+
*/
6480
private int queueCapacity = 100;
81+
/**
82+
* Prefix to use for async executor thread names.
83+
*/
6584
private String threadNamePrefix = "AsyncPythonAspect-";
85+
/**
86+
* Policy used when the async executor queue is full and a new task cannot be accepted.
87+
*/
6688
private RejectionPolicy rejectionPolicy = RejectionPolicy.CALLER_RUNS;
6789

6890
/**

core/spring-boot-python-executor-autoconfigure/src/main/java/io/w4t3rcs/python/autoconfigure/PythonFileProperties.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,8 @@
3131
@Getter @Setter
3232
@ConfigurationProperties("spring.python.file")
3333
public class PythonFileProperties {
34+
/**
35+
* Base directory path where Python scripts are stored or loaded from.
36+
*/
3437
private String path = "/python/";
3538
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"groups": [
3+
{
4+
"name": "spring.python.aspect.async",
5+
"description": "Configuration properties for asynchronous execution of Python aspects.",
6+
"type": "io.w4t3rcs.python.autoconfigure.PythonAspectProperties$AsyncProperties",
7+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonAspectProperties"
8+
},
9+
{
10+
"name": "spring.python.file",
11+
"description": "Configuration properties for managing Python files.",
12+
"type": "io.w4t3rcs.python.autoconfigure.PythonFileProperties",
13+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonFileProperties"
14+
}
15+
],
16+
"properties": [
17+
{
18+
"name": "spring.python.aspect.async.enabled",
19+
"description": "Whether asynchronous aspect execution is enabled.",
20+
"defaultValue": true,
21+
"type": "java.lang.Boolean",
22+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonAspectProperties"
23+
},
24+
{
25+
"name": "spring.python.aspect.async.scopes",
26+
"description": "Defines when asynchronous execution should be applied (before or after method execution).",
27+
"defaultValue": [
28+
"before",
29+
"after"
30+
],
31+
"type": "io.w4t3rcs.python.autoconfigure.PythonAspectProperties$AsyncProperties$Scope[]",
32+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonAspectProperties"
33+
},
34+
{
35+
"name": "spring.python.aspect.async.core-pool-size",
36+
"description": "Core number of threads to keep in the async thread pool.",
37+
"defaultValue": 10,
38+
"type": "java.lang.Integer",
39+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonAspectProperties"
40+
},
41+
{
42+
"name": "spring.python.aspect.async.max-pool-size",
43+
"description": "Maximum number of threads allowed in the async thread pool.",
44+
"defaultValue": 50,
45+
"type": "java.lang.Integer",
46+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonAspectProperties"
47+
},
48+
{
49+
"name": "spring.python.aspect.async.queue-capacity",
50+
"description": "Capacity of the task queue used by the async executor.",
51+
"defaultValue": 100,
52+
"type": "java.lang.Integer",
53+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonAspectProperties"
54+
},
55+
{
56+
"name": "spring.python.aspect.async.thread-name-prefix",
57+
"description": "Prefix to use for async executor thread names.",
58+
"defaultValue": "AsyncPythonAspect-",
59+
"type": "java.lang.String",
60+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonAspectProperties"
61+
},
62+
{
63+
"name": "spring.python.aspect.async.rejection-policy",
64+
"description": "Policy used when the async executor queue is full and a new task cannot be accepted.",
65+
"defaultValue": "caller_runs",
66+
"type": "io.w4t3rcs.python.autoconfigure.PythonAspectProperties$AsyncProperties$RejectionPolicy",
67+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonAspectProperties"
68+
},
69+
{
70+
"name": "spring.python.file.path",
71+
"description": "Base directory path where Python scripts are stored or loaded from.",
72+
"defaultValue": "/python/",
73+
"type": "java.lang.String",
74+
"sourceType": "io.w4t3rcs.python.autoconfigure.PythonFileProperties"
75+
}
76+
],
77+
"hints": [
78+
{
79+
"name": "spring.python.aspect.async.scopes",
80+
"values": [
81+
{
82+
"value": "before",
83+
"description": "Run asynchronously before the method execution."
84+
},
85+
{
86+
"value": "after",
87+
"description": "Run asynchronously after the method execution."
88+
}
89+
]
90+
},
91+
{
92+
"name": "spring.python.aspect.async.rejection-policy",
93+
"values": [
94+
{
95+
"value": "caller_runs",
96+
"description": "The calling thread runs the task when the queue is full."
97+
},
98+
{
99+
"value": "abort",
100+
"description": "Rejects the task and throws a RejectedExecutionException."
101+
},
102+
{
103+
"value": "discard",
104+
"description": "Silently discards the task when the queue is full."
105+
},
106+
{
107+
"value": "discard_oldest",
108+
"description": "Discards the oldest task in the queue and retries submission."
109+
}
110+
]
111+
}
112+
]
113+
}

0 commit comments

Comments
 (0)