Skip to content

Commit

Permalink
Bmoric/convert attempt micronaut (#19847)
Browse files Browse the repository at this point in the history
* tmp

* Fix build

* tmp

* Tmp

* tmp

* tmp

* Tmp

* tmp

* tmp

* Clean up
  • Loading branch information
benmoriceau authored Dec 7, 2022
1 parent 3c55fb0 commit 92a5efa
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public AirbyteApiClient(final ApiClient apiClient, final ApiClient micronautApiC
workspaceApi = new WorkspaceApi(apiClient);
healthApi = new HealthApi(micronautApiClient);
dbMigrationApi = new DbMigrationApi(apiClient);
attemptApi = new AttemptApi(apiClient);
attemptApi = new AttemptApi(micronautApiClient);
stateApi = new StateApi(apiClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
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.ConnectionApiController;
import io.airbyte.server.apis.DbMigrationApiController;
import io.airbyte.server.apis.DestinationApiController;
Expand All @@ -33,7 +32,6 @@
import io.airbyte.server.apis.StateApiController;
import io.airbyte.server.apis.WebBackendApiController;
import io.airbyte.server.apis.WorkspaceApiController;
import io.airbyte.server.apis.binders.AttemptApiBinder;
import io.airbyte.server.apis.binders.ConnectionApiBinder;
import io.airbyte.server.apis.binders.DbMigrationBinder;
import io.airbyte.server.apis.binders.DestinationApiBinder;
Expand All @@ -53,7 +51,6 @@
import io.airbyte.server.apis.binders.StateApiBinder;
import io.airbyte.server.apis.binders.WebBackendApiBinder;
import io.airbyte.server.apis.binders.WorkspaceApiBinder;
import io.airbyte.server.apis.factories.AttemptApiFactory;
import io.airbyte.server.apis.factories.ConnectionApiFactory;
import io.airbyte.server.apis.factories.DbMigrationApiFactory;
import io.airbyte.server.apis.factories.DestinationApiFactory;
Expand Down Expand Up @@ -176,8 +173,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
final WebBackendGeographiesHandler webBackendGeographiesHandler) {
final Map<String, String> mdc = MDC.getCopyOfContextMap();

AttemptApiFactory.setValues(attemptHandler, mdc);

ConnectionApiFactory.setValues(
connectionsHandler,
operationsHandler,
Expand Down Expand Up @@ -222,7 +217,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul

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

final Set<Object> components = Set.of(
new CorsFilter(),
new AttemptApiBinder(),
new ConnectionApiBinder(),
new DbMigrationBinder(),
new DestinationApiBinder(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import io.airbyte.api.model.generated.SaveStatsRequestBody;
import io.airbyte.api.model.generated.SetWorkflowInAttemptRequestBody;
import io.airbyte.server.handlers.AttemptHandler;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Body;
import io.micronaut.http.annotation.Post;
import javax.ws.rs.Path;

@Path("/api/v1/attempt/")
Expand All @@ -22,11 +24,15 @@ public AttemptApiController(final AttemptHandler attemptHandler) {
}

@Override
public InternalOperationResult saveStats(final SaveStatsRequestBody saveStatsRequestBody) {
@Post(uri = "/save_stats",
processes = MediaType.APPLICATION_JSON)
public InternalOperationResult saveStats(@Body final SaveStatsRequestBody saveStatsRequestBody) {
throw new UnsupportedOperationException();
}

@Override
@Post(uri = "/set_workflow_in_attempt",
processes = MediaType.APPLICATION_JSON)
public InternalOperationResult setWorkflowInAttempt(@Body final SetWorkflowInAttemptRequestBody requestBody) {
return ApiHelper.execute(() -> attemptHandler.setWorkflowInAttempt(requestBody));
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import io.airbyte.commons.temporal.config.WorkerMode;
import io.airbyte.config.persistence.ConfigRepository;
import io.airbyte.persistence.job.JobPersistence;
import io.airbyte.server.handlers.AttemptHandler;
import io.airbyte.server.handlers.HealthCheckHandler;
import io.micronaut.context.annotation.Factory;
import io.micronaut.context.annotation.Requires;
Expand All @@ -21,4 +23,10 @@ public HealthCheckHandler healthCheckHandler(@Named("configRepository") final Co
return new HealthCheckHandler(configRepository);
}

@Singleton
@Requires(env = WorkerMode.CONTROL_PLANE)
public AttemptHandler attemptHandler(final JobPersistence jobPersistence) {
return new AttemptHandler(jobPersistence);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
import io.micronaut.http.filter.HttpServerFilter;
import io.micronaut.http.filter.ServerFilterChain;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.reactivestreams.Publisher;

// https://medium.com/@Leejjon_net/how-to-allow-cross-origin-requests-in-a-jax-rs-microservice-d2a6aa2df484
@Filter("/**")
@Slf4j
public class CorsFilter implements HttpServerFilter {

public static final Map<String, String> MAP = Map.of(
Expand Down
4 changes: 4 additions & 0 deletions airbyte-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ micronaut:
httpMethod: GET
access:
- isAnonymous()
- pattern: /**
httpMethod: POST
access:
- isAnonymous()
server:
port: 8080
airbyte:
Expand Down

0 comments on commit 92a5efa

Please sign in to comment.