diff --git a/airbyte-api/src/main/java/io/airbyte/api/client/AirbyteApiClient.java b/airbyte-api/src/main/java/io/airbyte/api/client/AirbyteApiClient.java index f133f1f364fb..740b5edca86a 100644 --- a/airbyte-api/src/main/java/io/airbyte/api/client/AirbyteApiClient.java +++ b/airbyte-api/src/main/java/io/airbyte/api/client/AirbyteApiClient.java @@ -74,7 +74,7 @@ public AirbyteApiClient(final ApiClient apiClient, final ApiClient micronautApiC workspaceApi = new WorkspaceApi(apiClient); healthApi = new HealthApi(micronautApiClient); attemptApi = new AttemptApi(micronautApiClient); - stateApi = new StateApi(apiClient); + stateApi = new StateApi(micronautApiClient); } public ConnectionApi getConnectionApi() { diff --git a/airbyte-proxy/nginx-auth.conf.template b/airbyte-proxy/nginx-auth.conf.template index 7196e0912bdb..3a8668fe0a9d 100644 --- a/airbyte-proxy/nginx-auth.conf.template +++ b/airbyte-proxy/nginx-auth.conf.template @@ -38,7 +38,7 @@ http { } } - location ~ ^/api/v1/(connections|destinations|destination_definitions|operations)/.* { + location ~ ^/api/v1/(connections|destinations|destination_definitions|operations|state)/.* { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -93,7 +93,7 @@ http { } } - location ~ ^/api/v1/(connections|destinations|destination_definitions|operations)/.* { + location ~ ^/api/v1/(connections|destinations|destination_definitions|operations|state)/.* { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/airbyte-proxy/nginx-no-auth.conf.template b/airbyte-proxy/nginx-no-auth.conf.template index ef4088199780..dcf9e3f0cd73 100644 --- a/airbyte-proxy/nginx-no-auth.conf.template +++ b/airbyte-proxy/nginx-no-auth.conf.template @@ -20,7 +20,7 @@ http { proxy_pass "${PROXY_PASS_MICRONAUT_API}"; } - location ~ ^/api/v1/(connections|destinations|destination_definitions|operations)/.* { + location ~ ^/api/v1/(connections|destinations|destination_definitions|operations|state)/.* { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -48,7 +48,7 @@ http { proxy_pass "${PROXY_PASS_MICRONAUT_API}"; } - location ~ ^/api/v1/(connections|destinations|destination_definitions|operations)/.* { + location ~ ^/api/v1/(connections|destinations|destination_definitions|operations|state)/.* { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/airbyte-server/src/main/java/io/airbyte/server/ServerApp.java b/airbyte-server/src/main/java/io/airbyte/server/ServerApp.java index 6437d876a580..a80ce3bcbfb0 100644 --- a/airbyte-server/src/main/java/io/airbyte/server/ServerApp.java +++ b/airbyte-server/src/main/java/io/airbyte/server/ServerApp.java @@ -371,7 +371,6 @@ public static ServerRunnable getServer(final ServerFactory apiFactory, schedulerHandler, sourceHandler, sourceDefinitionsHandler, - stateHandler, workspacesHandler, webBackendConnectionsHandler, webBackendGeographiesHandler, diff --git a/airbyte-server/src/main/java/io/airbyte/server/ServerFactory.java b/airbyte-server/src/main/java/io/airbyte/server/ServerFactory.java index ba83133f0063..8ca027c8afbf 100644 --- a/airbyte-server/src/main/java/io/airbyte/server/ServerFactory.java +++ b/airbyte-server/src/main/java/io/airbyte/server/ServerFactory.java @@ -25,7 +25,6 @@ import io.airbyte.server.apis.SourceDefinitionApiController; import io.airbyte.server.apis.SourceDefinitionSpecificationApiController; import io.airbyte.server.apis.SourceOauthApiController; -import io.airbyte.server.apis.StateApiController; import io.airbyte.server.apis.WebBackendApiController; import io.airbyte.server.apis.WorkspaceApiController; import io.airbyte.server.apis.binders.DestinationDefinitionSpecificationApiBinder; @@ -38,7 +37,6 @@ import io.airbyte.server.apis.binders.SourceDefinitionApiBinder; import io.airbyte.server.apis.binders.SourceDefinitionSpecificationApiBinder; import io.airbyte.server.apis.binders.SourceOauthApiBinder; -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.DestinationDefinitionSpecificationApiFactory; @@ -51,7 +49,6 @@ import io.airbyte.server.apis.factories.SourceDefinitionApiFactory; import io.airbyte.server.apis.factories.SourceDefinitionSpecificationApiFactory; import io.airbyte.server.apis.factories.SourceOauthApiFactory; -import io.airbyte.server.apis.factories.StateApiFactory; import io.airbyte.server.apis.factories.WebBackendApiFactory; import io.airbyte.server.apis.factories.WorkspaceApiFactory; import io.airbyte.server.handlers.AttemptHandler; @@ -66,7 +63,6 @@ import io.airbyte.server.handlers.SchedulerHandler; import io.airbyte.server.handlers.SourceDefinitionsHandler; import io.airbyte.server.handlers.SourceHandler; -import io.airbyte.server.handlers.StateHandler; import io.airbyte.server.handlers.WebBackendCheckUpdatesHandler; import io.airbyte.server.handlers.WebBackendConnectionsHandler; import io.airbyte.server.handlers.WebBackendGeographiesHandler; @@ -110,7 +106,6 @@ ServerRunnable create(final SynchronousSchedulerClient synchronousSchedulerClien final SchedulerHandler schedulerHandler, final SourceHandler sourceHandler, final SourceDefinitionsHandler sourceDefinitionsHandler, - final StateHandler stateHandler, final WorkspacesHandler workspacesHandler, final WebBackendConnectionsHandler webBackendConnectionsHandler, final WebBackendGeographiesHandler webBackendGeographiesHandler, @@ -147,7 +142,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul final SchedulerHandler schedulerHandler, final SourceHandler sourceHandler, final SourceDefinitionsHandler sourceDefinitionsHandler, - final StateHandler stateHandler, final WorkspacesHandler workspacesHandler, final WebBackendConnectionsHandler webBackendConnectionsHandler, final WebBackendGeographiesHandler webBackendGeographiesHandler, @@ -174,8 +168,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul SourceDefinitionSpecificationApiFactory.setValues(schedulerHandler); - StateApiFactory.setValues(stateHandler); - WebBackendApiFactory.setValues(webBackendConnectionsHandler, webBackendGeographiesHandler, webBackendCheckUpdatesHandler); WorkspaceApiFactory.setValues(workspacesHandler); @@ -194,7 +186,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul SourceDefinitionApiController.class, SourceDefinitionSpecificationApiController.class, SourceOauthApiController.class, - StateApiController.class, WebBackendApiController.class, WorkspaceApiController.class); @@ -209,7 +200,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul new SourceDefinitionApiBinder(), new SourceDefinitionSpecificationApiBinder(), new SourceOauthApiBinder(), - new StateApiBinder(), new WebBackendApiBinder(), new WorkspaceApiBinder()); diff --git a/airbyte-server/src/main/java/io/airbyte/server/apis/StateApiController.java b/airbyte-server/src/main/java/io/airbyte/server/apis/StateApiController.java index e148c1010fe3..0692d4f475ba 100644 --- a/airbyte-server/src/main/java/io/airbyte/server/apis/StateApiController.java +++ b/airbyte-server/src/main/java/io/airbyte/server/apis/StateApiController.java @@ -9,20 +9,25 @@ import io.airbyte.api.model.generated.ConnectionState; import io.airbyte.api.model.generated.ConnectionStateCreateOrUpdate; import io.airbyte.server.handlers.StateHandler; -import javax.ws.rs.Path; -import lombok.AllArgsConstructor; +import io.micronaut.http.annotation.Controller; +import io.micronaut.http.annotation.Post; -@Path("/v1/state") -@AllArgsConstructor +@Controller("/api/v1/state") public class StateApiController implements StateApi { private final StateHandler stateHandler; + public StateApiController(final StateHandler stateHandler) { + this.stateHandler = stateHandler; + } + + @Post("/create_or_update") @Override public ConnectionState createOrUpdateState(final ConnectionStateCreateOrUpdate connectionStateCreateOrUpdate) { return ApiHelper.execute(() -> stateHandler.createOrUpdateState(connectionStateCreateOrUpdate)); } + @Post("/get") @Override public ConnectionState getState(final ConnectionIdRequestBody connectionIdRequestBody) { return ApiHelper.execute(() -> stateHandler.getState(connectionIdRequestBody)); diff --git a/airbyte-server/src/main/java/io/airbyte/server/apis/binders/StateApiBinder.java b/airbyte-server/src/main/java/io/airbyte/server/apis/binders/StateApiBinder.java deleted file mode 100644 index 65ab669528c0..000000000000 --- a/airbyte-server/src/main/java/io/airbyte/server/apis/binders/StateApiBinder.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Airbyte, Inc., all rights reserved. - */ - -package io.airbyte.server.apis.binders; - -import io.airbyte.server.apis.StateApiController; -import io.airbyte.server.apis.factories.StateApiFactory; -import org.glassfish.hk2.utilities.binding.AbstractBinder; -import org.glassfish.jersey.process.internal.RequestScoped; - -public class StateApiBinder extends AbstractBinder { - - @Override - protected void configure() { - bindFactory(StateApiFactory.class) - .to(StateApiController.class) - .in(RequestScoped.class); - } - -} diff --git a/airbyte-server/src/main/java/io/airbyte/server/apis/factories/StateApiFactory.java b/airbyte-server/src/main/java/io/airbyte/server/apis/factories/StateApiFactory.java deleted file mode 100644 index 0498681d7629..000000000000 --- a/airbyte-server/src/main/java/io/airbyte/server/apis/factories/StateApiFactory.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2022 Airbyte, Inc., all rights reserved. - */ - -package io.airbyte.server.apis.factories; - -import io.airbyte.server.apis.StateApiController; -import io.airbyte.server.handlers.StateHandler; -import org.glassfish.hk2.api.Factory; - -public class StateApiFactory implements Factory { - - private static StateHandler stateHandler; - - public static void setValues(final StateHandler stateHandler) { - StateApiFactory.stateHandler = stateHandler; - } - - @Override - public StateApiController provide() { - return new StateApiController(StateApiFactory.stateHandler); - } - - @Override - public void dispose(final StateApiController instance) { - /* no op */ - } - -} diff --git a/airbyte-server/src/main/java/io/airbyte/server/handlers/StateHandler.java b/airbyte-server/src/main/java/io/airbyte/server/handlers/StateHandler.java index c9a42e9e3b93..977f95813aad 100644 --- a/airbyte-server/src/main/java/io/airbyte/server/handlers/StateHandler.java +++ b/airbyte-server/src/main/java/io/airbyte/server/handlers/StateHandler.java @@ -10,10 +10,12 @@ import io.airbyte.config.StateWrapper; import io.airbyte.config.persistence.StatePersistence; import io.airbyte.workers.helper.StateConverter; +import jakarta.inject.Singleton; import java.io.IOException; import java.util.Optional; import java.util.UUID; +@Singleton public class StateHandler { private final StatePersistence statePersistence;