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 the server to micronaut #19194

Merged
merged 143 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
143 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
35a8624
tmp
benmoriceau Nov 9, 2022
f8452dd
Checkstyle
benmoriceau Nov 9, 2022
3d8948d
tmp
benmoriceau Nov 10, 2022
a4a5b5d
tmp
benmoriceau Nov 10, 2022
7639d5d
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Nov 15, 2022
470f637
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Nov 15, 2022
abfd514
Inject but don't resolve Bean
benmoriceau Nov 16, 2022
46c9d8e
tmp
benmoriceau Nov 16, 2022
b67653c
Tmp
benmoriceau Nov 16, 2022
b6b397e
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Nov 18, 2022
3b5b39c
fix build
benmoriceau Nov 18, 2022
1358315
TMP
benmoriceau Nov 21, 2022
1a60f15
Tmp
benmoriceau Nov 22, 2022
6229c09
Clean up
benmoriceau Nov 22, 2022
e24a488
better thread pool
benmoriceau Nov 22, 2022
0d8ae2f
Change port to 8080
benmoriceau Nov 22, 2022
ce1932e
Fix port
benmoriceau Nov 22, 2022
6c4da77
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Nov 22, 2022
f5b23cf
Rm unused
benmoriceau Nov 22, 2022
bba0af8
Cors filter
benmoriceau Nov 22, 2022
5e2c9a5
Format
benmoriceau Nov 22, 2022
002a39e
rename
benmoriceau Nov 28, 2022
4d36cd1
Tmp
benmoriceau Nov 30, 2022
f5cbc7b
Config based
benmoriceau Nov 30, 2022
3b2e18a
Rm health controller ref
benmoriceau Nov 30, 2022
bad7f07
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Nov 30, 2022
d3aecda
tmp
benmoriceau Nov 30, 2022
8f03443
Pool size
benmoriceau Dec 1, 2022
4666776
Mock healthcheck
benmoriceau Dec 2, 2022
267094a
Revert "Mock healthcheck"
benmoriceau Dec 2, 2022
95fa38c
Revert "Revert "Mock healthcheck""
benmoriceau Dec 2, 2022
245dd11
Restore health check
benmoriceau Dec 2, 2022
c237c8e
Tmp
benmoriceau Dec 2, 2022
4447ba8
format
benmoriceau Dec 2, 2022
57b0af8
Rm deprecated
benmoriceau Dec 2, 2022
8fef069
Fix PMD
benmoriceau Dec 3, 2022
44146ef
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Dec 3, 2022
77ff93a
Tmp
benmoriceau Dec 5, 2022
1c84878
Fix proxy test
benmoriceau Dec 5, 2022
a3fadde
Remove useless annotation
benmoriceau Dec 5, 2022
03d902a
set auto commit as false
benmoriceau Dec 7, 2022
caef0f6
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Dec 7, 2022
3c55fb0
Clean up and PR comments
benmoriceau Dec 7, 2022
92a5efa
Bmoric/convert attempt micronaut (#19847)
benmoriceau Dec 7, 2022
1dd8988
Comments and banner
benmoriceau Dec 7, 2022
6542588
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Dec 7, 2022
1d5ccae
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Dec 8, 2022
8402ffd
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Dec 8, 2022
f78b7ac
Non related files
benmoriceau Dec 8, 2022
04a2cac
rm tmp
benmoriceau Dec 8, 2022
2eece6d
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Dec 8, 2022
eb31d50
Fix build
benmoriceau Dec 8, 2022
a91d26b
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Dec 9, 2022
018d3dd
Format
benmoriceau Dec 9, 2022
d50555d
Hit the micronaut server directly
benmoriceau Dec 9, 2022
ce9127e
micronaut OperationApiController (#20270)
colesnodgrass Dec 9, 2022
01d5ebc
Bmoric/convert connection micronaut (#20211)
benmoriceau Dec 9, 2022
fa87e26
Bmoric/convert destination controller micronaut (#20269)
benmoriceau Dec 9, 2022
cb5d151
Bmoric/convert destination definition controller micronaut (#20277)
benmoriceau Dec 9, 2022
d35f939
convert StateApiController to Micronaut (#20329)
colesnodgrass Dec 9, 2022
db06338
Move dest oauth to micronaut (#20318)
benmoriceau Dec 9, 2022
711a7c7
Bmoric/convert source micronaut (#20334)
benmoriceau Dec 9, 2022
45cac68
Migrate to micronaut (#20339)
benmoriceau Dec 12, 2022
06c0af8
Migrate source to micronaut
benmoriceau Dec 12, 2022
ae5fad3
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Dec 12, 2022
f801280
convert SchedulerApiController to Micronaut (#20337)
colesnodgrass Dec 12, 2022
9fe2319
Bmoric/convert source definition micronaut (#20338)
benmoriceau Dec 12, 2022
fe595fb
update SourceOauthApiController to Micronaut (#20386)
colesnodgrass Dec 12, 2022
e9484a5
convert WorkspaceApiController to micronaut (#20214)
colesnodgrass Dec 12, 2022
1f257ed
Bmoric/convert jobs micronaut (#20382)
benmoriceau Dec 12, 2022
013135e
Bmoric/convert source definition specification micronaut (#20379)
benmoriceau Dec 12, 2022
38314dc
convert database assert call to Micronaut (#20406)
colesnodgrass Dec 13, 2022
ae2e034
convert NotificationsApiController to Micronaut (#20396)
colesnodgrass Dec 13, 2022
a8c11d2
Migrate logs to micronaut (#20400)
benmoriceau Dec 13, 2022
6a480ef
Bmoric/convert webbackend micronaut (#20403)
benmoriceau Dec 13, 2022
c0682a3
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Dec 21, 2022
5d13c4c
Cleanup (#20459)
benmoriceau Dec 21, 2022
fcb271d
Delete logs API
benmoriceau Dec 22, 2022
990a681
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Dec 22, 2022
60cbe90
Revert "Delete logs API"
benmoriceau Dec 23, 2022
a43f2d3
Rm flaky test
benmoriceau Dec 23, 2022
f001bdb
Format
benmoriceau Dec 23, 2022
97dd2df
Try to fix test
benmoriceau Dec 23, 2022
53f30c5
Format
benmoriceau Dec 24, 2022
c0a9ebc
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Jan 3, 2023
3e2c92f
Remove optional
benmoriceau Jan 3, 2023
f085d82
Rm import
benmoriceau Jan 3, 2023
ddf7228
Test sleep
benmoriceau Jan 3, 2023
33c5842
Simplify injection
benmoriceau Jan 3, 2023
ab6fead
update import
benmoriceau Jan 3, 2023
44caebb
Remove sleep
benmoriceau Jan 3, 2023
d2029e4
More injection
benmoriceau Jan 3, 2023
fb153cc
Remove more requirement
benmoriceau Jan 3, 2023
2f5602e
imports
benmoriceau Jan 3, 2023
bf8586e
Remove more requirement
benmoriceau Jan 3, 2023
250a6b3
Fix yaml
benmoriceau Jan 3, 2023
c390464
Remove unused conf
benmoriceau Jan 3, 2023
624edd9
Add role
benmoriceau Jan 3, 2023
e6e04f1
Test acceptance test
benmoriceau Jan 3, 2023
ad554f1
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Jan 3, 2023
19a1603
Update env
benmoriceau Jan 4, 2023
09ff988
Revert "Update to Micronaut 3.8.0 (#20716)"
benmoriceau Jan 4, 2023
c183e67
Update helm chart
benmoriceau Jan 4, 2023
446f8c2
Fix helm chart
benmoriceau Jan 4, 2023
d4b4d49
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Jan 4, 2023
55b1499
Convert Application Listener
benmoriceau Jan 5, 2023
18ebd34
Format
benmoriceau Jan 5, 2023
90e1ebe
Add explicit deployment mode
benmoriceau Jan 5, 2023
95d1c24
Change check port
benmoriceau Jan 5, 2023
f7c1e0c
Update version and bump version to the right value
benmoriceau Jan 5, 2023
dcb85ec
Cleanup
benmoriceau Jan 5, 2023
ecc6798
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Jan 5, 2023
777270a
Update FE end to end test
benmoriceau Jan 5, 2023
24cd7a8
Allow head request
benmoriceau Jan 5, 2023
d943232
Merge branch 'master' into bmoric/convert-health-micronaut
benmoriceau Jan 5, 2023
80264fd
Merge branch 'master' into bmoric/convert-health-micronaut
benmoriceau Jan 5, 2023
d046c55
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Jan 6, 2023
2e282b9
Fix controller
benmoriceau Jan 6, 2023
61bf41b
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Jan 6, 2023
d6c7db6
Format
benmoriceau Jan 6, 2023
cfd8881
Fix http client Bean
benmoriceau Jan 6, 2023
6e2c561
Format
benmoriceau Jan 6, 2023
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 @@ -17,6 +17,7 @@
import io.airbyte.config.storage.CloudStorageConfigs.GcsConfig;
import io.airbyte.config.storage.CloudStorageConfigs.MinioConfig;
import io.airbyte.config.storage.CloudStorageConfigs.S3Config;
import jakarta.inject.Singleton;
import java.net.URI;
import java.nio.file.Path;
import java.util.Arrays;
Expand All @@ -35,6 +36,7 @@
import org.slf4j.LoggerFactory;

@SuppressWarnings({"PMD.LongVariable", "PMD.CyclomaticComplexity", "PMD.AvoidReassigningParameters", "PMD.ConstructorCallsOverridableMethod"})
@Singleton
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is temporary, the values needed will be move to the handler creation as they are needed (the health check doesn't need any)

public class EnvConfigs implements Configs {

private static final Logger LOGGER = LoggerFactory.getLogger(EnvConfigs.class);
Expand Down
1 change: 1 addition & 0 deletions airbyte-proxy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN apt-get update -y && apt-get install -y apache2-utils && rm -rf /var/lib/apt
# This variable can be used to update the destination containers that Nginx proxies to.
ENV PROXY_PASS_WEB "http://airbyte-webapp:80"
ENV PROXY_PASS_API "http://airbyte-server:8001"
ENV PROXY_PASS_MICRONAUT_API "http://airbyte-server:8080"
evantahler marked this conversation as resolved.
Show resolved Hide resolved
ENV CONNECTOR_BUILDER_SERVER_API "http://airbyte-connector-builder-server:80"

# Nginx config file
Expand Down
34 changes: 34 additions & 0 deletions airbyte-proxy/nginx-auth.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ http {
auth_basic off;
}
}

location /api/v1/health {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

auth_basic "Welcome to Airbyte";
auth_basic_user_file /etc/nginx/.htpasswd;

proxy_pass "${PROXY_PASS_MICRONAUT_API}";

error_page 401 /etc/nginx/401.html;
location ~ (401.html)$ {
alias /etc/nginx/$1;
auth_basic off;
}
}
}

server {
Expand All @@ -41,6 +58,23 @@ http {
auth_basic off;
}
}

location /api/v1/health {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

auth_basic "Welcome to Airbyte";
auth_basic_user_file /etc/nginx/.htpasswd;

proxy_pass "${PROXY_PASS_MICRONAUT_API}";

error_page 401 /etc/nginx/401.html;
location ~ (401.html)$ {
alias /etc/nginx/$1;
auth_basic off;
}
}
}

server {
Expand Down
16 changes: 16 additions & 0 deletions airbyte-proxy/nginx-no-auth.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ http {

proxy_pass "${PROXY_PASS_WEB}";
}

location /api/v1/health {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass "${PROXY_PASS_MICRONAUT_API}";
}
}

server {
Expand All @@ -23,6 +31,14 @@ http {

proxy_pass "${PROXY_PASS_API}";
}

location /api/v1/health {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass "${PROXY_PASS_MICRONAUT_API}";
}
}

server {
Expand Down
2 changes: 1 addition & 1 deletion airbyte-proxy/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ else
TEMPLATE_PATH="/etc/nginx/templates/nginx-auth.conf.template"
fi

envsubst '${PROXY_PASS_WEB} ${PROXY_PASS_API} ${CONNECTOR_BUILDER_SERVER_API} ${PROXY_PASS_RESOLVER}' < $TEMPLATE_PATH > /etc/nginx/nginx.conf
envsubst '${PROXY_PASS_WEB} ${PROXY_PASS_API} ${PROXY_PASS_MICRONAUT_API} ${CONNECTOR_BUILDER_SERVER_API} ${PROXY_PASS_RESOLVER}' < $TEMPLATE_PATH > /etc/nginx/nginx.conf

echo "starting nginx..."
nginx -v
Expand Down
19 changes: 16 additions & 3 deletions airbyte-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ plugins {

configurations.all {
exclude group: 'io.micronaut.jaxrs'
exclude group: 'io.micronaut.sql'
}

dependencies {
Expand All @@ -24,7 +23,6 @@ dependencies {
implementation project(':airbyte-protocol:protocol-models')
implementation project(':airbyte-persistence:job-persistence')

implementation libs.flyway.core
implementation 'com.github.slugify:slugify:2.4'
implementation 'commons-cli:commons-cli:1.4'
implementation libs.temporal.sdk
Expand All @@ -37,7 +35,19 @@ dependencies {
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.swagger:swagger-annotations:1.6.2'

annotationProcessor platform(libs.micronaut.bom)
annotationProcessor libs.bundles.micronaut.annotation.processor

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

// Ensure that the versions defined in deps.toml are used
// instead of versions from transitive dependencies
implementation (libs.flyway.core) {
force = true
}

testImplementation project(':airbyte-test-utils')
testImplementation libs.postgresql
Expand All @@ -56,9 +66,10 @@ task copySeed(type: Copy, dependsOn: [project(':airbyte-config:init').processRes
test.dependsOn(project.tasks.copySeed)
assemble.dependsOn(project.tasks.copySeed)

mainClassName = 'io.airbyte.server.ServerApp'
mainClassName = 'io.airbyte.server.Application'

application {
applicationName = project.name
mainClass = mainClassName
applicationDefaultJvmArgs = ['-XX:+ExitOnOutOfMemoryError', '-XX:MaxRAMPercentage=75.0']
}
Expand Down Expand Up @@ -86,6 +97,8 @@ run {
environment "AIRBYTE_VERSION", env.VERSION
environment "AIRBYTE_ROLE", System.getenv('AIRBYTE_ROLE')
environment "TEMPORAL_HOST", "localhost:7233"

environment 'MICRONAUT_ENVIRONMENTS', 'control-plane'
}

// produce reproducible archives
Expand Down
15 changes: 15 additions & 0 deletions airbyte-server/src/main/java/io/airbyte/server/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server;

import io.micronaut.runtime.Micronaut;

public class Application {

public static void main(final String[] args) {
Micronaut.run(Application.class, args);
}

}
33 changes: 33 additions & 0 deletions airbyte-server/src/main/java/io/airbyte/server/EventListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server;

import io.micronaut.runtime.event.ApplicationStartupEvent;
import io.micronaut.scheduling.TaskExecutors;
import io.micronaut.scheduling.annotation.ExecuteOn;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import lombok.extern.slf4j.Slf4j;

@Singleton
@Slf4j
public class EventListener {

@Inject
ServerRunnable serverRunnable;

@io.micronaut.runtime.event.annotation.EventListener
@ExecuteOn(TaskExecutors.IO)
public void startEmitters(final ApplicationStartupEvent event) {
try {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what used to be in the main of the serverApp

log.error("Starting server");

serverRunnable.start();
} catch (final Exception e) {
throw new RuntimeException(e);
}
}

}
50 changes: 5 additions & 45 deletions airbyte-server/src/main/java/io/airbyte/server/ServerApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import io.airbyte.analytics.Deployment;
import io.airbyte.analytics.TrackingClient;
import io.airbyte.analytics.TrackingClientSingleton;
import io.airbyte.commons.lang.CloseableShutdownHook;
import io.airbyte.commons.resources.MoreResources;
import io.airbyte.commons.temporal.ConnectionManagerUtils;
import io.airbyte.commons.temporal.StreamResetRecordsHelper;
Expand All @@ -16,7 +15,6 @@
import io.airbyte.commons.temporal.TemporalWorkflowUtils;
import io.airbyte.commons.version.AirbyteVersion;
import io.airbyte.config.Configs;
import io.airbyte.config.EnvConfigs;
import io.airbyte.config.helpers.LogClientSingleton;
import io.airbyte.config.persistence.ConfigRepository;
import io.airbyte.config.persistence.SecretsRepositoryReader;
Expand All @@ -27,12 +25,7 @@
import io.airbyte.config.persistence.split_secrets.SecretsHydrator;
import io.airbyte.db.Database;
import io.airbyte.db.check.DatabaseCheckException;
import io.airbyte.db.factory.DSLContextFactory;
import io.airbyte.db.factory.DataSourceFactory;
import io.airbyte.db.factory.DatabaseCheckFactory;
import io.airbyte.db.factory.FlywayFactory;
import io.airbyte.db.instance.configs.ConfigsDatabaseMigrator;
import io.airbyte.db.instance.jobs.JobsDatabaseMigrator;
import io.airbyte.persistence.job.DefaultJobPersistence;
import io.airbyte.persistence.job.JobPersistence;
import io.airbyte.persistence.job.WebUrlHelper;
Expand Down Expand Up @@ -77,7 +70,6 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import javax.sql.DataSource;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
Expand All @@ -86,7 +78,6 @@
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletContainer;
import org.jooq.DSLContext;
import org.jooq.SQLDialect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
Expand All @@ -96,7 +87,6 @@ public class ServerApp implements ServerRunnable {

private static final Logger LOGGER = LoggerFactory.getLogger(ServerApp.class);
private static final int PORT = 8001;
private static final String DRIVER_CLASS_NAME = "org.postgresql.Driver";

private final AirbyteVersion airbyteVersion;
private final Set<Class<?>> customComponentClasses;
Expand Down Expand Up @@ -157,11 +147,11 @@ public void start() throws Exception {
}));
}

private static void assertDatabasesReady(final Configs configs,
final DSLContext configsDslContext,
final Flyway configsFlyway,
final DSLContext jobsDslContext,
final Flyway jobsFlyway)
public static void assertDatabasesReady(final Configs configs,
final DSLContext configsDslContext,
final Flyway configsFlyway,
final DSLContext jobsDslContext,
final Flyway jobsFlyway)
throws DatabaseCheckException {
LOGGER.info("Checking configs database flyway migration version..");
DatabaseCheckFactory
Expand Down Expand Up @@ -385,34 +375,4 @@ public static ServerRunnable getServer(final ServerFactory apiFactory,
webBackendGeographiesHandler);
}

public static void main(final String[] args) {
try {
final Configs configs = new EnvConfigs();

// Manual configuration that will be replaced by Dependency Injection in the future
final DataSource configsDataSource =
DataSourceFactory.create(configs.getConfigDatabaseUser(), configs.getConfigDatabasePassword(), DRIVER_CLASS_NAME,
configs.getConfigDatabaseUrl());
final DataSource jobsDataSource =
DataSourceFactory.create(configs.getDatabaseUser(), configs.getDatabasePassword(), DRIVER_CLASS_NAME, configs.getDatabaseUrl());

try (final DSLContext configsDslContext = DSLContextFactory.create(configsDataSource, SQLDialect.POSTGRES);
final DSLContext jobsDslContext = DSLContextFactory.create(jobsDataSource, SQLDialect.POSTGRES)) {

// Ensure that the database resources are closed on application shutdown
CloseableShutdownHook.registerRuntimeShutdownHook(configsDataSource, jobsDataSource, configsDslContext, jobsDslContext);

final Flyway configsFlyway = FlywayFactory.create(configsDataSource, DbMigrationHandler.class.getSimpleName(),
ConfigsDatabaseMigrator.DB_IDENTIFIER, ConfigsDatabaseMigrator.MIGRATION_FILE_LOCATION);
final Flyway jobsFlyway = FlywayFactory.create(jobsDataSource, DbMigrationHandler.class.getSimpleName(), JobsDatabaseMigrator.DB_IDENTIFIER,
JobsDatabaseMigrator.MIGRATION_FILE_LOCATION);

getServer(new ServerFactory.Api(), configs, configsDslContext, configsFlyway, jobsDslContext, jobsFlyway).start();
}
} catch (final Throwable e) {
LOGGER.error("Server failed", e);
System.exit(1); // so the app doesn't hang on background threads
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import io.airbyte.server.apis.binders.DestinationDefinitionApiBinder;
import io.airbyte.server.apis.binders.DestinationDefinitionSpecificationApiBinder;
import io.airbyte.server.apis.binders.DestinationOauthApiBinder;
import io.airbyte.server.apis.binders.HealthApiBinder;
import io.airbyte.server.apis.binders.JobsApiBinder;
import io.airbyte.server.apis.binders.LogsApiBinder;
import io.airbyte.server.apis.binders.NotificationApiBinder;
Expand All @@ -62,7 +61,6 @@
import io.airbyte.server.apis.factories.DestinationDefinitionApiFactory;
import io.airbyte.server.apis.factories.DestinationDefinitionSpecificationApiFactory;
import io.airbyte.server.apis.factories.DestinationOauthApiFactory;
import io.airbyte.server.apis.factories.HealthApiFactory;
import io.airbyte.server.apis.factories.JobsApiFactory;
import io.airbyte.server.apis.factories.LogsApiFactory;
import io.airbyte.server.apis.factories.NotificationsApiFactory;
Expand Down Expand Up @@ -195,8 +193,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul

DestinationDefinitionSpecificationApiFactory.setValues(schedulerHandler);

HealthApiFactory.setValues(healthCheckHandler);

DestinationOauthApiFactory.setValues(oAuthHandler);

SourceOauthApiFactory.setValues(oAuthHandler);
Expand Down Expand Up @@ -258,7 +254,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
new DestinationDefinitionApiBinder(),
new DestinationDefinitionSpecificationApiBinder(),
new DestinationOauthApiBinder(),
new HealthApiBinder(),
new JobsApiBinder(),
new LogsApiBinder(),
new NotificationApiBinder(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,32 @@

package io.airbyte.server.apis;

import io.airbyte.api.generated.HealthApi;
import io.airbyte.api.model.generated.HealthCheckRead;
import io.airbyte.server.handlers.HealthCheckHandler;
import javax.ws.rs.Path;
import lombok.AllArgsConstructor;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

@Path("/v1/health")
@AllArgsConstructor
public class HealthApiController implements HealthApi {
@Controller("/api/v1/health")
public class HealthApiController {

private final HealthCheckHandler healthCheckHandler;

@Override
public HealthApiController(final HealthCheckHandler healthCheckHandler) {
this.healthCheckHandler = healthCheckHandler;
}

@Get(produces = MediaType.APPLICATION_JSON)
@ApiOperation(value = "Health Check",
notes = "",
tags = {"health"})
@ApiResponses(value = {
@ApiResponse(code = 200,
message = "Successful operation",
response = HealthCheckRead.class)})
public HealthCheckRead getHealthCheck() {
return healthCheckHandler.health();
}
Expand Down
Loading