Skip to content

Commit

Permalink
refactor(pubsub): split into core and provider specific modules (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
emjburns committed Mar 22, 2018
1 parent d44b09e commit 1d4edfd
Show file tree
Hide file tree
Showing 39 changed files with 71 additions and 30 deletions.
23 changes: 23 additions & 0 deletions echo-pubsub-aws/echo-pubsub-aws.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2018 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

dependencies {
compile project(':echo-pubsub-core')
compile spinnaker.dependency("objenesis")
compile spinnaker.dependency("cglib")
compile spinnaker.dependency("aws")
compile spinnaker.dependency("korkAws")
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.netflix.spinnaker.echo.config.amazon;
package com.netflix.spinnaker.echo.config;

import com.netflix.spinnaker.kork.aws.bastion.BastionConfig;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.netflix.spinnaker.echo.config.amazon;
package com.netflix.spinnaker.echo.config;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -103,7 +103,7 @@ public InputStream readTemplatePath() {
}

public static enum MessageFormat {
S3("/amazon/s3.jinja"),
S3("/s3.jinja"),
CUSTOM(),
NONE();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.netflix.spinnaker.echo.pubsub.amazon;
package com.netflix.spinnaker.echo.pubsub.aws;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.netflix.spinnaker.echo.pubsub.amazon;
package com.netflix.spinnaker.echo.pubsub.aws;

import com.amazonaws.services.sqs.AmazonSQS;
import com.amazonaws.services.sqs.model.Message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.netflix.spinnaker.echo.pubsub.amazon;
package com.netflix.spinnaker.echo.pubsub.aws;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.netflix.spinnaker.echo.pubsub.amazon;
package com.netflix.spinnaker.echo.pubsub.aws;

import com.amazonaws.auth.policy.*;
import com.amazonaws.auth.policy.actions.SQSActions;
Expand All @@ -27,7 +27,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.echo.artifacts.MessageArtifactTranslator;
import com.netflix.spinnaker.echo.config.amazon.AmazonPubsubProperties;
import com.netflix.spinnaker.echo.config.AmazonPubsubProperties;
import com.netflix.spinnaker.echo.model.pubsub.MessageDescription;
import com.netflix.spinnaker.echo.model.pubsub.PubsubSystem;
import com.netflix.spinnaker.echo.pubsub.PubsubMessageHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,28 @@
* limitations under the License.
*/

package com.netflix.spinnaker.echo.pubsub.amazon;
package com.netflix.spinnaker.echo.pubsub.aws;

import com.amazonaws.ClientConfiguration;
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.services.sns.AmazonSNSClientBuilder;
import com.amazonaws.services.sqs.AmazonSQSClientBuilder;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.echo.config.amazon.AmazonPubsubProperties;
import com.netflix.spinnaker.echo.config.AmazonPubsubProperties;
import com.netflix.spinnaker.echo.discovery.DiscoveryActivated;
import com.netflix.spinnaker.echo.pubsub.PubsubMessageHandler;
import com.netflix.spinnaker.echo.pubsub.PubsubSubscribers;
import com.netflix.spinnaker.echo.pubsub.model.PubsubSubscriber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.RejectedExecutionException;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,19 @@
* limitations under the License.
*/

package com.netflix.spinnaker.echo.pubsub.amazon
package com.netflix.spinnaker.echo.pubsub.aws

import com.amazonaws.services.sns.AmazonSNS
import com.amazonaws.services.sqs.AmazonSQS
import com.amazonaws.services.sqs.model.CreateQueueResult
import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.spectator.api.Registry
import com.netflix.spinnaker.echo.config.amazon.AmazonPubsubProperties
import com.netflix.spinnaker.echo.config.AmazonPubsubProperties
import com.netflix.spinnaker.echo.pubsub.PubsubMessageHandler
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Subject

import java.util.concurrent.atomic.AtomicBoolean

class AmazonSQSSubscriberSpec extends Specification {

AmazonSNS amazonSNS = Mock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,4 @@ dependencies {
compile spinnaker.dependency('kork')
compile spinnaker.dependency("korkJedis")
compile spinnaker.dependency("korkJedisTest")
compile spinnaker.dependency("aws")
compile spinnaker.dependency("korkAws")

compile 'com.google.cloud:google-cloud-pubsub:0.33.0-beta'
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@

package com.netflix.spinnaker.echo.config.kafka;

// TODO: move to pubsub-kafka module
public class KafkaConfig {
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@

package com.netflix.spinnaker.echo.config.kafka;

// TODO: move to pubsub-kafka module
public class KafkaProperties {
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@

package com.netflix.spinnaker.echo.pubsub.kafka;

// TODO: move to pubsub-kafka module
public class KafkaMonitor {
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@

package com.netflix.spinnaker.echo.pubsub.kafka;

// TODO: move to pubsub-kafka module
public class KafkaSubscriber {
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.spinnaker.echo.model.pubsub.MessageDescription
import com.netflix.spinnaker.echo.model.pubsub.PubsubSystem
import com.netflix.spinnaker.echo.pipelinetriggers.monitor.PubsubEventMonitor
import com.netflix.spinnaker.echo.pubsub.google.GoogleMessageAcknowledger
import com.netflix.spinnaker.echo.pubsub.model.MessageAcknowledger
import com.netflix.spinnaker.kork.jedis.EmbeddedRedis
import com.netflix.spinnaker.kork.jedis.JedisClientDelegate
import com.netflix.spinnaker.kork.jedis.RedisClientDelegate
Expand Down Expand Up @@ -126,7 +126,7 @@ class PubsubMessageHandlerSpec extends Specification {
.retentionDeadlineMillis(10001)
.build()

def acker = Mock(GoogleMessageAcknowledger)
def acker = Mock(MessageAcknowledger)
String id = 'id'

when:
Expand All @@ -149,7 +149,7 @@ class PubsubMessageHandlerSpec extends Specification {
.retentionDeadlineMillis(10001)
.build()

def acker = Mock(GoogleMessageAcknowledger)
def acker = Mock(MessageAcknowledger)
String id = 'id'

when:
Expand Down
20 changes: 20 additions & 0 deletions echo-pubsub-google/echo-pubsub-google.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2018 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

dependencies {
compile project(':echo-pubsub-core')
compile 'com.google.cloud:google-cloud-pubsub:0.33.0-beta'
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.netflix.spinnaker.echo.config.google;
package com.netflix.spinnaker.echo.config;

import com.netflix.spinnaker.echo.pubsub.PubsubMessageHandler;
import com.netflix.spinnaker.echo.pubsub.PubsubSubscribers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package com.netflix.spinnaker.echo.config.google;
package com.netflix.spinnaker.echo.config;

import lombok.Data;
import lombok.NoArgsConstructor;
Expand Down Expand Up @@ -78,8 +78,8 @@ public InputStream readTemplatePath() {
}

public static enum MessageFormat {
GCS("/google/gcs.jinja"),
GCR("/google/gcr.jinja"),
GCS("/gcs.jinja"),
GCR("/gcr.jinja"),
CUSTOM();

private String jarPath = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import com.google.pubsub.v1.PubsubMessage;
import com.google.pubsub.v1.SubscriptionName;
import com.netflix.spinnaker.echo.artifacts.MessageArtifactTranslator;
import com.netflix.spinnaker.echo.config.google.GooglePubsubProperties;
import com.netflix.spinnaker.echo.config.GooglePubsubProperties;
import com.netflix.spinnaker.echo.model.pubsub.MessageDescription;
import com.netflix.spinnaker.echo.model.pubsub.PubsubSystem;
import com.netflix.spinnaker.echo.pubsub.PubsubMessageHandler;
Expand Down
4 changes: 3 additions & 1 deletion echo-web/echo-web.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ dependencies {
compile project(':echo-scheduler')
compile project(':echo-rest')
compile project(':echo-webhooks')
compile project(':echo-pubsub')
compile project(':echo-pubsub-core')
compile project(':echo-pubsub-aws')
compile project(':echo-pubsub-google')
compile spinnaker.dependency('kork')
compile spinnaker.dependency('korkStackdriver')
compile spinnaker.dependency('korkWeb')
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

include 'echo-core', 'echo-model', 'echo-web', 'echo-notifications', 'echo-pipelinetriggers', 'echo-scheduler', 'echo-rest', 'echo-webhooks', 'echo-pubsub'
include 'echo-core', 'echo-model', 'echo-web', 'echo-notifications', 'echo-pipelinetriggers', 'echo-scheduler', 'echo-rest', 'echo-webhooks', 'echo-pubsub-core', 'echo-pubsub-aws', 'echo-pubsub-google'

rootProject.name = 'echo'

Expand Down

0 comments on commit 1d4edfd

Please sign in to comment.