Skip to content

Commit

Permalink
Extract split the server into 2 modules (#21736)
Browse files Browse the repository at this point in the history
* tmp

* For diff

* Extract common server

* Format

* Better way to get resources

* Extract the old mapper

* Move test as well

* Format
  • Loading branch information
benmoriceau authored Jan 24, 2023
1 parent daa8eb1 commit 0b97ce3
Show file tree
Hide file tree
Showing 185 changed files with 389 additions and 310 deletions.
69 changes: 69 additions & 0 deletions airbyte-commons-server/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
plugins {
id "java-library"
}

dependencies {
annotationProcessor platform(libs.micronaut.bom)
annotationProcessor libs.bundles.micronaut.annotation.processor
annotationProcessor libs.micronaut.jaxrs.processor

implementation platform(libs.micronaut.bom)
implementation libs.bundles.micronaut
implementation libs.micronaut.jaxrs.server

// Ensure that the versions defined in deps.toml are used
// instead of versions from transitive dependencies
implementation(libs.flyway.core) {
force = true
}
implementation(libs.s3) {
// Force to avoid updated version brought in transitively from Micronaut 3.8+
// that is incompatible with our current Helm setup
force = true
}
implementation(libs.aws.java.sdk.s3) {
// Force to avoid updated version brought in transitively from Micronaut 3.8+
// that is incompatible with our current Helm setup
force = true
}

implementation project(':airbyte-analytics')
implementation project(':airbyte-api')
implementation project(':airbyte-commons-docker')
implementation project(':airbyte-commons-temporal')
implementation project(':airbyte-commons-worker')
implementation project(':airbyte-config:init')
implementation project(':airbyte-config:config-models')
implementation project(':airbyte-config:config-persistence')
implementation project(':airbyte-config:specs')
implementation project(':airbyte-metrics:metrics-lib')
implementation project(':airbyte-db:db-lib')
implementation project(":airbyte-json-validation")
implementation project(':airbyte-notification')
implementation project(':airbyte-oauth')
implementation project(':airbyte-protocol:protocol-models')
implementation project(':airbyte-persistence:job-persistence')

implementation 'com.github.slugify:slugify:2.4'
implementation 'commons-cli:commons-cli:1.4'
implementation libs.temporal.sdk
implementation 'org.apache.cxf:cxf-core:3.4.2'
implementation 'org.eclipse.jetty:jetty-server:9.4.31.v20200723'
implementation 'org.eclipse.jetty:jetty-servlet:9.4.31.v20200723'
implementation 'org.glassfish.jaxb:jaxb-runtime:3.0.2'
implementation 'org.glassfish.jersey.containers:jersey-container-servlet'
implementation 'org.glassfish.jersey.inject:jersey-hk2'
implementation 'org.glassfish.jersey.media:jersey-media-json-jackson'
implementation 'org.glassfish.jersey.ext:jersey-bean-validation'
implementation 'org.quartz-scheduler:quartz:2.3.2'
implementation 'io.sentry:sentry:6.3.1'
implementation 'io.swagger:swagger-annotations:1.6.2'

testImplementation project(':airbyte-test-utils')
testImplementation libs.postgresql
testImplementation libs.platform.testcontainers.postgresql
testImplementation 'com.squareup.okhttp3:mockwebserver:4.9.1'
testImplementation 'org.mockito:mockito-inline:4.7.0'
}

Task publishArtifactsTask = getPublishArtifactsTask("$rootProject.ext.version", project)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server;
package io.airbyte.commons.server;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server;
package io.airbyte.commons.server;

public class ServerConstants {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.converters;
package io.airbyte.commons.server.converters;

import io.airbyte.api.model.generated.ActorDefinitionResourceRequirements;
import io.airbyte.api.model.generated.ConnectionRead;
Expand All @@ -18,10 +18,10 @@
import io.airbyte.api.model.generated.NormalizationDestinationDefinitionConfig;
import io.airbyte.api.model.generated.ResourceRequirements;
import io.airbyte.commons.enums.Enums;
import io.airbyte.commons.server.handlers.helpers.CatalogConverter;
import io.airbyte.config.BasicSchedule;
import io.airbyte.config.Schedule;
import io.airbyte.config.StandardSync;
import io.airbyte.server.handlers.helpers.CatalogConverter;
import java.util.stream.Collectors;

public class ApiPojoConverters {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.converters;
package io.airbyte.commons.server.converters;

import io.airbyte.api.model.generated.FieldAdd;
import io.airbyte.api.model.generated.FieldRemove;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.converters;
package io.airbyte.commons.server.converters;

import com.fasterxml.jackson.databind.JsonNode;
import io.airbyte.commons.json.Jsons;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.converters;
package io.airbyte.commons.server.converters;

import io.airbyte.api.model.generated.AttemptFailureOrigin;
import io.airbyte.api.model.generated.AttemptFailureReason;
Expand All @@ -28,6 +28,8 @@
import io.airbyte.api.model.generated.SourceDefinitionRead;
import io.airbyte.api.model.generated.SynchronousJobRead;
import io.airbyte.commons.enums.Enums;
import io.airbyte.commons.server.scheduler.SynchronousJobMetadata;
import io.airbyte.commons.server.scheduler.SynchronousResponse;
import io.airbyte.commons.version.AirbyteVersion;
import io.airbyte.config.Configs.WorkerEnvironment;
import io.airbyte.config.JobConfig.ConfigType;
Expand All @@ -42,8 +44,6 @@
import io.airbyte.persistence.job.models.Attempt;
import io.airbyte.persistence.job.models.AttemptNormalizationStatus;
import io.airbyte.persistence.job.models.Job;
import io.airbyte.server.scheduler.SynchronousJobMetadata;
import io.airbyte.server.scheduler.SynchronousResponse;
import io.airbyte.workers.helper.ProtocolConverters;
import jakarta.inject.Singleton;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.converters;
package io.airbyte.commons.server.converters;

import io.airbyte.commons.enums.Enums;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.converters;
package io.airbyte.commons.server.converters;

import io.airbyte.api.model.generated.AdvancedAuth;
import io.airbyte.api.model.generated.AdvancedAuth.AuthFlowTypeEnum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.converters;
package io.airbyte.commons.server.converters;

import static io.airbyte.api.model.generated.OperatorWebhook.WebhookTypeEnum.DBTCLOUD;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.converters;
package io.airbyte.commons.server.converters;

import com.google.common.base.Preconditions;
import io.airbyte.commons.server.scheduler.SynchronousResponse;
import io.airbyte.protocol.models.ConnectorSpecification;
import io.airbyte.server.scheduler.SynchronousResponse;

public class SpecFetcher {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.converters;
package io.airbyte.commons.server.converters;

import io.airbyte.api.model.generated.WorkflowStateRead;
import io.airbyte.commons.temporal.scheduling.state.WorkflowState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.converters;
package io.airbyte.commons.server.converters;

import com.fasterxml.jackson.databind.JsonNode;
import io.airbyte.api.model.generated.WebhookConfigRead;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.errors;
package io.airbyte.commons.server.errors;

public class ApplicationErrorKnownException extends KnownException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.errors;
package io.airbyte.commons.server.errors;

public class BadObjectSchemaKnownException extends KnownException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.errors;
package io.airbyte.commons.server.errors;

public class ConnectFailureKnownException extends KnownException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.errors;
package io.airbyte.commons.server.errors;

import io.micronaut.context.annotation.Requires;
import io.micronaut.http.HttpRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.errors;
package io.airbyte.commons.server.errors;

import io.airbyte.api.model.generated.NotFoundKnownExceptionInfo;
import org.apache.logging.log4j.core.util.Throwables;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.errors;
package io.airbyte.commons.server.errors;

public class InternalServerKnownException extends KnownException {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.commons.server.errors;

import io.airbyte.api.model.generated.InvalidInputExceptionInfo;
import io.airbyte.api.model.generated.InvalidInputProperty;
import io.airbyte.commons.json.Jsons;
import java.util.ArrayList;
import java.util.List;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import org.apache.logging.log4j.core.util.Throwables;

@Provider
public class InvalidInputExceptionMapper implements ExceptionMapper<ConstraintViolationException> {

public static InvalidInputExceptionInfo infoFromConstraints(final ConstraintViolationException cve) {
final InvalidInputExceptionInfo exceptionInfo = new InvalidInputExceptionInfo()
.exceptionClassName(cve.getClass().getName())
.message("Some properties contained invalid input.")
.exceptionStack(Throwables.toStringList(cve));

final List<InvalidInputProperty> props = new ArrayList<InvalidInputProperty>();
for (final ConstraintViolation<?> cv : cve.getConstraintViolations()) {
props.add(new InvalidInputProperty()
.propertyPath(cv.getPropertyPath().toString())
.message(cv.getMessage())
.invalidValue(cv.getInvalidValue() != null ? cv.getInvalidValue().toString() : "null"));
}
exceptionInfo.validationErrors(props);
return exceptionInfo;
}

@Override
public Response toResponse(final ConstraintViolationException e) {
return Response.status(Response.Status.BAD_REQUEST)
.entity(Jsons.serialize(InvalidInputExceptionMapper.infoFromConstraints(e)))
.type("application/json")
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.errors;
package io.airbyte.commons.server.errors;

import com.fasterxml.jackson.core.JsonParseException;
import javax.ws.rs.core.Response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.errors;
package io.airbyte.commons.server.errors;

import com.fasterxml.jackson.databind.JsonMappingException;
import io.airbyte.commons.json.Jsons;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.errors;
package io.airbyte.commons.server.errors;

import io.airbyte.api.model.generated.KnownExceptionInfo;
import org.apache.logging.log4j.core.util.Throwables;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.errors;
package io.airbyte.commons.server.errors;

import io.airbyte.commons.json.Jsons;
import io.micronaut.context.annotation.Requires;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.errors;
package io.airbyte.commons.server.errors;

import io.airbyte.commons.json.Jsons;
import javax.ws.rs.NotFoundException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.errors;
package io.airbyte.commons.server.errors;

import io.airbyte.api.model.generated.KnownExceptionInfo;
import io.airbyte.commons.json.Jsons;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.errors;
package io.airbyte.commons.server.errors;

import io.airbyte.commons.version.Version;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.errors;
package io.airbyte.commons.server.errors;

public class ValueConflictKnownException extends KnownException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.handlers;
package io.airbyte.commons.server.handlers;

import io.airbyte.api.model.generated.InternalOperationResult;
import io.airbyte.api.model.generated.SaveStatsRequestBody;
Expand Down
Loading

0 comments on commit 0b97ce3

Please sign in to comment.