Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove configuration API #18998

Merged
merged 23 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7027679
Extract Operation API
benmoriceau Nov 3, 2022
eb18779
Extract scheduler API
benmoriceau Nov 3, 2022
05ffc3a
Format
benmoriceau Nov 3, 2022
09d63e5
Merge branch 'bmoric/extract-operation-api' of github.com:airbytehq/a…
benmoriceau Nov 3, 2022
585a8a9
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/ext…
benmoriceau Nov 3, 2022
6fc0a85
Merge branch 'bmoric/extract-operation-api' of github.com:airbytehq/a…
benmoriceau Nov 3, 2022
97b33a1
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/ext…
benmoriceau Nov 3, 2022
88c2557
extract source api
benmoriceau Nov 3, 2022
4f799f5
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/ext…
benmoriceau Nov 3, 2022
af86517
Extract source definition api
benmoriceau Nov 4, 2022
c76ed4e
Add path
benmoriceau Nov 4, 2022
6a57dcc
Extract State API
benmoriceau Nov 4, 2022
30b991d
extract webbackend api
benmoriceau Nov 4, 2022
c72225d
extract webbackend api
benmoriceau Nov 4, 2022
ecad901
extract workspace api
benmoriceau Nov 4, 2022
1cf081b
Extract source definition specification api
benmoriceau Nov 4, 2022
e1649ab
Remove configuration API
benmoriceau Nov 4, 2022
7bb500b
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/ext…
benmoriceau Nov 8, 2022
0962577
Merge branch 'master' into bmoric/extract-source-definition-specifica…
benmoriceau Nov 8, 2022
025b12b
Merge branch 'bmoric/extract-source-definition-specification-api' of …
benmoriceau Nov 8, 2022
4582738
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/rm-…
benmoriceau Nov 8, 2022
227f7bc
Merge branch 'master' into bmoric/rm-configuration-api
benmoriceau Nov 9, 2022
a5c8d4d
Merge branch 'master' into bmoric/rm-configuration-api
benmoriceau Nov 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

15 changes: 0 additions & 15 deletions airbyte-server/src/main/java/io/airbyte/server/ServerApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,22 +348,7 @@ 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: 2 additions & 51 deletions airbyte-server/src/main/java/io/airbyte/server/ServerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,8 @@

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 @@ -95,33 +86,13 @@
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 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,
ServerRunnable create(final AirbyteVersion airbyteVersion,
final AttemptHandler attemptHandler,
final ConnectionsHandler connectionsHandler,
final DbMigrationHandler dbMigrationHandler,
Expand All @@ -144,22 +115,7 @@ ServerRunnable create(final SynchronousSchedulerClient synchronousSchedulerClien
class Api implements ServerFactory {

@Override
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,
public ServerRunnable create(final AirbyteVersion airbyteVersion,
final AttemptHandler attemptHandler,
final ConnectionsHandler connectionsHandler,
final DbMigrationHandler dbMigrationHandler,
Expand All @@ -180,9 +136,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
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 @@ -231,7 +184,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul

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

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

import io.airbyte.config.persistence.ConfigNotFoundException;
import io.airbyte.server.errors.BadObjectSchemaKnownException;
import io.airbyte.server.errors.IdNotFoundKnownException;
import io.airbyte.validation.json.JsonValidationException;
import java.io.IOException;

public class ApiHelper {

static <T> T execute(final HandlerCall<T> call) {
try {
return call.call();
} catch (final ConfigNotFoundException e) {
throw new IdNotFoundKnownException(String.format("Could not find configuration for %s: %s.", e.getType(), e.getConfigId()),
e.getConfigId(), e);
} catch (final JsonValidationException e) {
throw new BadObjectSchemaKnownException(
String.format("The provided configuration does not fulfill the specification. Errors: %s", e.getMessage()), e);
} catch (final IOException e) {
throw new RuntimeException(e);
}
}

interface HandlerCall<T> {

T call() throws ConfigNotFoundException, IOException, JsonValidationException;

}

}
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 ConfigurationApi.execute(() -> attemptHandler.setWorkflowInAttempt(requestBody));
return ApiHelper.execute(() -> attemptHandler.setWorkflowInAttempt(requestBody));
}

}
Loading