-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract the AttemptApi out of the ConfigurationApi (#18406)
* Tmp * Extract the Attempt API from the V1 API * Add comments * format * Rename to Controller
- Loading branch information
1 parent
25e7a37
commit 62eb6b6
Showing
5 changed files
with
104 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
airbyte-server/src/main/java/io/airbyte/server/apis/AttemptApiController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis; | ||
|
||
import io.airbyte.api.generated.AttemptApi; | ||
import io.airbyte.api.model.generated.InternalOperationResult; | ||
import io.airbyte.api.model.generated.SetWorkflowInAttemptRequestBody; | ||
import io.airbyte.persistence.job.JobPersistence; | ||
import io.airbyte.server.handlers.AttemptHandler; | ||
import javax.ws.rs.Path; | ||
|
||
@Path("/v1/attempt/set_workflow_in_attempt") | ||
public class AttemptApiController implements AttemptApi { | ||
|
||
private final AttemptHandler attemptHandler; | ||
|
||
public AttemptApiController(final JobPersistence jobPersistence) { | ||
attemptHandler = new AttemptHandler(jobPersistence); | ||
} | ||
|
||
@Override | ||
public InternalOperationResult setWorkflowInAttempt(final SetWorkflowInAttemptRequestBody requestBody) { | ||
return ConfigurationApi.execute(() -> attemptHandler.setWorkflowInAttempt(requestBody)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
airbyte-server/src/main/java/io/airbyte/server/apis/binders/AttemptApiBinder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis.binders; | ||
|
||
import io.airbyte.server.apis.AttemptApiController; | ||
import io.airbyte.server.apis.factories.AttemptApiFactory; | ||
import org.glassfish.hk2.utilities.binding.AbstractBinder; | ||
import org.glassfish.jersey.process.internal.RequestScoped; | ||
|
||
public class AttemptApiBinder extends AbstractBinder { | ||
|
||
@Override | ||
protected void configure() { | ||
bindFactory(AttemptApiFactory.class) | ||
.to(AttemptApiController.class) | ||
.in(RequestScoped.class); | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
airbyte-server/src/main/java/io/airbyte/server/apis/factories/AttemptApiFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis.factories; | ||
|
||
import io.airbyte.persistence.job.JobPersistence; | ||
import io.airbyte.server.apis.AttemptApiController; | ||
import java.util.Map; | ||
import org.glassfish.hk2.api.Factory; | ||
import org.slf4j.MDC; | ||
|
||
public class AttemptApiFactory implements Factory<AttemptApiController> { | ||
|
||
private static JobPersistence jobPersistence; | ||
private static Map<String, String> mdc; | ||
|
||
public static void setValues(final JobPersistence jobPersistence, final Map<String, String> mdc) { | ||
AttemptApiFactory.jobPersistence = jobPersistence; | ||
AttemptApiFactory.mdc = mdc; | ||
} | ||
|
||
@Override | ||
public AttemptApiController provide() { | ||
MDC.setContextMap(AttemptApiFactory.mdc); | ||
|
||
return new AttemptApiController(jobPersistence); | ||
} | ||
|
||
@Override | ||
public void dispose(final AttemptApiController instance) { | ||
/* no op */ | ||
} | ||
|
||
} |