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

convert StateApiController to Micronaut #20329

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions airbyte-proxy/nginx-auth.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions airbyte-proxy/nginx-no-auth.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ public static ServerRunnable getServer(final ServerFactory apiFactory,
schedulerHandler,
sourceHandler,
sourceDefinitionsHandler,
stateHandler,
workspacesHandler,
webBackendConnectionsHandler,
webBackendGeographiesHandler,
Expand Down
10 changes: 0 additions & 10 deletions airbyte-server/src/main/java/io/airbyte/server/ServerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -174,8 +168,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul

SourceDefinitionSpecificationApiFactory.setValues(schedulerHandler);

StateApiFactory.setValues(stateHandler);

WebBackendApiFactory.setValues(webBackendConnectionsHandler, webBackendGeographiesHandler, webBackendCheckUpdatesHandler);

WorkspaceApiFactory.setValues(workspacesHandler);
Expand All @@ -194,7 +186,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
SourceDefinitionApiController.class,
SourceDefinitionSpecificationApiController.class,
SourceOauthApiController.class,
StateApiController.class,
WebBackendApiController.class,
WorkspaceApiController.class);

Expand All @@ -209,7 +200,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
new SourceDefinitionApiBinder(),
new SourceDefinitionSpecificationApiBinder(),
new SourceOauthApiBinder(),
new StateApiBinder(),
new WebBackendApiBinder(),
new WorkspaceApiBinder());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down