Skip to content

Commit

Permalink
Merge pull request #39 from codef-io/develop
Browse files Browse the repository at this point in the history
release: v2.0.0-beta-004
  • Loading branch information
h-beeen authored Nov 26, 2024
2 parents 1eedff2 + b67e166 commit dcbcb9d
Show file tree
Hide file tree
Showing 22 changed files with 497 additions and 384 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,7 @@ jobs:
uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter-config.yml
version: ${{ steps.get_version.outputs.VERSION }}
tag: v${{ steps.get_version.outputs.VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/src/main/resources/logback-test.xml
*.java.hsp
*.sonarj
*.sw*
Expand Down
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,14 @@
<p align="center">
<a href="https://github.com/codef-io/easycodef-java-v2/actions?query=branch%3Amaster"><img align="center" src="https://img.shields.io/github/actions/workflow/status/codef-io/easycodef-java-v2/publish.yml?style=for-the-badge&logo=gradle&color=02303A" alt="Build Status"/></a>
<a href="https://github.com/codef-io/easycodef-java-v2"><img align="center" src="https://img.shields.io/github/last-commit/codef-io/easycodef-java-v2/master?style=for-the-badge&label=LAST%20BUILD&logo=Github&color=181717" alt="Last Commit"/></a>
<a href="https://central.sonatype.com/artifact/io.codef.api/easycodef-java-v2/2.0.0-beta-003"><img align="center" src="https://img.shields.io/maven-central/v/io.codef.api/easycodef-java-v2.svg?style=for-the-badge&label=Maven%20Central&logo=apache-maven&color=C71A36" alt="Maven Central"/></a>
<a href="https://central.sonatype.com/artifact/io.codef.api/easycodef-java-v2/2.0.0-beta-004"><img align="center" src="https://img.shields.io/maven-central/v/io.codef.api/easycodef-java-v2.svg?style=for-the-badge&label=Maven%20Central&logo=apache-maven&color=C71A36" alt="Maven Central"/></a>
</p>

<br><br>

> [!TIP]
> - **[EasyCodef V2 Wiki](https://github.com/codef-io/easycodef-java-v2/wiki)**
<br>

> [!NOTE]
> - [Codef Homepage](https://codef.io/)
> [!IMPORTANT]
> - **[EasyCodef Java V2 Wiki Guide Docs](https://github.com/codef-io/easycodef-java-v2/wiki)**
> - [Codef API Developer Guide](https://developer.codef.io/)
> - [Hectodata Homepage](https://hectodata.co.kr/)
> - [Hecto Tech Blog](https://blog.hectodata.co.kr/)
<br>

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {


group = "io.codef.api"
version = "2.0.0-beta-003"
version = "2.0.0-beta-004"

signing {
useInMemoryPgpKeys(
Expand Down
65 changes: 65 additions & 0 deletions src/main/java/io/codef/api/CodefExecutorManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package io.codef.api;

import io.codef.api.dto.EasyCodefRequest;
import io.codef.api.dto.EasyCodefResponse;
import io.codef.api.facade.SingleReqFacade;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

// 실행기 관리를 위한 클래스
public class CodefExecutorManager implements AutoCloseable {
private final ScheduledExecutorService scheduler;
private final Executor virtualThreadExecutor;

private CodefExecutorManager(ScheduledExecutorService scheduler, Executor virtualThreadExecutor) {
this.scheduler = scheduler;
this.virtualThreadExecutor = virtualThreadExecutor;
}

public static CodefExecutorManager create() {
return new CodefExecutorManager(
Executors.newScheduledThreadPool(1),
Executors.newThreadPerTaskExecutor(Thread.ofVirtual().factory())
);
}

public CompletableFuture<EasyCodefResponse> scheduleRequest(
EasyCodefRequest request,
long delayMs,
SingleReqFacade facade
) {
return scheduleDelayedExecution(delayMs)
.thenComposeAsync(
ignored -> executeRequest(request, facade),
virtualThreadExecutor
);
}

private CompletableFuture<Void> scheduleDelayedExecution(long delayMs) {
CompletableFuture<Void> future = new CompletableFuture<>();
scheduler.schedule(
() -> future.complete(null),
delayMs,
TimeUnit.MILLISECONDS
);
return future;
}

private CompletableFuture<EasyCodefResponse> executeRequest(
EasyCodefRequest request,
SingleReqFacade facade
) {
return CompletableFuture.supplyAsync(
() -> facade.requestProduct(request),
virtualThreadExecutor
);
}

@Override
public void close() {
scheduler.shutdown();
}
}
Loading

0 comments on commit dcbcb9d

Please sign in to comment.