-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bmoric/extract db migration api (#18459)
* Tmp * Extract the Attempt API from the V1 API * Add comments * Move Connection API out of configuration API * format * format * Rename to Controller * Rename to Controller * Add values to the factory * Change the constructor to use hadler instead of objects needed by the handler * Update with new tags. * tmp * Fix PMD errors * Extract DB migrator * Add something that I forgot * restore destination factory initialization * format
- Loading branch information
1 parent
2e5fb6c
commit 71956a9
Showing
8 changed files
with
115 additions
and
34 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
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
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
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
33 changes: 33 additions & 0 deletions
33
airbyte-server/src/main/java/io/airbyte/server/apis/DbMigrationApiController.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,33 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis; | ||
|
||
import io.airbyte.api.generated.DbMigrationApi; | ||
import io.airbyte.api.model.generated.DbMigrationExecutionRead; | ||
import io.airbyte.api.model.generated.DbMigrationReadList; | ||
import io.airbyte.api.model.generated.DbMigrationRequestBody; | ||
import io.airbyte.server.handlers.DbMigrationHandler; | ||
import javax.ws.rs.Path; | ||
|
||
@Path("/v1/db_migrations") | ||
public class DbMigrationApiController implements DbMigrationApi { | ||
|
||
private final DbMigrationHandler dbMigrationHandler; | ||
|
||
public DbMigrationApiController(final DbMigrationHandler dbMigrationHandler) { | ||
this.dbMigrationHandler = dbMigrationHandler; | ||
} | ||
|
||
@Override | ||
public DbMigrationExecutionRead executeMigrations(final DbMigrationRequestBody dbMigrationRequestBody) { | ||
return ConfigurationApi.execute(() -> dbMigrationHandler.migrate(dbMigrationRequestBody)); | ||
} | ||
|
||
@Override | ||
public DbMigrationReadList listMigrations(final DbMigrationRequestBody dbMigrationRequestBody) { | ||
return ConfigurationApi.execute(() -> dbMigrationHandler.list(dbMigrationRequestBody)); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
airbyte-server/src/main/java/io/airbyte/server/apis/binders/DbMigrationBinder.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.DbMigrationApiController; | ||
import io.airbyte.server.apis.factories.DbMigrationApiFactory; | ||
import org.glassfish.hk2.utilities.binding.AbstractBinder; | ||
import org.glassfish.jersey.process.internal.RequestScoped; | ||
|
||
public class DbMigrationBinder extends AbstractBinder { | ||
|
||
@Override | ||
protected void configure() { | ||
bindFactory(DbMigrationApiFactory.class) | ||
.to(DbMigrationApiController.class) | ||
.in(RequestScoped.class); | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
airbyte-server/src/main/java/io/airbyte/server/apis/factories/DbMigrationApiFactory.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.server.apis.DbMigrationApiController; | ||
import io.airbyte.server.handlers.DbMigrationHandler; | ||
import java.util.Map; | ||
import org.glassfish.hk2.api.Factory; | ||
import org.slf4j.MDC; | ||
|
||
public class DbMigrationApiFactory implements Factory<DbMigrationApiController> { | ||
|
||
private static DbMigrationHandler dbMigrationHandler; | ||
private static Map<String, String> mdc; | ||
|
||
public static void setValues(final DbMigrationHandler dbMigrationHandler, final Map<String, String> mdc) { | ||
DbMigrationApiFactory.dbMigrationHandler = dbMigrationHandler; | ||
DbMigrationApiFactory.mdc = mdc; | ||
} | ||
|
||
@Override | ||
public DbMigrationApiController provide() { | ||
MDC.setContextMap(DbMigrationApiFactory.mdc); | ||
|
||
return new DbMigrationApiController(dbMigrationHandler); | ||
} | ||
|
||
@Override | ||
public void dispose(final DbMigrationApiController instance) { | ||
/* no op */ | ||
} | ||
|
||
} |
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