Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add sns producer and consumer annotation (#38)
- Loading branch information
Showing
14 changed files
with
292 additions
and
6 deletions.
There are no files selected for viewing
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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/hlag/tools/commvis/analyzer/annotation/VisualizeSnsProducer.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.hlag.tools.commvis.analyzer.annotation; | ||
|
||
import java.lang.annotation.*; | ||
|
||
/** | ||
* Marks a producer for AWS SNS messages. | ||
*/ | ||
@Repeatable(VisualizeSnsProducers.class) | ||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface VisualizeSnsProducer { | ||
/** | ||
* @return name of the SNS topic messages are sent to | ||
*/ | ||
String topicName(); | ||
|
||
/** | ||
* @return the id of the project called, usually the Gitlab project id or similar | ||
*/ | ||
String projectId(); | ||
|
||
/** | ||
* @return the name of the project called. Just for a better visibility in the code. The value isn't used. | ||
*/ | ||
String projectName() default ""; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/hlag/tools/commvis/analyzer/annotation/VisualizeSnsProducers.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.hlag.tools.commvis.analyzer.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Used to group multiple {@link VisualizeSnsProducer} annotations on one element. | ||
*/ | ||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface VisualizeSnsProducers { | ||
/** | ||
* @return all grouped {@link VisualizeSnsProducer} annotations | ||
*/ | ||
VisualizeSnsProducer[] value(); | ||
} |
9 changes: 4 additions & 5 deletions
9
src/main/java/com/hlag/tools/commvis/analyzer/annotation/VisualizeSqsConsumer.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
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
21 changes: 21 additions & 0 deletions
21
src/main/java/com/hlag/tools/commvis/analyzer/annotation/VisualizeSqsViaSnsConsumer.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.hlag.tools.commvis.analyzer.annotation; | ||
|
||
import java.lang.annotation.*; | ||
|
||
/** | ||
* Annotated on methods to indicate that SQS messages are consumed from a SBS topic. | ||
*/ | ||
@Repeatable(VisualizeSqsViaSnsConsumers.class) | ||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface VisualizeSqsViaSnsConsumer { | ||
/** | ||
* @return name of the SNS topic messages are received from (via subscription) | ||
*/ | ||
String topicName(); | ||
|
||
/** | ||
* @return the name of the project the messages are received from. Just for a better visibility in the code. The value isn't used. | ||
*/ | ||
String projectName() default ""; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/hlag/tools/commvis/analyzer/annotation/VisualizeSqsViaSnsConsumers.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.hlag.tools.commvis.analyzer.annotation; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
/** | ||
* Used to group multiple {@link VisualizeSqsViaSnsConsumer} annotations on one element. | ||
*/ | ||
public @interface VisualizeSqsViaSnsConsumers { | ||
/** | ||
* @return all grouped {@link VisualizeSqsViaSnsConsumer} annotations | ||
*/ | ||
VisualizeSqsViaSnsConsumer[] value(); | ||
} |
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
48 changes: 48 additions & 0 deletions
48
src/main/java/com/hlag/tools/commvis/analyzer/model/SnsProducer.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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.hlag.tools.commvis.analyzer.model; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
import lombok.AccessLevel; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Value; | ||
|
||
/** | ||
* A producer for SNS messages. | ||
*/ | ||
@Value | ||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE) | ||
public class SnsProducer implements ISenderReceiverCommunication, IProducer { | ||
/** | ||
* the class name where the producer was found. | ||
*/ | ||
@SerializedName(value="class_name") | ||
String className; | ||
|
||
/** | ||
* the method name were the producer was found. | ||
*/ | ||
@SerializedName(value="method_name") | ||
String methodName; | ||
|
||
/** | ||
* the topic the messages are sent to. | ||
*/ | ||
@SerializedName(value="topic_name") | ||
String topicName; | ||
|
||
/** | ||
* The project id of the referenced project. | ||
*/ | ||
@SerializedName(value="destination_project_id") | ||
String destinationProjectId; | ||
|
||
/** | ||
* internal id of this node | ||
*/ | ||
@SerializedName(value="id") | ||
String id; | ||
|
||
@Override | ||
public void visit(AbstractCommunicationModelVisitor visitor) { | ||
visitor.visit(this); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/hlag/tools/commvis/analyzer/model/SqsViaSnsConsumer.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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.hlag.tools.commvis.analyzer.model; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
import lombok.AccessLevel; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Value; | ||
|
||
/** | ||
* A receiver for SQS messages via SNS topics. | ||
*/ | ||
@Value | ||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE) | ||
public class SqsViaSnsConsumer implements ISenderReceiverCommunication, IConsumer { | ||
@SerializedName(value="class_name") | ||
String className; | ||
|
||
@SerializedName(value="method_name") | ||
String methodName; | ||
|
||
@SerializedName(value="topic_name") | ||
String topicName; | ||
|
||
@SerializedName(value="id") | ||
String id; | ||
|
||
@Override | ||
public void visit(AbstractCommunicationModelVisitor visitor) { | ||
visitor.visit(this); | ||
} | ||
|
||
@Override | ||
public boolean isProducedBy(IProducer producer) { | ||
if (producer instanceof SnsProducer) { | ||
SnsProducer snsProducer = (SnsProducer) producer; | ||
|
||
return topicName.equals(snsProducer.getTopicName()); | ||
} | ||
|
||
return false; | ||
} | ||
} |
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.