-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
159 additions
and
100 deletions.
There are no files selected for viewing
7 changes: 3 additions & 4 deletions
7
service/src/main/java/bio/terra/appmanager/events/ChartEvents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
package bio.terra.appmanager.events; | ||
|
||
import bio.terra.common.events.client.PubsubClient; | ||
import bio.terra.common.events.client.PubsubClientFactory; | ||
import bio.terra.common.events.config.PubsubConfig; | ||
import bio.terra.common.events.topics.ChartTopic; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public class ChartEvents extends ChartTopic { | ||
|
||
public ChartEvents(PubsubConfig config, PubsubClient client) { | ||
super(config, client); | ||
public ChartEvents(PubsubConfig config, PubsubClientFactory factory) { | ||
super(config, factory); | ||
} | ||
} |
38 changes: 34 additions & 4 deletions
38
service/src/main/java/bio/terra/common/events/client/PubsubClientFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,48 @@ | ||
package bio.terra.common.events.client; | ||
|
||
import bio.terra.common.events.client.google.GooglePubsubClient; | ||
import org.springframework.context.annotation.Bean; | ||
import bio.terra.common.events.config.PubsubConfig; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* Based on the various configs that are out there for pubsub, create an instance of the pubsub | ||
* client to be used by a Spring Boot application. | ||
* | ||
* <p>Current clients supported are: | ||
* | ||
* <ul> | ||
* <li>GoogleClient | ||
* </ul> | ||
* | ||
* <p>This class would need to be added to if additional clients become supported (like Azure, AWS, | ||
* etc.) | ||
*/ | ||
@Component | ||
public class PubsubClientFactory { | ||
|
||
@Bean(name = "pubsubClient") | ||
public PubsubClient createPubsubClient() { | ||
return new GooglePubsubClient(); | ||
private PubsubConfig pubsubConfig; | ||
|
||
public PubsubClientFactory(PubsubConfig config) { | ||
this.pubsubConfig = config; | ||
} | ||
|
||
public PubsubClient createPubsubClient(String topicName) { | ||
return new GooglePubsubClient( | ||
pubsubConfig.googleConfig().projectId(), | ||
formatTopicName(topicName), | ||
pubsubConfig.createTopic()); | ||
} | ||
|
||
private String formatTopicName(String topic) { | ||
List<String> parts = new ArrayList<>(Arrays.asList("event", topic)); | ||
|
||
if (pubsubConfig.nameSuffix() != null) { | ||
parts.add(pubsubConfig.nameSuffix()); | ||
} | ||
|
||
return String.join("-", parts); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
service/src/main/java/bio/terra/common/events/client/google/EventTopicName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
package bio.terra.common.events.client.google; | ||
|
||
import bio.terra.appmanager.config.ChartPublisherConfig; | ||
import com.google.pubsub.v1.TopicName; | ||
import java.io.IOException; | ||
import javax.naming.ConfigurationException; | ||
|
||
public interface EventTopicName { | ||
TopicName getEventTopicName(ChartPublisherConfig config) | ||
throws IOException, ConfigurationException; | ||
TopicName verifyTopicName(String name) throws IOException, ConfigurationException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
service/src/main/java/bio/terra/common/events/client/google/TopicCreatorFactory.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
service/src/main/java/bio/terra/common/events/topics/EventTopic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
service/src/main/java/bio/terra/common/events/topics/messages/ChartCreated.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
service/src/main/java/bio/terra/common/events/topics/messages/ChartDeleted.java
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...ra/common/events/topics/EventMessage.java → .../events/topics/messages/EventMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...erra/common/events/topics/EventTypes.java → ...on/events/topics/messages/EventTypes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.