Kategorisierung
enum class AntipatternType(val displayName: String) {
API_VERSIONING("API-Versioning"),
CYCLIC_DEPENDENCY("Cyclic Dependencies"),
USAGE_ESB("Usage Enterprise Service Bus"),
HARDCODED_ENDPOINTS("Hardcoded Endpoints"),
NO_API_GATEWAY("No API-Gateway"),
SHARED_PERSISTENCE("Shared Persistence"),
LOCAL_LOGGING("Local Logging"),
NO_MONITORING("Missing Monitoring"),
}
data class Antipattern(
val type: AntipatternType,
val message: String)
interface AntipatternOperationAnalyzerStrategy {
fun analyzeOperationNodes
(nodes: Iterable<IntermediateOperationNode>):
Collection<Antipattern>
}
interface AntipatternServiceAnalyzerStrategy {
fun analyzeOperationNodes
(microservices: Iterable<IntermediateMicroservice>):
Collection<Antipattern>
}
private var strategies = setOf(
CircleStrategy(),
WrongAspectStrategy("ESB", AntipatternType.USAGE_ESB, "Using an 'Enterprise Service Bus' can make a solution too complex"),
MissingAspectStrategy("ServiceDiscovery", AntipatternType.HARDCODED_ENDPOINTS, "A service discovery should be used"),
AspectUsageStrategy("Database", AntipatternType.SHARED_PERSISTENCE, "Only one Service should access a data storage. In case of data separation, like different tables this can be ignored"),
MissingAspectStrategy("LogServer", AntipatternType.LOCAL_LOGGING, "Log-Data should be stored central"),
MissingAspectStrategy("Monitoring", AntipatternType.NO_MONITORING, "Services should be monitored central"),
MissingAspectStrategy("API-Gateway", AntipatternType.NO_API_GATEWAY, "Although the service has endpoints no API-Gateway is connected", true)
)
override fun checkExistingAntipattern(): Collection{
val allInfrastuctureNodes = Cache.allInfrastuctureNodes()
val allContainer = Cache.allContainer()
val operationNodes = mutableListOf()
operationNodes.addAll(allContainer)
operationNodes.addAll(allInfrastuctureNodes)
val result = mutableListOf()
strategies.forEach { result.addAll(it.analyzeOperationNodes(operationNodes)) }
return result
}