Skip to content

Commit

Permalink
Revert "Remove configuration API (#18998)"
Browse files Browse the repository at this point in the history
This reverts commit 41f3c0a.
  • Loading branch information
gosusnp authored Nov 15, 2022
1 parent 23679f5 commit 430b96b
Show file tree
Hide file tree
Showing 26 changed files with 1,338 additions and 140 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server;

import io.airbyte.server.apis.ConfigurationApi;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.process.internal.RequestScoped;

public class ConfigurationApiBinder extends AbstractBinder {

@Override
protected void configure() {
bindFactory(ConfigurationApiFactory.class)
.to(ConfigurationApi.class)
.in(RequestScoped.class);
}

}
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;

import io.airbyte.server.apis.ConfigurationApi;
import java.util.Map;
import org.glassfish.hk2.api.Factory;
import org.slf4j.MDC;

public class ConfigurationApiFactory implements Factory<ConfigurationApi> {

private static Map<String, String> mdc;

public static void setValues(
final Map<String, String> mdc) {
ConfigurationApiFactory.mdc = mdc;
}

@Override
public ConfigurationApi provide() {
MDC.setContextMap(ConfigurationApiFactory.mdc);

return new ConfigurationApi();
}

@Override
public void dispose(final ConfigurationApi service) {
/* noop */
}

}
15 changes: 15 additions & 0 deletions airbyte-server/src/main/java/io/airbyte/server/ServerApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,22 @@ public static ServerRunnable getServer(final ServerFactory apiFactory,
LOGGER.info("Starting server...");

return apiFactory.create(
syncSchedulerClient,
configRepository,
secretsRepositoryReader,
secretsRepositoryWriter,
jobPersistence,
configsDatabase,
jobsDatabase,
trackingClient,
configs.getWorkerEnvironment(),
configs.getLogConfigs(),
configs.getAirbyteVersion(),
configs.getWorkspaceRoot(),
httpClient,
eventRunner,
configsFlyway,
jobsFlyway,
attemptHandler,
connectionsHandler,
dbMigrationHandler,
Expand Down
53 changes: 51 additions & 2 deletions airbyte-server/src/main/java/io/airbyte/server/ServerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@

package io.airbyte.server;

import io.airbyte.analytics.TrackingClient;
import io.airbyte.commons.version.AirbyteVersion;
import io.airbyte.config.Configs.WorkerEnvironment;
import io.airbyte.config.helpers.LogConfigs;
import io.airbyte.config.persistence.ConfigRepository;
import io.airbyte.config.persistence.SecretsRepositoryReader;
import io.airbyte.config.persistence.SecretsRepositoryWriter;
import io.airbyte.db.Database;
import io.airbyte.persistence.job.JobPersistence;
import io.airbyte.server.apis.AttemptApiController;
import io.airbyte.server.apis.ConfigurationApi;
import io.airbyte.server.apis.ConnectionApiController;
import io.airbyte.server.apis.DbMigrationApiController;
import io.airbyte.server.apis.DestinationApiController;
Expand Down Expand Up @@ -86,13 +95,33 @@
import io.airbyte.server.handlers.WebBackendConnectionsHandler;
import io.airbyte.server.handlers.WebBackendGeographiesHandler;
import io.airbyte.server.handlers.WorkspacesHandler;
import io.airbyte.server.scheduler.EventRunner;
import io.airbyte.server.scheduler.SynchronousSchedulerClient;
import java.net.http.HttpClient;
import java.nio.file.Path;
import java.util.Map;
import java.util.Set;
import org.flywaydb.core.Flyway;
import org.slf4j.MDC;

public interface ServerFactory {

ServerRunnable create(final AirbyteVersion airbyteVersion,
ServerRunnable create(final SynchronousSchedulerClient synchronousSchedulerClient,
final ConfigRepository configRepository,
final SecretsRepositoryReader secretsRepositoryReader,
final SecretsRepositoryWriter secretsRepositoryWriter,
final JobPersistence jobPersistence,
final Database configsDatabase,
final Database jobsDatabase,
final TrackingClient trackingClient,
final WorkerEnvironment workerEnvironment,
final LogConfigs logConfigs,
final AirbyteVersion airbyteVersion,
final Path workspaceRoot,
final HttpClient httpClient,
final EventRunner eventRunner,
final Flyway configsFlyway,
final Flyway jobsFlyway,
final AttemptHandler attemptHandler,
final ConnectionsHandler connectionsHandler,
final DbMigrationHandler dbMigrationHandler,
Expand All @@ -115,7 +144,22 @@ ServerRunnable create(final AirbyteVersion airbyteVersion,
class Api implements ServerFactory {

@Override
public ServerRunnable create(final AirbyteVersion airbyteVersion,
public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedulerClient,
final ConfigRepository configRepository,
final SecretsRepositoryReader secretsRepositoryReader,
final SecretsRepositoryWriter secretsRepositoryWriter,
final JobPersistence jobPersistence,
final Database configsDatabase,
final Database jobsDatabase,
final TrackingClient trackingClient,
final WorkerEnvironment workerEnvironment,
final LogConfigs logConfigs,
final AirbyteVersion airbyteVersion,
final Path workspaceRoot,
final HttpClient httpClient,
final EventRunner eventRunner,
final Flyway configsFlyway,
final Flyway jobsFlyway,
final AttemptHandler attemptHandler,
final ConnectionsHandler connectionsHandler,
final DbMigrationHandler dbMigrationHandler,
Expand All @@ -136,6 +180,9 @@ public ServerRunnable create(final AirbyteVersion airbyteVersion,
final WebBackendGeographiesHandler webBackendGeographiesHandler) {
final Map<String, String> mdc = MDC.getCopyOfContextMap();

// set static values for factory
ConfigurationApiFactory.setValues(mdc);

AttemptApiFactory.setValues(attemptHandler, mdc);

ConnectionApiFactory.setValues(
Expand Down Expand Up @@ -184,6 +231,7 @@ public ServerRunnable create(final AirbyteVersion airbyteVersion,

// server configurations
final Set<Class<?>> componentClasses = Set.of(
ConfigurationApi.class,
AttemptApiController.class,
ConnectionApiController.class,
DbMigrationApiController.class,
Expand All @@ -208,6 +256,7 @@ public ServerRunnable create(final AirbyteVersion airbyteVersion,

final Set<Object> components = Set.of(
new CorsFilter(),
new ConfigurationApiBinder(),
new AttemptApiBinder(),
new ConnectionApiBinder(),
new DbMigrationBinder(),
Expand Down
35 changes: 0 additions & 35 deletions airbyte-server/src/main/java/io/airbyte/server/apis/ApiHelper.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public InternalOperationResult saveStats(final SaveStatsRequestBody saveStatsReq

@Override
public InternalOperationResult setWorkflowInAttempt(final SetWorkflowInAttemptRequestBody requestBody) {
return ApiHelper.execute(() -> attemptHandler.setWorkflowInAttempt(requestBody));
return ConfigurationApi.execute(() -> attemptHandler.setWorkflowInAttempt(requestBody));
}

}
Loading

0 comments on commit 430b96b

Please sign in to comment.