├── .gitignore
├── LICENSE
├── README.md
├── collapse-executor-core
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── icodening
│ └── collapse
│ └── core
│ ├── AbstractCollapseExecutor.java
│ ├── AsyncSameOutputCollapseExecutor.java
│ ├── BatchCollector.java
│ ├── BlockingSameOutputCollapseExecutor.java
│ ├── Bundle.java
│ ├── CollapseExecutor.java
│ ├── CollapseExecutorAsyncSupport.java
│ ├── CollapseExecutorBlockingSupport.java
│ ├── CollectorListener.java
│ ├── EqualsInputGrouper.java
│ ├── GroupListeningBatchCollector.java
│ ├── Input.java
│ ├── InputGrouper.java
│ ├── LengthLimitedInputGrouper.java
│ ├── ListeningCollector.java
│ ├── NamedCollapseExecutor.java
│ ├── NoOpInputGrouper.java
│ ├── SingleThreadExecutor.java
│ ├── SuspendableCollector.java
│ ├── ThreadlessExecutor.java
│ ├── support
│ ├── AsyncCallableGroupCollapseExecutor.java
│ ├── BlockingCallableGroupCollapseExecutor.java
│ ├── CallableGroup.java
│ └── FutureCallableGroupCollapseExecutor.java
│ └── util
│ ├── CacheableSupplier.java
│ ├── ThrowableCallable.java
│ └── VirtualThreadExecutorServiceProvider.java
├── collapse-executor-integration
├── collapse-executor-aop
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── icodening
│ │ └── collapse
│ │ └── aop
│ │ ├── AopCallableGroup.java
│ │ ├── CollapseMethodInterceptor.java
│ │ ├── CollapsibleAnnotationAspect.java
│ │ └── annotation
│ │ └── Collapsible.java
├── collapse-executor-pattern
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── icodening
│ │ └── collapse
│ │ └── web
│ │ └── pattern
│ │ ├── AbstractConfigurationCollapseGroupResolver.java
│ │ ├── CollapseDefinitionProperties.java
│ │ ├── CollapseGroupDefinition.java
│ │ ├── CollapseGroupResolver.java
│ │ ├── CollapsePolicyDefinition.java
│ │ ├── RegexConfigurationCollapseGroupResolver.java
│ │ ├── RequestAttributes.java
│ │ └── RequestCollapseGroup.java
├── collapse-executor-servlet
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── icodening
│ │ └── collapse
│ │ └── web
│ │ └── server
│ │ ├── AsyncServletExecutor.java
│ │ ├── CollapseHttpRequestServletFilter.java
│ │ ├── HttpServletRequestAttributes.java
│ │ ├── RecordableServletOutputStream.java
│ │ ├── RecordableServletResponse.java
│ │ ├── ServletCollapseRequest.java
│ │ └── ServletCollapseResponse.java
├── collapse-executor-spring-boot-autoconfigure
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── icodening
│ │ │ └── collapse
│ │ │ └── spring
│ │ │ └── boot
│ │ │ └── autoconfigure
│ │ │ ├── CollapseComponentScanner.java
│ │ │ ├── CollapseExecutorAutoConfiguration.java
│ │ │ ├── CollapseExecutorProperties.java
│ │ │ ├── ComponentScanMark.java
│ │ │ ├── ConditionalOnCollapseEnabled.java
│ │ │ ├── aop
│ │ │ └── CollapseAopAutoConfiguration.java
│ │ │ └── web
│ │ │ ├── client
│ │ │ ├── CollapseHttpRequestInterceptorInitializer.java
│ │ │ ├── CollapseRestTemplateAutoConfiguration.java
│ │ │ ├── CollapseRestTemplateProperties.java
│ │ │ └── reactive
│ │ │ │ ├── CollapseWebClientAutoConfiguration.java
│ │ │ │ └── CollapseWebClientProperties.java
│ │ │ └── server
│ │ │ ├── CollapseServletAutoConfiguration.java
│ │ │ └── CollapseServletProperties.java
│ │ └── resources
│ │ └── META-INF
│ │ ├── spring.factories
│ │ └── spring
│ │ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports
├── collapse-executor-spring-web
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── icodening
│ │ └── collapse
│ │ └── spring
│ │ └── web
│ │ ├── client
│ │ ├── CollapseHttpRequestInterceptor.java
│ │ ├── CollapseHttpRequestInterceptorConfigurator.java
│ │ ├── RepeatableReadResponse.java
│ │ ├── RestTemplateRequestAttributes.java
│ │ ├── SameHttpRequestUrlInputGrouper.java
│ │ └── reactive
│ │ │ ├── CollapseExchangeFilterFunction.java
│ │ │ └── WebClientRequestAttributes.java
│ │ └── pattern
│ │ └── PathPatternCollapseGroupResolver.java
└── pom.xml
├── collapse-executor-samples
├── README.md
├── collapse-executor-sample-advanced
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── icodening
│ │ └── collapse
│ │ └── sample
│ │ └── advanced
│ │ ├── CollapseExecutorAdvancedExample.java
│ │ └── support
│ │ ├── CustomAsyncCollapseExecutor.java
│ │ ├── CustomBlockingCollapseExecutor.java
│ │ ├── UserEntity.java
│ │ └── UserService.java
├── collapse-executor-sample-sequence
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── icodening
│ │ │ └── collapse
│ │ │ └── sample
│ │ │ └── sequence
│ │ │ ├── SequenceApplication.java
│ │ │ ├── generator
│ │ │ ├── AbstractRepositorySequenceGenerator.java
│ │ │ ├── SequenceGenerator.java
│ │ │ └── SimpleJdbcSequenceGenerator.java
│ │ │ └── service
│ │ │ └── SequenceGeneratorSampleService.java
│ │ └── resources
│ │ ├── application.yaml
│ │ ├── data.sql
│ │ └── schema.sql
├── collapse-executor-sample-simple
│ ├── README.md
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── com
│ │ └── icodening
│ │ └── collapse
│ │ └── sample
│ │ └── simple
│ │ ├── AsyncCollapseExecutorExample.java
│ │ ├── BlockingCollapseExecutorExample.java
│ │ └── FutureCollapseExecutorExample.java
├── collapse-executor-sample-spring-boot
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── icodening
│ │ │ └── collapse
│ │ │ └── sample
│ │ │ └── spring
│ │ │ └── boot
│ │ │ ├── SpringBootSampleApplication.java
│ │ │ ├── config
│ │ │ └── SampleConfiguration.java
│ │ │ ├── controller
│ │ │ ├── RestTemplateController.java
│ │ │ ├── StressTestController.java
│ │ │ ├── UserController.java
│ │ │ └── WebClientController.java
│ │ │ ├── entity
│ │ │ └── UserEntity.java
│ │ │ ├── executor
│ │ │ ├── AbstractBatchGetExecutor.java
│ │ │ ├── RestTemplateBatchGetExecutor.java
│ │ │ └── WebClientBatchGetExecutor.java
│ │ │ └── service
│ │ │ ├── AbstractBlockingCallSample.java
│ │ │ ├── RestTemplateCollapseBlockingCallSample.java
│ │ │ ├── UserService.java
│ │ │ └── WebClientCollapseBlockingCallSample.java
│ │ └── resources
│ │ └── application.yaml
└── pom.xml
├── docs
└── images
│ ├── collapse-executor-simple.png
│ ├── collapse-executor.png
│ ├── rest-template-collapse.png
│ ├── rest-template-without-collapse.png
│ ├── webclient-collapse.png
│ ├── webclient-without-collapse.png
│ ├── with-collapse.png
│ ├── without-collapse-executor.png
│ └── without-collapse.png
└── pom.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | pom.xml.tag
3 | pom.xml.releaseBackup
4 | pom.xml.versionsBackup
5 | pom.xml.next
6 | release.properties
7 | dependency-reduced-pom.xml
8 | buildNumber.properties
9 | .mvn/timing.properties
10 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar
11 | .mvn/wrapper/maven-wrapper.jar
12 | .idea
13 | .vscode
14 | # Eclipse m2e generated files
15 | # Eclipse Core
16 | .project
17 | # JDT-specific (Eclipse Java Development Tools)
18 | .classpath
19 |
--------------------------------------------------------------------------------
/collapse-executor-core/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
20 |
21 | collapse-executor-parent
22 | com.icodening.collapse
23 | 1.0.0
24 |
25 | 4.0.0
26 |
27 | collapse-executor-core
28 |
29 |
--------------------------------------------------------------------------------
/collapse-executor-core/src/main/java/com/icodening/collapse/core/AsyncSameOutputCollapseExecutor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.icodening.collapse.core;
17 |
18 | import java.util.List;
19 | import java.util.concurrent.CompletableFuture;
20 |
21 | /**
22 | * @author icodening
23 | * @date 2023.05.21
24 | */
25 | public abstract class AsyncSameOutputCollapseExecutor extends CollapseExecutorAsyncSupport {
26 |
27 | public AsyncSameOutputCollapseExecutor() {
28 | super();
29 | }
30 |
31 | public AsyncSameOutputCollapseExecutor(ListeningCollector collector) {
32 | super(collector);
33 | }
34 |
35 | @Override
36 | protected void bindingOutput(OUTPUT batchOutput, List>> bundles) {
37 | for (Bundle> bundle : bundles) {
38 | bundle.bindOutput(CompletableFuture.completedFuture(batchOutput));
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/collapse-executor-core/src/main/java/com/icodening/collapse/core/BlockingSameOutputCollapseExecutor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.icodening.collapse.core;
17 |
18 | import java.util.List;
19 |
20 | /**
21 | * @author icodening
22 | * @date 2023.05.14
23 | */
24 | public abstract class BlockingSameOutputCollapseExecutor extends CollapseExecutorBlockingSupport {
25 |
26 | public BlockingSameOutputCollapseExecutor() {
27 | super();
28 | }
29 |
30 | public BlockingSameOutputCollapseExecutor(ListeningCollector collector) {
31 | super(collector);
32 | }
33 |
34 | @Override
35 | protected void bindingOutput(OUTPUT batchOutput, List> bundles) {
36 | for (Bundle bundle : bundles) {
37 | bundle.bindOutput(batchOutput);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/collapse-executor-core/src/main/java/com/icodening/collapse/core/Bundle.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023-2024 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.icodening.collapse.core;
17 |
18 | import java.util.concurrent.CompletableFuture;
19 | import java.util.concurrent.Executor;
20 |
21 | /**
22 | * input output bundle
23 | *
24 | * @author icodening
25 | * @date 2023.05.14
26 | */
27 | public final class Bundle {
28 |
29 | private final CollapseExecutor collapseExecutor;
30 |
31 | private final INPUT input;
32 |
33 | private volatile OUTPUT output;
34 |
35 | private volatile Throwable throwable;
36 |
37 | private final Executor callbackExecutor;
38 |
39 | private final CompletableFuture