Skip to content

Commit

Permalink
refactor: into own packages
Browse files Browse the repository at this point in the history
  • Loading branch information
cpate4 committed Jul 30, 2024
1 parent 174276c commit 6752920
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 25 deletions.
12 changes: 7 additions & 5 deletions service/src/main/java/bio/terra/appmanager/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,26 @@
"bio.terra.common.retry.transaction",
// Scan for tracing-related components & configs
"bio.terra.common.tracing",
// Event-driven architecture related configs
"bio.terra.common.events",
// Scan all service-specific packages beneath the current package
"bio.terra.appmanager"
})
@ConfigurationPropertiesScan("bio.terra.appmanager")
@ConfigurationPropertiesScan({"bio.terra.common.events", "bio.terra.appmanager"})
@EnableRetry
@EnableTransactionManagement
@EnableConfigurationProperties
public class App {
public static void main(String[] args) {
new SpringApplicationBuilder(App.class).initializers(new LoggingInitializer()).run(args);
}

private final DataSource dataSource;

public App(DataSource dataSource) {
this.dataSource = dataSource;
}

public static void main(String[] args) {
new SpringApplicationBuilder(App.class).initializers(new LoggingInitializer()).run(args);
}

@Bean("objectMapper")
public ObjectMapper objectMapper() {
return new ObjectMapper()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package bio.terra.appmanager.config;

import bio.terra.common.events.config.GooglePublisherConfiguration;
import bio.terra.common.events.config.PubsubBeeConfig;
import bio.terra.common.events.config.PubsubGoogleConfig;
import org.springframework.context.annotation.Configuration;

@Configuration
Expand All @@ -20,6 +23,9 @@ public String getBaseName() {

@Override
public String getTopicId() {
System.out.println("name: " + beeConfig.name());
System.out.println("is_active: " + beeConfig.isActive());

if (beeConfig.isActive()) {
return getBaseName() + "-" + beeConfig.name();
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package bio.terra.appmanager.dao;

import bio.terra.appmanager.config.GooglePublisherConfiguration;
import bio.terra.common.events.config.GooglePublisherConfiguration;
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutureCallback;
import com.google.api.core.ApiFutures;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package bio.terra.appmanager.config;
package bio.terra.common.events.config;

public interface GooglePublisherConfiguration {
String getBaseName();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package bio.terra.appmanager.config;
package bio.terra.common.events.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "appmanager.pubsub.bee")
@ConfigurationProperties(prefix = "terra.common.pubsub.bee")
public record PubsubBeeConfig(String name, Boolean isActive) {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package bio.terra.appmanager.config;
package bio.terra.common.events.config;

import bio.terra.appmanager.config.ChartPublisherConfig;
import bio.terra.appmanager.dao.EventTopicName;
import bio.terra.appmanager.dao.TopicCreatorFactory;
import com.google.cloud.pubsub.v1.Publisher;
Expand All @@ -16,6 +17,10 @@ public class PubsubConfig {
@Bean
public EventTopicName getEventTopicName(
PubsubBeeConfig beeConfig, PubsubGoogleConfig googleConfig) {

System.out.println("name: " + beeConfig.name());
System.out.println("is_active: " + beeConfig.isActive());

if (beeConfig.isActive()) {
return TopicCreatorFactory.createCreateEventTopicIfNotExist(googleConfig.projectId());
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package bio.terra.appmanager.config;
package bio.terra.common.events.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "appmanager.pubsub.google")
@ConfigurationProperties(prefix = "terra.common.pubsub.google")
public record PubsubGoogleConfig(String projectId) {}
27 changes: 14 additions & 13 deletions service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
# This is for deployment-specific values, which may be managed by other teams

env:
pubsub:
google:
projectId: ${SERVICE_GOOGLE_PROJECT:broad-dsde-dev}
bee:
name: ${BEE_NAME:notabeeenv}
isActive: ${IS_BEE:false}
google:
project_id: ${SERVICE_GOOGLE_PROJECT:broad-dsde-dev}
bee:
name: ${BEE_NAME:notabeeenv}
is_active: ${IS_BEE:false}
admin:
service_accounts_for_read: ${SERVICE_ACCOUNT_ADMINS_FOR_READ:test@readnowhere.com}
service_accounts_for_write: ${SERVICE_ACCOUNT_ADMINS_FOR_WRITE:test@writenowhere.com}
Expand Down Expand Up @@ -74,6 +73,15 @@ management:
exposure:
include: "*"

terra:
common:
pubsub:
google:
project_id: ${env.google.project_id}
bee:
is_active: ${env.bee.is_active}
name: ${env.bee.name}

appmanager:
admin:
service_accounts_for_read: ${env.admin.service_accounts_for_read}
Expand Down Expand Up @@ -102,13 +110,6 @@ appmanager:
sam:
basePath: ${env.sam.basePath}

pubsub:
google:
projectId: ${env.pubsub.google.projectId}
bee:
name: ${env.pubsub.bee.name}
isActive: ${env.pubsub.bee.isActive}

terra.common:
kubernetes:
inKubernetes: false
Expand Down

0 comments on commit 6752920

Please sign in to comment.