diff --git a/build.gradle.kts b/build.gradle.kts index fb47b1ac..c1a7a8b9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,6 +11,7 @@ val vertxVersion: String by project val kotlinVersion: String by project val projectVersion: String by project val jacksonVersion: String by project +val slf4jVersion: String by project group = "spp.protocol" version = projectVersion @@ -49,10 +50,11 @@ kotlin { } val jvmMain by getting { dependencies { + implementation("org.slf4j:slf4j-api:$slf4jVersion") implementation("io.vertx:vertx-core:$vertxVersion") implementation("io.vertx:vertx-codegen:$vertxVersion") implementation("io.vertx:vertx-tcp-eventbus-bridge:$vertxVersion") - implementation("io.vertx:vertx-service-proxy:4.1.5") + implementation("io.vertx:vertx-service-proxy:$vertxVersion") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion") implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$jacksonVersion") implementation("com.fasterxml.jackson.datatype:jackson-datatype-guava:$jacksonVersion") @@ -79,15 +81,32 @@ kotlin { } dependencies { - "kapt"("io.vertx:vertx-codegen:4.1.5:processor") + "kapt"("io.vertx:vertx-codegen:$vertxVersion:processor") } tasks.register("setupJsonMappers") { from(file("$projectDir/src/jvmMain/resources/META-INF/vertx/json-mappers.properties")) - into(file("$buildDir/tmp/kapt3/src/main/resources/META-INF/vertx")) + into(file("$buildDir/generated/source/kapt/main/META-INF/vertx")) } tasks.getByName("compileKotlinJvm").dependsOn("setupJsonMappers") +tasks.register("restrictDeletionOfJsonMappers") { + mustRunAfter("setupJsonMappers") + commandLine("chmod", "a-w", "$buildDir/generated/source/kapt/main/META-INF/vertx") +} +tasks.getByName("compileKotlinJvm").dependsOn("restrictDeletionOfJsonMappers") + +tasks.register("unrestrictDeletionOfJsonMappers") { + mustRunAfter("compileKotlinJvm") + if (file("$buildDir/generated/source/kapt/main/META-INF/vertx").exists()) { + commandLine("chmod", "a+w", "$buildDir/generated/source/kapt/main/META-INF/vertx") + } else { + commandLine("true") //no-op + } +} +tasks.getByName("jvmJar").dependsOn("unrestrictDeletionOfJsonMappers") +tasks.getByName("clean").dependsOn("unrestrictDeletionOfJsonMappers") + configure { annotation("kotlinx.serialization.Serializable") } diff --git a/gradle.properties b/gradle.properties index ec2cedfb..aa2190bf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,8 @@ kotlin.code.style=official -projectVersion=0.3.1 +projectVersion=0.4.0 kotlinVersion=1.6.10 vertxVersion=4.2.4 -jacksonVersion=2.13.0 +jacksonVersion=2.13.1 +slf4jVersion=1.7.33 diff --git a/src/commonMain/kotlin/spp.protocol/ProtocolAddress.kt b/src/commonMain/kotlin/spp.protocol/ProtocolAddress.kt deleted file mode 100644 index 2e43148a..00000000 --- a/src/commonMain/kotlin/spp.protocol/ProtocolAddress.kt +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol - -/** - * Contains all the public addresses which consume and send protocol messages. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -object ProtocolAddress { - object Global { //todo: could probably rename to Plugin to indicate it's the module consuming message - //Portal - const val FindPortal = "FindAndOpenPortal" - const val FindAndOpenPortal = "FindAndOpenPortal" - const val OpenPortal = "OpenPortal" - const val ClosePortal = "ClosePortal" - const val ClickedViewAsExternalPortal = "ClickedViewAsExternalPortal" - const val KeepAlivePortal = "KeepAlivePortal" //todo: remove - const val UpdatePortalArtifact = "UpdatePortalArtifact" - const val GetPortalConfiguration = "GetPortalConfiguration" - const val SetCurrentPage = "SetCurrentPage" - const val RefreshPortal = "RefreshPortal" - const val CanOpenPortal = "CanOpenPortal" - const val ChangedPortalArtifact = "ChangedPortalArtifact" - const val CanNavigateToArtifact = "CanNavigateToArtifact" - const val NavigateToArtifact = "NavigateToArtifact" - const val GetPortalTranslations = "GetPortalTranslations" - - //Portal - Overview - const val RefreshOverview = "RefreshOverview" - const val SetOverviewTimeFrame = "SetOverviewTimeFrame" - const val ClickedEndpointArtifact = "ClickedEndpointArtifact" - - //Portal - Activity - const val ActivityTabOpened = "ActivityTabOpened" - const val SetMetricTimeFrame = "SetMetricTimeFrame" - const val SetActiveChartMetric = "SetActiveChartMetric" - const val RefreshActivity = "RefreshActivity" - const val ArtifactMetricsUpdated = "ArtifactMetricUpdated" - - //Portal - Traces - const val SetTraceOrderType = "SetTraceOrderType" - const val ClickedDisplayTraces = "ClickedDisplayTraces" - const val ClickedDisplayTraceStack = "ClickedDisplayTraceStack" - const val ClickedDisplayInnerTraceStack = "ClickedDisplayInnerTraceStack" - const val ClickedDisplaySpanInfo = "ClickedDisplaySpanInfo" - const val GetTraceStack = "GetTraceStack" - const val RefreshTraces = "RefreshTraces" - const val ArtifactTracesUpdated = "ArtifactTracesUpdated" - const val TraceSpanUpdated = "TraceSpanUpdated" - const val QueryTraceStack = "QueryTraceStack" - const val ClickedStackTraceElement = "ClickedStackTraceElement" - const val FetchMoreTraces = "FetchMoreTraces" - - //Portal - Logs - const val SetLogOrderType = "SetLogOrderType" - const val RefreshLogs = "RefreshLogs" - const val ArtifactLogUpdated = "ArtifactLogUpdated" - const val ClickedDisplayLog = "ClickedDisplayLog" - const val ClickedDisplayLogs = "ClickedDisplayLogs" - const val FetchMoreLogs = "FetchMoreLogs" - - //Portal - Configuration - const val DisplayArtifactConfiguration = "DisplayArtifactConfiguration" - const val UpdateArtifactEntryMethod = "UpdateArtifactEntryMethod" - const val UpdateArtifactAutoSubscribe = "UpdateArtifactAutoSubscribe" - } - - @Suppress("FunctionName") - object Portal { - fun RenderPage(portalUuid: String): String { - return "$portalUuid-RenderPage" - } - - fun UpdateEndpoints(portalUuid: String): String { - return "$portalUuid-UpdateEndpoints" - } - - fun ClearActivity(portalUuid: String): String { - return "$portalUuid-ClearActivity" - } - - fun DisplayActivity(portalUuid: String): String { - return "$portalUuid-DisplayActivity" - } - - fun DisplayTraces(portalUuid: String): String { - return "$portalUuid-DisplayTraces" - } - - fun DisplayLogs(portalUuid: String): String { - return "$portalUuid-DisplayLogs" - } - - fun DisplayLog(portalUuid: String): String { - return "$portalUuid-DisplayLog" - } - - fun DisplayTraceStack(portalUuid: String): String { - return "$portalUuid-DisplayTraceStack" - } - - fun DisplaySpanInfo(portalUuid: String): String { - return "$portalUuid-DisplaySpanInfo" - } - - fun UpdateTraceSpan(portalUuid: String): String { - return "$portalUuid-UpdateTraceSpan" - } - - fun DisplayArtifactConfiguration(portalUuid: String): String { - return "$portalUuid-DisplayArtifactConfiguration" - } - } -} diff --git a/src/commonMain/kotlin/spp.protocol/Serializers.kt b/src/commonMain/kotlin/spp.protocol/Serializers.kt index bb091441..391ec114 100644 --- a/src/commonMain/kotlin/spp.protocol/Serializers.kt +++ b/src/commonMain/kotlin/spp.protocol/Serializers.kt @@ -17,14 +17,13 @@ */ package spp.protocol -import spp.protocol.artifact.ArtifactType -import spp.protocol.portal.PageType import kotlinx.datetime.Instant import kotlinx.serialization.KSerializer import kotlinx.serialization.descriptors.PrimitiveKind import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder +import spp.protocol.artifact.ArtifactType /** * Used to serialize/deserialize protocol messages. @@ -65,20 +64,4 @@ class Serializers { override fun deserialize(decoder: Decoder) = ArtifactType.valueOf(decoder.decodeString()) override fun serialize(encoder: Encoder, value: ArtifactType) = encoder.encodeString(value.name) } - - /** - * Used to serialize/deserialize [PageType] classes. - * - * @since 0.2.0 - */ - class PageTypeSerializer : KSerializer { - - override val descriptor = PrimitiveSerialDescriptor( - "spp.protocol.PageTypeSerializer", - PrimitiveKind.STRING - ) - - override fun deserialize(decoder: Decoder) = PageType.valueOf(decoder.decodeString()) - override fun serialize(encoder: Encoder, value: PageType) = encoder.encodeString(value.name) - } } diff --git a/src/commonMain/kotlin/spp.protocol/advice/AdviceType.kt b/src/commonMain/kotlin/spp.protocol/advice/AdviceType.kt deleted file mode 100644 index 505767e7..00000000 --- a/src/commonMain/kotlin/spp.protocol/advice/AdviceType.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.advice - -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -enum class AdviceType { - RampDetectionAdvice, - ActiveExceptionAdvice -} diff --git a/src/commonMain/kotlin/spp.protocol/advice/ArtifactAdvice.kt b/src/commonMain/kotlin/spp.protocol/advice/ArtifactAdvice.kt deleted file mode 100644 index 8d9e34e4..00000000 --- a/src/commonMain/kotlin/spp.protocol/advice/ArtifactAdvice.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.advice - -import spp.protocol.artifact.ArtifactQualifiedName - -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -abstract class ArtifactAdvice( - val artifact: ArtifactQualifiedName, - val category: AdviceCategory, - val type: AdviceType -) { - - private val artifactAdviceListeners = mutableListOf() - - fun addArtifactAdviceListener(artifactAdviceListener: ArtifactAdviceListener) { - artifactAdviceListeners.add(artifactAdviceListener) - } - - protected fun triggerUpdated() { - artifactAdviceListeners.forEach(ArtifactAdviceListener::updated) - } - - /** - * Determine if [artifactAdvice] is the same as this one. If so, the first [ArtifactAdvice] should be updated. - */ - abstract fun isSameArtifactAdvice(artifactAdvice: ArtifactAdvice): Boolean - - abstract fun updateArtifactAdvice(artifactAdvice: ArtifactAdvice) -} diff --git a/src/commonMain/kotlin/spp.protocol/advice/ArtifactAdviceListener.kt b/src/commonMain/kotlin/spp.protocol/advice/ArtifactAdviceListener.kt deleted file mode 100644 index 6118e4ef..00000000 --- a/src/commonMain/kotlin/spp.protocol/advice/ArtifactAdviceListener.kt +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.advice - -/** - * Used to listen for when an [ArtifactAdvice] is updated. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -fun interface ArtifactAdviceListener { - fun updated() -} diff --git a/src/commonMain/kotlin/spp.protocol/advice/cautionary/RampDetectionAdvice.kt b/src/commonMain/kotlin/spp.protocol/advice/cautionary/RampDetectionAdvice.kt deleted file mode 100644 index 274118e9..00000000 --- a/src/commonMain/kotlin/spp.protocol/advice/cautionary/RampDetectionAdvice.kt +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.advice.cautionary - -import spp.protocol.advice.AdviceCategory -import spp.protocol.advice.AdviceType -import spp.protocol.advice.ArtifactAdvice -import spp.protocol.artifact.ArtifactQualifiedName - -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -class RampDetectionAdvice( - artifact: ArtifactQualifiedName, - regressionSource: ArtifactQualifiedName, - regression: SimpleRegression -) : ArtifactAdvice(artifact, AdviceCategory.CAUTIONARY, AdviceType.RampDetectionAdvice) { - - var regression: SimpleRegression = regression - private set - - fun updateRegression(regression: SimpleRegression) { - this.regression = regression - triggerUpdated() - } - - override fun isSameArtifactAdvice(artifactAdvice: ArtifactAdvice): Boolean { - return artifactAdvice is RampDetectionAdvice && artifactAdvice.artifact == artifact - } - - override fun updateArtifactAdvice(artifactAdvice: ArtifactAdvice) { - updateRegression((artifactAdvice as RampDetectionAdvice).regression) - } - - interface SimpleRegression { - val n: Long - val intercept: Double - val slope: Double - val sumSquaredErrors: Double - val totalSumSquares: Double - val xSumSquares: Double - val sumOfCrossProducts: Double - val regressionSumSquares: Double - val meanSquareError: Double - val r: Double - val rSquare: Double - val interceptStdErr: Double - val slopeStdErr: Double - val slopeConfidenceInterval: Double - val significance: Double - - fun predict(x: Double): Double - } - - override fun toString(): String { - return "$type{$artifact - Confidence: ${regression.rSquare}" - } -} diff --git a/src/commonMain/kotlin/spp.protocol/advice/informative/ActiveExceptionAdvice.kt b/src/commonMain/kotlin/spp.protocol/advice/informative/ActiveExceptionAdvice.kt deleted file mode 100644 index 56292d35..00000000 --- a/src/commonMain/kotlin/spp.protocol/advice/informative/ActiveExceptionAdvice.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.advice.informative - -import spp.protocol.advice.AdviceCategory -import spp.protocol.advice.AdviceType -import spp.protocol.advice.ArtifactAdvice -import spp.protocol.artifact.ArtifactQualifiedName -import spp.protocol.artifact.exception.LiveStackTrace -import kotlinx.datetime.Instant - -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -class ActiveExceptionAdvice( - artifact: ArtifactQualifiedName, - stackTrace: LiveStackTrace, - occurredAt: Instant -) : ArtifactAdvice(artifact, AdviceCategory.INFORMATIVE, AdviceType.ActiveExceptionAdvice) { - - var stackTrace: LiveStackTrace = stackTrace - private set - var occurredAt: Instant = occurredAt - private set - - fun update(stackTrace: LiveStackTrace, occurredAt: Instant) { - this.stackTrace = stackTrace - this.occurredAt = occurredAt - triggerUpdated() - } - - /** - * Compares everything except [LiveStackTrace.message] as the message may just contain timestamp differences - * even though everything else is equivalent. - */ - override fun isSameArtifactAdvice(artifactAdvice: ArtifactAdvice): Boolean { - return artifactAdvice is ActiveExceptionAdvice && artifactAdvice.artifact == artifact && - artifactAdvice.stackTrace.exceptionType == stackTrace.exceptionType && - artifactAdvice.stackTrace.elements == stackTrace.elements && - artifactAdvice.stackTrace.causedBy == stackTrace.causedBy - } - - override fun updateArtifactAdvice(artifactAdvice: ArtifactAdvice) { - update((artifactAdvice as ActiveExceptionAdvice).stackTrace, artifactAdvice.occurredAt) - } - - override fun toString(): String { - return "$type{$artifact - ${stackTrace.exceptionType} @ $occurredAt}" - } -} diff --git a/src/commonMain/kotlin/spp.protocol/artifact/ArtifactConfiguration.kt b/src/commonMain/kotlin/spp.protocol/artifact/ArtifactConfiguration.kt deleted file mode 100644 index a9f55931..00000000 --- a/src/commonMain/kotlin/spp.protocol/artifact/ArtifactConfiguration.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.artifact - -import kotlinx.serialization.Serializable - -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -@Serializable -data class ArtifactConfiguration( - val endpoint: Boolean, - val subscribeAutomatically: Boolean, - val endpointName: String, - val endpointIds: List = emptyList() -) diff --git a/src/commonMain/kotlin/spp.protocol/artifact/ArtifactInformation.kt b/src/commonMain/kotlin/spp.protocol/artifact/ArtifactInformation.kt deleted file mode 100644 index a1674e2c..00000000 --- a/src/commonMain/kotlin/spp.protocol/artifact/ArtifactInformation.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.artifact - -import spp.protocol.Serializers -import kotlinx.datetime.Instant -import kotlinx.serialization.Serializable - -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -@Serializable -data class ArtifactInformation( - val artifactQualifiedName: String, - @Serializable(with = Serializers.InstantKSerializer::class) - val createDate: Instant, - @Serializable(with = Serializers.InstantKSerializer::class) - val lastUpdated: Instant, - val config: ArtifactConfiguration -) diff --git a/src/commonMain/kotlin/spp.protocol/utils/ArtifactNameUtils.kt b/src/commonMain/kotlin/spp.protocol/artifact/ArtifactNameUtils.kt similarity index 99% rename from src/commonMain/kotlin/spp.protocol/utils/ArtifactNameUtils.kt rename to src/commonMain/kotlin/spp.protocol/artifact/ArtifactNameUtils.kt index 5337c4ce..0d91e593 100644 --- a/src/commonMain/kotlin/spp.protocol/utils/ArtifactNameUtils.kt +++ b/src/commonMain/kotlin/spp.protocol/artifact/ArtifactNameUtils.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.utils +package spp.protocol.artifact /** * Useful methods for formatting artifact names. diff --git a/src/commonMain/kotlin/spp.protocol/artifact/endpoint/EndpointResult.kt b/src/commonMain/kotlin/spp.protocol/artifact/endpoint/EndpointResult.kt deleted file mode 100644 index fa34f330..00000000 --- a/src/commonMain/kotlin/spp.protocol/artifact/endpoint/EndpointResult.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.artifact.endpoint - -import spp.protocol.Serializers -import spp.protocol.artifact.metrics.ArtifactSummarizedResult -import spp.protocol.artifact.QueryTimeFrame -import kotlinx.datetime.Instant -import kotlinx.serialization.Serializable - -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -@Serializable -data class EndpointResult( - val timeFrame: QueryTimeFrame, - @Serializable(with = Serializers.InstantKSerializer::class) - val start: Instant, - @Serializable(with = Serializers.InstantKSerializer::class) - val stop: Instant, - val step: String, - val endpointMetrics: List -) diff --git a/src/commonMain/kotlin/spp.protocol/artifact/exception/LiveStackTraceElement.kt b/src/commonMain/kotlin/spp.protocol/artifact/exception/LiveStackTraceElement.kt index 33960b01..94ff7e8a 100644 --- a/src/commonMain/kotlin/spp.protocol/artifact/exception/LiveStackTraceElement.kt +++ b/src/commonMain/kotlin/spp.protocol/artifact/exception/LiveStackTraceElement.kt @@ -17,9 +17,9 @@ */ package spp.protocol.artifact.exception -import spp.protocol.instrument.LiveVariable -import spp.protocol.utils.ArtifactNameUtils.getShortQualifiedClassName import kotlinx.serialization.Serializable +import spp.protocol.artifact.ArtifactNameUtils.getShortQualifiedClassName +import spp.protocol.instrument.variable.LiveVariable /** * todo: description. diff --git a/src/commonMain/kotlin/spp.protocol/artifact/log/Log.kt b/src/commonMain/kotlin/spp.protocol/artifact/log/Log.kt index 11409466..9002f0bd 100644 --- a/src/commonMain/kotlin/spp.protocol/artifact/log/Log.kt +++ b/src/commonMain/kotlin/spp.protocol/artifact/log/Log.kt @@ -39,11 +39,6 @@ data class Log( val exception: LiveStackTrace? = null, val arguments: List = listOf() ) { - @Deprecated("Use toFormattedString() instead.", ReplaceWith("toFormattedString()")) - fun getFormattedMessage(): String { - return toFormattedMessage() - } - fun toFormattedMessage(): String { var arg = 0 var formattedMessage = content diff --git a/src/commonMain/kotlin/spp.protocol/artifact/log/LogCountSummary.kt b/src/commonMain/kotlin/spp.protocol/artifact/log/LogCountSummary.kt index 362ffeee..cf8c7ed4 100644 --- a/src/commonMain/kotlin/spp.protocol/artifact/log/LogCountSummary.kt +++ b/src/commonMain/kotlin/spp.protocol/artifact/log/LogCountSummary.kt @@ -17,9 +17,9 @@ */ package spp.protocol.artifact.log -import spp.protocol.Serializers import kotlinx.datetime.Instant import kotlinx.serialization.Serializable +import spp.protocol.Serializers /** * todo: description. diff --git a/src/commonMain/kotlin/spp.protocol/artifact/log/LogResult.kt b/src/commonMain/kotlin/spp.protocol/artifact/log/LogResult.kt index cf0c79eb..421d98e6 100644 --- a/src/commonMain/kotlin/spp.protocol/artifact/log/LogResult.kt +++ b/src/commonMain/kotlin/spp.protocol/artifact/log/LogResult.kt @@ -17,9 +17,9 @@ */ package spp.protocol.artifact.log -import spp.protocol.Serializers import kotlinx.datetime.Instant import kotlinx.serialization.Serializable +import spp.protocol.Serializers import spp.protocol.artifact.ArtifactQualifiedName /** diff --git a/src/commonMain/kotlin/spp.protocol/artifact/metrics/ArtifactMetricResult.kt b/src/commonMain/kotlin/spp.protocol/artifact/metrics/ArtifactMetricResult.kt index 0aea86fa..1abb4acb 100644 --- a/src/commonMain/kotlin/spp.protocol/artifact/metrics/ArtifactMetricResult.kt +++ b/src/commonMain/kotlin/spp.protocol/artifact/metrics/ArtifactMetricResult.kt @@ -17,11 +17,11 @@ */ package spp.protocol.artifact.metrics -import spp.protocol.Serializers -import spp.protocol.artifact.QueryTimeFrame import kotlinx.datetime.Instant import kotlinx.serialization.Serializable +import spp.protocol.Serializers import spp.protocol.artifact.ArtifactQualifiedName +import spp.protocol.artifact.QueryTimeFrame /** * todo: description. diff --git a/src/commonMain/kotlin/spp.protocol/artifact/metrics/ArtifactSummarizedResult.kt b/src/commonMain/kotlin/spp.protocol/artifact/metrics/ArtifactSummarizedResult.kt deleted file mode 100644 index 3cb3d729..00000000 --- a/src/commonMain/kotlin/spp.protocol/artifact/metrics/ArtifactSummarizedResult.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.artifact.metrics - -import spp.protocol.artifact.ArtifactQualifiedName -import spp.protocol.artifact.endpoint.EndpointType -import kotlinx.serialization.Serializable - -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -@Serializable -data class ArtifactSummarizedResult( - val artifactQualifiedName: ArtifactQualifiedName, - val artifactSummarizedMetrics: List, - val endpointType: EndpointType -) diff --git a/src/commonMain/kotlin/spp.protocol/artifact/trace/Trace.kt b/src/commonMain/kotlin/spp.protocol/artifact/trace/Trace.kt index d470d3f2..8fa04262 100644 --- a/src/commonMain/kotlin/spp.protocol/artifact/trace/Trace.kt +++ b/src/commonMain/kotlin/spp.protocol/artifact/trace/Trace.kt @@ -17,9 +17,9 @@ */ package spp.protocol.artifact.trace -import spp.protocol.Serializers import kotlinx.datetime.Instant import kotlinx.serialization.Serializable +import spp.protocol.Serializers /** * todo: description. diff --git a/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceResult.kt b/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceResult.kt index 80ee4fa6..311232fd 100644 --- a/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceResult.kt +++ b/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceResult.kt @@ -17,9 +17,9 @@ */ package spp.protocol.artifact.trace -import spp.protocol.Serializers import kotlinx.datetime.Instant import kotlinx.serialization.Serializable +import spp.protocol.Serializers import spp.protocol.artifact.ArtifactQualifiedName /** diff --git a/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceSpan.kt b/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceSpan.kt index 1e5c125e..778914c1 100644 --- a/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceSpan.kt +++ b/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceSpan.kt @@ -17,9 +17,9 @@ */ package spp.protocol.artifact.trace -import spp.protocol.Serializers import kotlinx.datetime.Instant import kotlinx.serialization.Serializable +import spp.protocol.Serializers import spp.protocol.artifact.ArtifactQualifiedName /** diff --git a/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceSpanLogEntry.kt b/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceSpanLogEntry.kt index 908370b0..9520043a 100644 --- a/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceSpanLogEntry.kt +++ b/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceSpanLogEntry.kt @@ -17,9 +17,9 @@ */ package spp.protocol.artifact.trace -import spp.protocol.Serializers import kotlinx.datetime.Instant import kotlinx.serialization.Serializable +import spp.protocol.Serializers /** * todo: description. diff --git a/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceSpanQuery.kt b/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceSpanQuery.kt deleted file mode 100644 index db4a7c19..00000000 --- a/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceSpanQuery.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.artifact.trace - -import kotlinx.datetime.Instant - -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -data class TraceSpanQuery( - val traceId: String? = null, - val segmentId: String? = null, - val spanId: Int? = null, - val parentSpanId: Int? = null, -// val refs: List = emptyList(), - val serviceCode: String? = null, - val serviceInstanceName: String? = null, - val startTime: Instant? = null, - val endTime: Instant? = null, - val endpointName: String? = null, - val artifactQualifiedName: String? = null, - val type: String? = null, - val peer: String? = null, - val component: String? = null, - val error: Boolean? = null, - val childError: Boolean? = null, - val hasChildStack: Boolean? = null, - val layer: String? = null, - val tags: Set = emptySet(), -// val logs: List = emptyList() -) diff --git a/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceStack.kt b/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceStack.kt index 74ee2504..d16be793 100644 --- a/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceStack.kt +++ b/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceStack.kt @@ -17,8 +17,8 @@ */ package spp.protocol.artifact.trace -import spp.protocol.artifact.trace.TraceStack.Segment import kotlinx.serialization.Serializable +import spp.protocol.artifact.trace.TraceStack.Segment /** * Represents a list of [TraceSpan]s as the equivalent tree structure. diff --git a/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceStackPath.kt b/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceStackPath.kt deleted file mode 100644 index 810bdf4d..00000000 --- a/src/commonMain/kotlin/spp.protocol/artifact/trace/TraceStackPath.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.artifact.trace - -import kotlinx.serialization.Serializable - -/** - * Used to keep track of the path taken in a [TraceStack]. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -@Serializable -data class TraceStackPath( - val traceStack: TraceStack, - val path: List = mutableListOf(), - val orderType: TraceOrderType, - val localTracing: Boolean = false -) { - - fun getCurrentSegment(): TraceStack.Segment? { - val segmentId = path.lastOrNull()?.segmentId - return if (segmentId != null) { - traceStack.getSegment(segmentId) - } else null - } - - fun getCurrentRoot(): TraceSpan? { - return path.lastOrNull() - } - - fun follow(segmentId: String, spanId: Int) { - (path as MutableList).add(traceStack.getSegment(segmentId).getTraceSpan(spanId)) - } - - fun removeLastRoot() { - (path as MutableList).removeLast() - } - - fun autoFollow(artifactQualifiedName: String) { - val shortestPath = mutableListOf() - val startSpan = traceStack.traceSpans.find { it.endpointName == artifactQualifiedName } - if (startSpan != null) { - var currentSpan: TraceSpan = startSpan - while (currentSpan.spanId != 0 || currentSpan.parentSpanId != -1) { - val prevSpan = traceStack.getSegment(currentSpan.segmentId).getTraceSpan(currentSpan.spanId - 1) - shortestPath.add(prevSpan) - currentSpan = prevSpan - } - shortestPath.add(startSpan) - - shortestPath.forEach { - follow(it.segmentId, it.spanId) - } - } - } -} diff --git a/src/commonMain/kotlin/spp.protocol/error/AccessDenied.kt b/src/commonMain/kotlin/spp.protocol/error/AccessDenied.kt deleted file mode 100644 index 90121e7e..00000000 --- a/src/commonMain/kotlin/spp.protocol/error/AccessDenied.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.error - -/** - * todo: description. - * - * @since 0.3.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -class AccessDenied : RuntimeException { - - val reason: String - - constructor(reason: String) : this(reason, "Access denied: $reason") - - private constructor(reason: String, message: String) : super(message) { - this.reason = reason - } - - fun toEventBusException(): AccessDenied { - return AccessDenied( - reason, "EventBusException:AccessDenied[$reason]" - ) - } -} diff --git a/src/commonMain/kotlin/spp.protocol/error/JWTVerificationException.kt b/src/commonMain/kotlin/spp.protocol/error/JWTVerificationException.kt deleted file mode 100644 index 899f99c7..00000000 --- a/src/commonMain/kotlin/spp.protocol/error/JWTVerificationException.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.error - -/** - * todo: description. - * - * @since 0.3.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -class JWTVerificationException : RuntimeException { - - private val reason: String - - constructor(reason: String) : this(reason, "JWT verification exception: $reason") - - private constructor(reason: String, message: String) : super(message) { - this.reason = reason - } - - fun toEventBusException(): JWTVerificationException { - return JWTVerificationException( - reason, "EventBusException:JWTVerificationException[$reason]" - ) - } -} diff --git a/src/commonMain/kotlin/spp.protocol/error/MissingRemoteException.kt b/src/commonMain/kotlin/spp.protocol/error/MissingRemoteException.kt deleted file mode 100644 index de4cffe7..00000000 --- a/src/commonMain/kotlin/spp.protocol/error/MissingRemoteException.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.error - -/** - * todo: description. - * - * @since 0.3.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -class MissingRemoteException : RuntimeException { - - private val remote: String - - constructor(remote: String) : this(remote, "Missing remote: $remote") - - private constructor(remote: String, message: String) : super(message) { - this.remote = remote - } - - fun toEventBusException(): MissingRemoteException { - return MissingRemoteException( - remote, "EventBusException:MissingRemoteException[$remote]" - ) - } -} diff --git a/src/commonMain/kotlin/spp.protocol/instrument/breakpoint/LiveBreakpoint.kt b/src/commonMain/kotlin/spp.protocol/instrument/LiveBreakpoint.kt similarity index 88% rename from src/commonMain/kotlin/spp.protocol/instrument/breakpoint/LiveBreakpoint.kt rename to src/commonMain/kotlin/spp.protocol/instrument/LiveBreakpoint.kt index 61e8c13d..bffc4914 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/breakpoint/LiveBreakpoint.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/LiveBreakpoint.kt @@ -15,14 +15,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.instrument.breakpoint +package spp.protocol.instrument import kotlinx.serialization.Contextual import kotlinx.serialization.Serializable -import spp.protocol.instrument.InstrumentThrottle -import spp.protocol.instrument.LiveInstrument -import spp.protocol.instrument.LiveInstrumentType -import spp.protocol.instrument.LiveSourceLocation +import spp.protocol.instrument.throttle.InstrumentThrottle /** * A live breakpoint represents a non-breaking breakpoint. diff --git a/src/commonMain/kotlin/spp.protocol/instrument/LiveInstrument.kt b/src/commonMain/kotlin/spp.protocol/instrument/LiveInstrument.kt index 79cfa99c..efc5899b 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/LiveInstrument.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/LiveInstrument.kt @@ -19,6 +19,7 @@ package spp.protocol.instrument import kotlinx.serialization.Contextual import kotlinx.serialization.Serializable +import spp.protocol.instrument.throttle.InstrumentThrottle /** * todo: description. @@ -27,7 +28,7 @@ import kotlinx.serialization.Serializable * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ @Serializable -abstract class LiveInstrument { +sealed class LiveInstrument { abstract val location: LiveSourceLocation abstract val condition: String? abstract val expiresAt: Long? //todo: can just use -1 like hitLimit? diff --git a/src/commonMain/kotlin/spp.protocol/instrument/LiveInstrumentBatch.kt b/src/commonMain/kotlin/spp.protocol/instrument/LiveInstrumentBatch.kt deleted file mode 100644 index 247c5f15..00000000 --- a/src/commonMain/kotlin/spp.protocol/instrument/LiveInstrumentBatch.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.instrument - -import kotlinx.serialization.Serializable - -/** - * todo: description. - * - * @since 0.3.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -@Serializable -data class LiveInstrumentBatch( - val instruments: List -) diff --git a/src/commonMain/kotlin/spp.protocol/instrument/log/LiveLog.kt b/src/commonMain/kotlin/spp.protocol/instrument/LiveLog.kt similarity index 88% rename from src/commonMain/kotlin/spp.protocol/instrument/log/LiveLog.kt rename to src/commonMain/kotlin/spp.protocol/instrument/LiveLog.kt index 08d0394e..db4025db 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/log/LiveLog.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/LiveLog.kt @@ -15,14 +15,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.instrument.log +package spp.protocol.instrument -import spp.protocol.instrument.InstrumentThrottle -import spp.protocol.instrument.LiveInstrument -import spp.protocol.instrument.LiveInstrumentType -import spp.protocol.instrument.LiveSourceLocation import kotlinx.serialization.Contextual import kotlinx.serialization.Serializable +import spp.protocol.instrument.throttle.InstrumentThrottle /** * A live log represents a textual message. diff --git a/src/commonMain/kotlin/spp.protocol/instrument/meter/LiveMeter.kt b/src/commonMain/kotlin/spp.protocol/instrument/LiveMeter.kt similarity index 89% rename from src/commonMain/kotlin/spp.protocol/instrument/meter/LiveMeter.kt rename to src/commonMain/kotlin/spp.protocol/instrument/LiveMeter.kt index e16c9dfd..65d698d8 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/meter/LiveMeter.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/LiveMeter.kt @@ -15,14 +15,13 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.instrument.meter +package spp.protocol.instrument import kotlinx.serialization.Contextual import kotlinx.serialization.Serializable -import spp.protocol.instrument.InstrumentThrottle -import spp.protocol.instrument.LiveInstrument -import spp.protocol.instrument.LiveInstrumentType -import spp.protocol.instrument.LiveSourceLocation +import spp.protocol.instrument.meter.MeterType +import spp.protocol.instrument.meter.MetricValue +import spp.protocol.instrument.throttle.InstrumentThrottle /** * A live meter represents a metric that is measured continuously over time. diff --git a/src/commonMain/kotlin/spp.protocol/instrument/LiveSourceLocation.kt b/src/commonMain/kotlin/spp.protocol/instrument/LiveSourceLocation.kt index 7b75827d..ec219037 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/LiveSourceLocation.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/LiveSourceLocation.kt @@ -30,7 +30,7 @@ import kotlin.jvm.JvmOverloads data class LiveSourceLocation @JvmOverloads constructor( val source: String, val line: Int = -1, - val service: String? = null, + val service: String? = null, //todo: can use Service val serviceInstance: String? = null, //todo: fully impl val commitId: String? = null, //todo: impl val fileChecksum: String? = null //todo: impl diff --git a/src/commonMain/kotlin/spp.protocol/instrument/span/LiveSpan.kt b/src/commonMain/kotlin/spp.protocol/instrument/LiveSpan.kt similarity index 88% rename from src/commonMain/kotlin/spp.protocol/instrument/span/LiveSpan.kt rename to src/commonMain/kotlin/spp.protocol/instrument/LiveSpan.kt index 222c4e08..30f0317d 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/span/LiveSpan.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/LiveSpan.kt @@ -15,14 +15,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.instrument.span +package spp.protocol.instrument import kotlinx.serialization.Contextual import kotlinx.serialization.Serializable -import spp.protocol.instrument.InstrumentThrottle -import spp.protocol.instrument.LiveInstrument -import spp.protocol.instrument.LiveInstrumentType -import spp.protocol.instrument.LiveSourceLocation +import spp.protocol.instrument.throttle.InstrumentThrottle /** * A live span represents a single unit of work in a program. diff --git a/src/commonMain/kotlin/spp.protocol/instrument/breakpoint/event/LiveBreakpointRemoved.kt b/src/commonMain/kotlin/spp.protocol/instrument/breakpoint/event/LiveBreakpointRemoved.kt deleted file mode 100644 index 9f9cb287..00000000 --- a/src/commonMain/kotlin/spp.protocol/instrument/breakpoint/event/LiveBreakpointRemoved.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.instrument.breakpoint.event - -import spp.protocol.Serializers -import spp.protocol.artifact.exception.LiveStackTrace -import spp.protocol.instrument.LiveInstrumentEventType -import spp.protocol.instrument.TrackedLiveEvent -import kotlinx.datetime.Instant -import kotlinx.serialization.Serializable - -/** - * todo: description. - * - * @since 0.3.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -@Serializable -data class LiveBreakpointRemoved( - val breakpointId: String, - @Serializable(with = Serializers.InstantKSerializer::class) - override val occurredAt: Instant, - val cause: LiveStackTrace? = null -) : TrackedLiveEvent { - val eventType: LiveInstrumentEventType = LiveInstrumentEventType.BREAKPOINT_REMOVED -} diff --git a/src/commonMain/kotlin/spp.protocol/instrument/breakpoint/event/TrackedLiveEvent.kt b/src/commonMain/kotlin/spp.protocol/instrument/breakpoint/event/TrackedLiveEvent.kt deleted file mode 100644 index b2aed8ec..00000000 --- a/src/commonMain/kotlin/spp.protocol/instrument/breakpoint/event/TrackedLiveEvent.kt +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.instrument.breakpoint.event - -import kotlinx.datetime.Instant - -/** - * todo: description. - * - * @since 0.3.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -interface TrackedLiveEvent { - val occurredAt: Instant -} diff --git a/src/commonMain/kotlin/spp.protocol/artifact/endpoint/EndpointType.kt b/src/commonMain/kotlin/spp.protocol/instrument/command/CommandType.kt similarity index 80% rename from src/commonMain/kotlin/spp.protocol/artifact/endpoint/EndpointType.kt rename to src/commonMain/kotlin/spp.protocol/instrument/command/CommandType.kt index 1a55e6be..a7fec38d 100644 --- a/src/commonMain/kotlin/spp.protocol/artifact/endpoint/EndpointType.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/command/CommandType.kt @@ -15,14 +15,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.artifact.endpoint +package spp.protocol.instrument.command -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -enum class EndpointType { - HTTP +enum class CommandType { + ADD_LIVE_INSTRUMENT, + REMOVE_LIVE_INSTRUMENT } diff --git a/src/commonMain/kotlin/spp.protocol/artifact/metrics/ArtifactSummarizedMetrics.kt b/src/commonMain/kotlin/spp.protocol/instrument/command/LiveInstrumentCommand.kt similarity index 72% rename from src/commonMain/kotlin/spp.protocol/artifact/metrics/ArtifactSummarizedMetrics.kt rename to src/commonMain/kotlin/spp.protocol/instrument/command/LiveInstrumentCommand.kt index 9623303f..65cb8336 100644 --- a/src/commonMain/kotlin/spp.protocol/artifact/metrics/ArtifactSummarizedMetrics.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/command/LiveInstrumentCommand.kt @@ -15,18 +15,15 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.artifact.metrics +package spp.protocol.instrument.command import kotlinx.serialization.Serializable +import spp.protocol.instrument.LiveInstrument +import spp.protocol.instrument.LiveSourceLocation -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ @Serializable -data class ArtifactSummarizedMetrics( - val metricType: MetricType, - val value: Double +data class LiveInstrumentCommand( + var commandType: CommandType, + var instruments: Set = emptySet(), + var locations: Set = emptySet() ) diff --git a/src/commonMain/kotlin/spp.protocol/instrument/breakpoint/event/LiveBreakpointHit.kt b/src/commonMain/kotlin/spp.protocol/instrument/event/LiveBreakpointHit.kt similarity index 90% rename from src/commonMain/kotlin/spp.protocol/instrument/breakpoint/event/LiveBreakpointHit.kt rename to src/commonMain/kotlin/spp.protocol/instrument/event/LiveBreakpointHit.kt index e828813a..ad8e705f 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/breakpoint/event/LiveBreakpointHit.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/event/LiveBreakpointHit.kt @@ -15,14 +15,12 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.instrument.breakpoint.event +package spp.protocol.instrument.event -import spp.protocol.Serializers -import spp.protocol.artifact.exception.LiveStackTrace -import spp.protocol.instrument.LiveInstrumentEventType -import spp.protocol.instrument.TrackedLiveEvent import kotlinx.datetime.Instant import kotlinx.serialization.Serializable +import spp.protocol.Serializers +import spp.protocol.artifact.exception.LiveStackTrace /** * todo: description. diff --git a/src/commonMain/kotlin/spp.protocol/instrument/LiveInstrumentEvent.kt b/src/commonMain/kotlin/spp.protocol/instrument/event/LiveInstrumentEvent.kt similarity index 93% rename from src/commonMain/kotlin/spp.protocol/instrument/LiveInstrumentEvent.kt rename to src/commonMain/kotlin/spp.protocol/instrument/event/LiveInstrumentEvent.kt index 2655fb92..066bc8c7 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/LiveInstrumentEvent.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/event/LiveInstrumentEvent.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.instrument +package spp.protocol.instrument.event import kotlinx.serialization.Serializable @@ -28,5 +28,5 @@ import kotlinx.serialization.Serializable @Serializable data class LiveInstrumentEvent( val eventType: LiveInstrumentEventType, - val data: String + val data: String //todo: type out ) diff --git a/src/commonMain/kotlin/spp.protocol/instrument/LiveInstrumentEventType.kt b/src/commonMain/kotlin/spp.protocol/instrument/event/LiveInstrumentEventType.kt similarity index 96% rename from src/commonMain/kotlin/spp.protocol/instrument/LiveInstrumentEventType.kt rename to src/commonMain/kotlin/spp.protocol/instrument/event/LiveInstrumentEventType.kt index 38344bf5..2bce4d8a 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/LiveInstrumentEventType.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/event/LiveInstrumentEventType.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.instrument +package spp.protocol.instrument.event /** * todo: description. diff --git a/src/commonMain/kotlin/spp.protocol/instrument/span/event/LiveSpanRemoved.kt b/src/commonMain/kotlin/spp.protocol/instrument/event/LiveInstrumentRemoved.kt similarity index 79% rename from src/commonMain/kotlin/spp.protocol/instrument/span/event/LiveSpanRemoved.kt rename to src/commonMain/kotlin/spp.protocol/instrument/event/LiveInstrumentRemoved.kt index cfde2fae..767f48e8 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/span/event/LiveSpanRemoved.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/event/LiveInstrumentRemoved.kt @@ -15,26 +15,24 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.instrument.span.event +package spp.protocol.instrument.event import kotlinx.datetime.Instant import kotlinx.serialization.Serializable import spp.protocol.Serializers import spp.protocol.artifact.exception.LiveStackTrace -import spp.protocol.instrument.LiveInstrumentEventType -import spp.protocol.instrument.TrackedLiveEvent +import spp.protocol.instrument.LiveInstrument /** * todo: description. * + * @since 0.3.1 * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ @Serializable -data class LiveSpanRemoved( - val spanId: String, +data class LiveInstrumentRemoved( + val liveInstrument: LiveInstrument, @Serializable(with = Serializers.InstantKSerializer::class) override val occurredAt: Instant, val cause: LiveStackTrace? = null -) : TrackedLiveEvent { - val eventType: LiveInstrumentEventType = LiveInstrumentEventType.SPAN_REMOVED -} +) : TrackedLiveEvent diff --git a/src/commonMain/kotlin/spp.protocol/instrument/log/event/LiveLogHit.kt b/src/commonMain/kotlin/spp.protocol/instrument/event/LiveLogHit.kt similarity index 90% rename from src/commonMain/kotlin/spp.protocol/instrument/log/event/LiveLogHit.kt rename to src/commonMain/kotlin/spp.protocol/instrument/event/LiveLogHit.kt index 68079644..c66703f4 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/log/event/LiveLogHit.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/event/LiveLogHit.kt @@ -15,14 +15,12 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.instrument.log.event +package spp.protocol.instrument.event -import spp.protocol.Serializers -import spp.protocol.artifact.log.LogResult -import spp.protocol.instrument.LiveInstrumentEventType -import spp.protocol.instrument.TrackedLiveEvent import kotlinx.datetime.Instant import kotlinx.serialization.Serializable +import spp.protocol.Serializers +import spp.protocol.artifact.log.LogResult /** * todo: description. diff --git a/src/commonMain/kotlin/spp.protocol/instrument/TrackedLiveEvent.kt b/src/commonMain/kotlin/spp.protocol/instrument/event/TrackedLiveEvent.kt similarity index 96% rename from src/commonMain/kotlin/spp.protocol/instrument/TrackedLiveEvent.kt rename to src/commonMain/kotlin/spp.protocol/instrument/event/TrackedLiveEvent.kt index 82900ae8..61399eb7 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/TrackedLiveEvent.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/event/TrackedLiveEvent.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.instrument +package spp.protocol.instrument.event import kotlinx.datetime.Instant diff --git a/src/commonMain/kotlin/spp.protocol/instrument/log/event/LiveLogRemoved.kt b/src/commonMain/kotlin/spp.protocol/instrument/log/event/LiveLogRemoved.kt deleted file mode 100644 index b2999aa6..00000000 --- a/src/commonMain/kotlin/spp.protocol/instrument/log/event/LiveLogRemoved.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.instrument.log.event - -import spp.protocol.Serializers -import spp.protocol.artifact.exception.LiveStackTrace -import spp.protocol.instrument.LiveInstrumentEventType -import spp.protocol.instrument.TrackedLiveEvent -import spp.protocol.instrument.log.LiveLog -import kotlinx.datetime.Instant -import kotlinx.serialization.Serializable - -/** - * todo: description. - * - * @since 0.3.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -@Serializable -data class LiveLogRemoved( - val logId: String, - @Serializable(with = Serializers.InstantKSerializer::class) - override val occurredAt: Instant, - val cause: LiveStackTrace? = null, - val liveLog: LiveLog -) : TrackedLiveEvent { - val eventType: LiveInstrumentEventType = LiveInstrumentEventType.LOG_REMOVED -} diff --git a/src/commonMain/kotlin/spp.protocol/instrument/meter/event/LiveMeterRemoved.kt b/src/commonMain/kotlin/spp.protocol/instrument/meter/event/LiveMeterRemoved.kt deleted file mode 100644 index ab340bb1..00000000 --- a/src/commonMain/kotlin/spp.protocol/instrument/meter/event/LiveMeterRemoved.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.instrument.meter.event - -import spp.protocol.Serializers -import spp.protocol.artifact.exception.LiveStackTrace -import spp.protocol.instrument.LiveInstrumentEventType -import spp.protocol.instrument.TrackedLiveEvent -import kotlinx.datetime.Instant -import kotlinx.serialization.Serializable - -/** - * todo: description. - * - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -@Serializable -data class LiveMeterRemoved( - val meterId: String, - @Serializable(with = Serializers.InstantKSerializer::class) - override val occurredAt: Instant, - val cause: LiveStackTrace? = null -) : TrackedLiveEvent { - val eventType: LiveInstrumentEventType = LiveInstrumentEventType.METER_REMOVED -} diff --git a/src/commonMain/kotlin/spp.protocol/instrument/HitThrottle.kt b/src/commonMain/kotlin/spp.protocol/instrument/throttle/HitThrottle.kt similarity index 97% rename from src/commonMain/kotlin/spp.protocol/instrument/HitThrottle.kt rename to src/commonMain/kotlin/spp.protocol/instrument/throttle/HitThrottle.kt index a0890881..38f758f4 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/HitThrottle.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/throttle/HitThrottle.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.instrument +package spp.protocol.instrument.throttle import kotlinx.datetime.Clock import kotlin.jvm.Transient diff --git a/src/commonMain/kotlin/spp.protocol/instrument/InstrumentThrottle.kt b/src/commonMain/kotlin/spp.protocol/instrument/throttle/InstrumentThrottle.kt similarity index 96% rename from src/commonMain/kotlin/spp.protocol/instrument/InstrumentThrottle.kt rename to src/commonMain/kotlin/spp.protocol/instrument/throttle/InstrumentThrottle.kt index 975bfc66..ee5c9f82 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/InstrumentThrottle.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/throttle/InstrumentThrottle.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.instrument +package spp.protocol.instrument.throttle import kotlinx.serialization.Serializable diff --git a/src/commonMain/kotlin/spp.protocol/instrument/ThrottleStep.kt b/src/commonMain/kotlin/spp.protocol/instrument/throttle/ThrottleStep.kt similarity index 96% rename from src/commonMain/kotlin/spp.protocol/instrument/ThrottleStep.kt rename to src/commonMain/kotlin/spp.protocol/instrument/throttle/ThrottleStep.kt index d678eb7e..f4647cbe 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/ThrottleStep.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/throttle/ThrottleStep.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.instrument +package spp.protocol.instrument.throttle /** * todo: description. diff --git a/src/commonMain/kotlin/spp.protocol/instrument/LiveVariable.kt b/src/commonMain/kotlin/spp.protocol/instrument/variable/LiveVariable.kt similarity index 90% rename from src/commonMain/kotlin/spp.protocol/instrument/LiveVariable.kt rename to src/commonMain/kotlin/spp.protocol/instrument/variable/LiveVariable.kt index 92703c70..89e2de4a 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/LiveVariable.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/variable/LiveVariable.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.instrument +package spp.protocol.instrument.variable import kotlinx.serialization.Contextual import kotlinx.serialization.Serializable @@ -33,5 +33,6 @@ data class LiveVariable( val lineNumber: Int = -1, val scope: LiveVariableScope? = null, val liveClazz: String? = null, - val liveIdentity: String? = null + val liveIdentity: String? = null, + val presentation: String? = null ) diff --git a/src/commonMain/kotlin/spp.protocol/instrument/LiveVariableScope.kt b/src/commonMain/kotlin/spp.protocol/instrument/variable/LiveVariableScope.kt similarity index 96% rename from src/commonMain/kotlin/spp.protocol/instrument/LiveVariableScope.kt rename to src/commonMain/kotlin/spp.protocol/instrument/variable/LiveVariableScope.kt index b8897a40..41ca83bb 100644 --- a/src/commonMain/kotlin/spp.protocol/instrument/LiveVariableScope.kt +++ b/src/commonMain/kotlin/spp.protocol/instrument/variable/LiveVariableScope.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.instrument +package spp.protocol.instrument.variable import kotlinx.serialization.Serializable diff --git a/src/commonMain/kotlin/spp.protocol/advice/AdviceCategory.kt b/src/commonMain/kotlin/spp.protocol/platform/PlatformAddress.kt similarity index 56% rename from src/commonMain/kotlin/spp.protocol/advice/AdviceCategory.kt rename to src/commonMain/kotlin/spp.protocol/platform/PlatformAddress.kt index b46ff9f8..a1b8bcac 100644 --- a/src/commonMain/kotlin/spp.protocol/advice/AdviceCategory.kt +++ b/src/commonMain/kotlin/spp.protocol/platform/PlatformAddress.kt @@ -15,23 +15,15 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.advice +package spp.protocol.platform -/** - * Types of advice assignable to a source code artifact. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -enum class AdviceCategory { - - /** - * Advice which is useful or interesting. - */ - INFORMATIVE, +object PlatformAddress { + const val PROCESSOR_CONNECTED = "spp.platform.status.processor-connected" + const val PROCESSOR_DISCONNECTED = "spp.platform.status.processor-disconnected" + const val PROBE_CONNECTED = "spp.platform.status.probe-connected" + const val PROBE_DISCONNECTED = "spp.platform.status.probe-disconnected" + const val MARKER_CONNECTED = "spp.platform.status.marker-connected" + const val MARKER_DISCONNECTED = "spp.platform.status.marker-disconnected" - /** - * Advice which indicates development action is required. - */ - CAUTIONARY + const val GENERATE_PROBE = "spp.platform.action.generate-probe" } diff --git a/src/commonMain/kotlin/spp.protocol/advice/AdviceListener.kt b/src/commonMain/kotlin/spp.protocol/platform/ProbeAddress.kt similarity index 78% rename from src/commonMain/kotlin/spp.protocol/advice/AdviceListener.kt rename to src/commonMain/kotlin/spp.protocol/platform/ProbeAddress.kt index a91f4300..ea04f9d6 100644 --- a/src/commonMain/kotlin/spp.protocol/advice/AdviceListener.kt +++ b/src/commonMain/kotlin/spp.protocol/platform/ProbeAddress.kt @@ -15,14 +15,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.advice +package spp.protocol.platform -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -interface AdviceListener { - suspend fun advised(advice: ArtifactAdvice) +object ProbeAddress { + const val LIVE_INSTRUMENT_REMOTE = "spp.probe.command.live-instrument-remote" } diff --git a/src/commonMain/kotlin/spp.protocol/artifact/log/LogViewType.kt b/src/commonMain/kotlin/spp.protocol/platform/ProcessorAddress.kt similarity index 66% rename from src/commonMain/kotlin/spp.protocol/artifact/log/LogViewType.kt rename to src/commonMain/kotlin/spp.protocol/platform/ProcessorAddress.kt index ff1f1e30..ab99c35a 100644 --- a/src/commonMain/kotlin/spp.protocol/artifact/log/LogViewType.kt +++ b/src/commonMain/kotlin/spp.protocol/platform/ProcessorAddress.kt @@ -15,18 +15,12 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.artifact.log +package spp.protocol.platform -import kotlinx.serialization.Serializable +object ProcessorAddress { + const val REMOTE_REGISTERED = "spp.processor.status.remote-registered" + const val LIVE_INSTRUMENT_APPLIED = "spp.processor.status.live-instrument-applied" + const val LIVE_INSTRUMENT_REMOVED = "spp.processor.status.live-instrument-removed" -/** - * todo: description. - * - * @since 0.2.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -@Serializable -enum class LogViewType(val description: String) { - LIVE_TAIL("Live Logs"), - INDIVIDUAL_LOG("Log"); + const val SET_LOG_PUBLISH_RATE_LIMIT = "spp.processor.setting.log-publish-rate-limit" } diff --git a/src/jvmMain/kotlin/spp/protocol/util/AccessChecker.kt b/src/commonMain/kotlin/spp.protocol/platform/auth/AccessChecker.kt similarity index 94% rename from src/jvmMain/kotlin/spp/protocol/util/AccessChecker.kt rename to src/commonMain/kotlin/spp.protocol/platform/auth/AccessChecker.kt index 4bfd2b86..8a1a7482 100644 --- a/src/jvmMain/kotlin/spp/protocol/util/AccessChecker.kt +++ b/src/commonMain/kotlin/spp.protocol/platform/auth/AccessChecker.kt @@ -15,10 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.util - -import spp.protocol.auth.AccessPermission -import spp.protocol.auth.AccessType +package spp.protocol.platform.auth object AccessChecker { diff --git a/src/commonMain/kotlin/spp.protocol/auth/AccessPermission.kt b/src/commonMain/kotlin/spp.protocol/platform/auth/AccessPermission.kt similarity index 96% rename from src/commonMain/kotlin/spp.protocol/auth/AccessPermission.kt rename to src/commonMain/kotlin/spp.protocol/platform/auth/AccessPermission.kt index c75e0596..f65fec91 100644 --- a/src/commonMain/kotlin/spp.protocol/auth/AccessPermission.kt +++ b/src/commonMain/kotlin/spp.protocol/platform/auth/AccessPermission.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.auth +package spp.protocol.platform.auth import kotlinx.serialization.Serializable diff --git a/src/commonMain/kotlin/spp.protocol/auth/AccessType.kt b/src/commonMain/kotlin/spp.protocol/platform/auth/AccessType.kt similarity index 95% rename from src/commonMain/kotlin/spp.protocol/auth/AccessType.kt rename to src/commonMain/kotlin/spp.protocol/platform/auth/AccessType.kt index fdf98797..2b1a244d 100644 --- a/src/commonMain/kotlin/spp.protocol/auth/AccessType.kt +++ b/src/commonMain/kotlin/spp.protocol/platform/auth/AccessType.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.auth +package spp.protocol.platform.auth enum class AccessType { BLACK_LIST, diff --git a/src/commonMain/kotlin/spp.protocol/auth/DataRedaction.kt b/src/commonMain/kotlin/spp.protocol/platform/auth/DataRedaction.kt similarity index 96% rename from src/commonMain/kotlin/spp.protocol/auth/DataRedaction.kt rename to src/commonMain/kotlin/spp.protocol/platform/auth/DataRedaction.kt index 4b0696cd..6f2e7286 100644 --- a/src/commonMain/kotlin/spp.protocol/auth/DataRedaction.kt +++ b/src/commonMain/kotlin/spp.protocol/platform/auth/DataRedaction.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.auth +package spp.protocol.platform.auth data class DataRedaction( val id: String, diff --git a/src/commonMain/kotlin/spp.protocol/auth/DeveloperRole.kt b/src/commonMain/kotlin/spp.protocol/platform/auth/DeveloperRole.kt similarity index 97% rename from src/commonMain/kotlin/spp.protocol/auth/DeveloperRole.kt rename to src/commonMain/kotlin/spp.protocol/platform/auth/DeveloperRole.kt index fa4d763b..cbe26d8f 100644 --- a/src/commonMain/kotlin/spp.protocol/auth/DeveloperRole.kt +++ b/src/commonMain/kotlin/spp.protocol/platform/auth/DeveloperRole.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.auth +package spp.protocol.platform.auth enum class DeveloperRole(var roleName: String, var nativeRole: Boolean) { ROLE_MANAGER("role_manager", true), diff --git a/src/commonMain/kotlin/spp.protocol/auth/RolePermission.kt b/src/commonMain/kotlin/spp.protocol/platform/auth/RolePermission.kt similarity index 98% rename from src/commonMain/kotlin/spp.protocol/auth/RolePermission.kt rename to src/commonMain/kotlin/spp.protocol/platform/auth/RolePermission.kt index 37d2bdc6..1e6479ea 100644 --- a/src/commonMain/kotlin/spp.protocol/auth/RolePermission.kt +++ b/src/commonMain/kotlin/spp.protocol/platform/auth/RolePermission.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.auth +package spp.protocol.platform.auth enum class RolePermission(val manager: Boolean = true) { RESET(true), diff --git a/src/commonMain/kotlin/spp.protocol/developer/Developer.kt b/src/commonMain/kotlin/spp.protocol/platform/developer/Developer.kt similarity index 96% rename from src/commonMain/kotlin/spp.protocol/developer/Developer.kt rename to src/commonMain/kotlin/spp.protocol/platform/developer/Developer.kt index a99dd53e..4c3c4108 100644 --- a/src/commonMain/kotlin/spp.protocol/developer/Developer.kt +++ b/src/commonMain/kotlin/spp.protocol/platform/developer/Developer.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.developer +package spp.protocol.platform.developer import kotlinx.serialization.Serializable diff --git a/src/commonMain/kotlin/spp.protocol/developer/SelfInfo.kt b/src/commonMain/kotlin/spp.protocol/platform/developer/SelfInfo.kt similarity index 84% rename from src/commonMain/kotlin/spp.protocol/developer/SelfInfo.kt rename to src/commonMain/kotlin/spp.protocol/platform/developer/SelfInfo.kt index aac17ae8..94df0fb7 100644 --- a/src/commonMain/kotlin/spp.protocol/developer/SelfInfo.kt +++ b/src/commonMain/kotlin/spp.protocol/platform/developer/SelfInfo.kt @@ -15,12 +15,12 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.developer +package spp.protocol.platform.developer import kotlinx.serialization.Serializable -import spp.protocol.auth.AccessPermission -import spp.protocol.auth.DeveloperRole -import spp.protocol.auth.RolePermission +import spp.protocol.platform.auth.AccessPermission +import spp.protocol.platform.auth.DeveloperRole +import spp.protocol.platform.auth.RolePermission @Serializable data class SelfInfo( diff --git a/src/commonMain/kotlin/spp.protocol/general/Service.kt b/src/commonMain/kotlin/spp.protocol/platform/general/Service.kt similarity index 91% rename from src/commonMain/kotlin/spp.protocol/general/Service.kt rename to src/commonMain/kotlin/spp.protocol/platform/general/Service.kt index ba1521fe..986777a9 100644 --- a/src/commonMain/kotlin/spp.protocol/general/Service.kt +++ b/src/commonMain/kotlin/spp.protocol/platform/general/Service.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.general +package spp.protocol.platform.general import kotlinx.serialization.Serializable @@ -28,5 +28,5 @@ import kotlinx.serialization.Serializable data class Service( val id: String, val name: String, - val group: String? = null + val group: String? = null //todo: add ServiceInstance? ) diff --git a/src/jvmMain/kotlin/spp/protocol/platform/client/ActiveProbe.kt b/src/commonMain/kotlin/spp.protocol/platform/status/ActiveInstance.kt similarity index 87% rename from src/jvmMain/kotlin/spp/protocol/platform/client/ActiveProbe.kt rename to src/commonMain/kotlin/spp.protocol/platform/status/ActiveInstance.kt index 97690e97..529d1d35 100644 --- a/src/jvmMain/kotlin/spp/protocol/platform/client/ActiveProbe.kt +++ b/src/commonMain/kotlin/spp.protocol/platform/status/ActiveInstance.kt @@ -15,15 +15,14 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.platform.client +package spp.protocol.platform.status import kotlinx.serialization.Contextual import kotlinx.serialization.Serializable @Serializable -data class ActiveProbe( - val probeId: String, +data class ActiveInstance( + val instanceId: String, val connectedAt: Long, - val remotes: MutableList = mutableListOf(), val meta: MutableMap = mutableMapOf() ) diff --git a/src/commonMain/kotlin/spp.protocol/status/MarkerConnection.kt b/src/commonMain/kotlin/spp.protocol/platform/status/InstanceConnection.kt similarity index 90% rename from src/commonMain/kotlin/spp.protocol/status/MarkerConnection.kt rename to src/commonMain/kotlin/spp.protocol/platform/status/InstanceConnection.kt index ada19592..a98184b1 100644 --- a/src/commonMain/kotlin/spp.protocol/status/MarkerConnection.kt +++ b/src/commonMain/kotlin/spp.protocol/platform/status/InstanceConnection.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.status +package spp.protocol.platform.status import kotlinx.serialization.Contextual import kotlinx.serialization.Serializable @@ -23,12 +23,12 @@ import kotlinx.serialization.Serializable /** * todo: description. * - * @since 0.3.0 + * @since 0.3.1 * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ @Serializable -data class MarkerConnection( - var markerId: String, +data class InstanceConnection( + var instanceId: String, var connectionTime: Long, val meta: MutableMap = mutableMapOf() ) diff --git a/src/commonMain/kotlin/spp.protocol/portal/PageType.kt b/src/commonMain/kotlin/spp.protocol/portal/PageType.kt deleted file mode 100644 index 689094e2..00000000 --- a/src/commonMain/kotlin/spp.protocol/portal/PageType.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.portal - -import spp.protocol.Serializers -import kotlinx.serialization.Serializable - -/** - * Contains the available possible portal tabs. - * - * @since 0.1.0 - * @author Brandon Fergerson - */ -@Serializable(with = Serializers.PageTypeSerializer::class) -enum class PageType(val icon: String, var hasChildren: Boolean) { - OVERVIEW("icon demo-icon satellite", false), - ACTIVITY("icon demo-icon dashboard", false), - TRACES("icon demo-icon code", true), - LOGS("icon demo-icon align left", false), - CONFIGURATION("icon configure", false); - - val title = name.toLowerCase().capitalize() -} diff --git a/src/commonMain/kotlin/spp.protocol/portal/PortalConfiguration.kt b/src/commonMain/kotlin/spp.protocol/portal/PortalConfiguration.kt deleted file mode 100644 index 1fb6a8d4..00000000 --- a/src/commonMain/kotlin/spp.protocol/portal/PortalConfiguration.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.portal - -import spp.protocol.artifact.ArtifactType -import kotlinx.serialization.Serializable - -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -@Serializable -data class PortalConfiguration( - var currentPage: PageType = PageType.ACTIVITY, - var darkMode: Boolean = false, //todo: can be page or status bar - var external: Boolean = false, - var visibleOverview: Boolean = true, - var visibleActivity: Boolean = true, - var visibleTraces: Boolean = true, - var visibleLogs: Boolean = true, - var visibleConfiguration: Boolean = false, - var autoResolveEndpointNames: Boolean = false, - var artifactType: ArtifactType? = null, //todo: allow multiple types? (endpoint + method) - var statusBar: Boolean = false -) { - fun isViewable(pageType: PageType): Boolean { - return when (pageType) { - PageType.OVERVIEW -> visibleOverview - PageType.ACTIVITY -> visibleActivity - PageType.TRACES -> visibleTraces - PageType.LOGS -> visibleLogs - PageType.CONFIGURATION -> visibleConfiguration - } - } -} diff --git a/src/commonMain/kotlin/spp.protocol/view/LiveViewConfig.kt b/src/commonMain/kotlin/spp.protocol/view/LiveViewConfig.kt index 82dce276..9d931baa 100644 --- a/src/commonMain/kotlin/spp.protocol/view/LiveViewConfig.kt +++ b/src/commonMain/kotlin/spp.protocol/view/LiveViewConfig.kt @@ -28,7 +28,6 @@ import kotlinx.serialization.Serializable @Serializable data class LiveViewConfig( val viewName: String, - val userDefined: Boolean, val viewMetrics: List, val refreshRateLimit: Int = 1000 //limit of once per X milliseconds ) diff --git a/src/jvmMain/kotlin/spp/protocol/ProtocolMarshaller.kt b/src/jvmMain/kotlin/spp/protocol/ProtocolMarshaller.kt index 14df8c7a..19abd59f 100644 --- a/src/jvmMain/kotlin/spp/protocol/ProtocolMarshaller.kt +++ b/src/jvmMain/kotlin/spp/protocol/ProtocolMarshaller.kt @@ -31,20 +31,17 @@ import io.vertx.core.json.JsonObject import io.vertx.core.json.jackson.DatabindCodec import kotlinx.datetime.Instant import spp.protocol.artifact.ArtifactQualifiedName +import spp.protocol.artifact.exception.LiveStackTrace import spp.protocol.artifact.log.LogCountSummary import spp.protocol.artifact.trace.TraceResult -import spp.protocol.developer.SelfInfo -import spp.protocol.general.Service -import spp.protocol.instrument.LiveInstrument -import spp.protocol.instrument.LiveInstrumentBatch -import spp.protocol.instrument.LiveInstrumentType -import spp.protocol.instrument.LiveSourceLocation -import spp.protocol.instrument.breakpoint.LiveBreakpoint -import spp.protocol.instrument.breakpoint.event.LiveBreakpointHit -import spp.protocol.instrument.log.LiveLog -import spp.protocol.instrument.meter.LiveMeter -import spp.protocol.instrument.span.LiveSpan -import spp.protocol.platform.client.ActiveProbe +import spp.protocol.instrument.* +import spp.protocol.instrument.command.CommandType +import spp.protocol.instrument.command.LiveInstrumentCommand +import spp.protocol.instrument.event.LiveBreakpointHit +import spp.protocol.instrument.event.LiveInstrumentRemoved +import spp.protocol.platform.developer.SelfInfo +import spp.protocol.platform.general.Service +import spp.protocol.platform.status.ActiveInstance import spp.protocol.view.LiveViewSubscription import java.util.* @@ -188,11 +185,6 @@ object ProtocolMarshaller { return value.mapTo(LiveSourceLocation::class.java) } - @JvmStatic - fun serializeLiveInstrumentBatch(value: LiveInstrumentBatch): JsonObject { - return JsonObject(Json.encode(value)) - } - @JvmStatic fun serializeLiveViewSubscription(value: LiveViewSubscription): JsonObject { return JsonObject(Json.encode(value)) @@ -224,23 +216,53 @@ object ProtocolMarshaller { } @JvmStatic - fun serializeActiveProbe(value: ActiveProbe): JsonObject { + fun serializeActiveInstance(value: ActiveInstance): JsonObject { return JsonObject(Json.encode(value)) } @JvmStatic - fun deserializeActiveProbe(value: JsonObject): ActiveProbe { - return value.mapTo(ActiveProbe::class.java) + fun deserializeActiveInstance(value: JsonObject): ActiveInstance { + return value.mapTo(ActiveInstance::class.java) } @JvmStatic - fun deserializeLiveInstrumentBatch(value: JsonObject): LiveInstrumentBatch { - val rawInstruments = value.getJsonArray("instruments") - val typedInstruments = mutableListOf() - for (i in rawInstruments.list.indices) { - typedInstruments.add(deserializeLiveInstrument(rawInstruments.getJsonObject(i))) - } - return LiveInstrumentBatch(typedInstruments) + fun serializeLiveInstrumentCommand(value: LiveInstrumentCommand): JsonObject { + return JsonObject(Json.encode(value)) + } + + @JvmStatic + fun deserializeLiveInstrumentCommand(value: JsonObject): LiveInstrumentCommand { + return LiveInstrumentCommand( + CommandType.valueOf(value.getString("commandType")), + value.getJsonArray("instruments").list.map { + if (it is JsonObject) { + deserializeLiveInstrument(it) + } else { + deserializeLiveInstrument(JsonObject.mapFrom(it)) + } + }.toSet(), + value.getJsonArray("locations").list.map { + if (it is JsonObject) { + deserializeLiveSourceLocation(it) + } else { + deserializeLiveSourceLocation(JsonObject.mapFrom(it)) + } + }.toSet() + ) + } + + @JvmStatic + fun serializeLiveInstrumentRemoved(value: LiveInstrumentRemoved): JsonObject { + return JsonObject(Json.encode(value)) + } + + @JvmStatic + fun deserializeLiveInstrumentRemoved(value: JsonObject): LiveInstrumentRemoved { + return LiveInstrumentRemoved( + deserializeLiveInstrument(value.getJsonObject("liveInstrument")), + Instant.fromEpochMilliseconds(value.getLong("occurredAt")), + value.getJsonObject("cause")?.let { Json.decodeValue(it.toString(), LiveStackTrace::class.java) } + ) } @JvmStatic diff --git a/src/jvmMain/kotlin/spp/protocol/SourceMarkerServices.kt b/src/jvmMain/kotlin/spp/protocol/SourceServices.kt similarity index 76% rename from src/jvmMain/kotlin/spp/protocol/SourceMarkerServices.kt rename to src/jvmMain/kotlin/spp/protocol/SourceServices.kt index 6ecf0600..4c44defe 100644 --- a/src/jvmMain/kotlin/spp/protocol/SourceMarkerServices.kt +++ b/src/jvmMain/kotlin/spp/protocol/SourceServices.kt @@ -17,13 +17,12 @@ */ package spp.protocol -import spp.protocol.SourceMarkerServices.Utilize.LIVE_INSTRUMENT -import spp.protocol.SourceMarkerServices.Utilize.LIVE_VIEW +import spp.protocol.SourceServices.Utilize.LIVE_INSTRUMENT +import spp.protocol.SourceServices.Utilize.LIVE_VIEW +import spp.protocol.service.LiveInstrumentService import spp.protocol.service.LiveService -import spp.protocol.service.live.LiveInstrumentService -import spp.protocol.service.live.LiveViewService -import spp.protocol.service.logging.LogCountIndicatorService -import spp.protocol.service.tracing.LocalTracingService +import spp.protocol.service.LiveViewService +import spp.protocol.service.LogCountIndicatorService /** * todo: description. @@ -31,13 +30,12 @@ import spp.protocol.service.tracing.LocalTracingService * @since 0.2.1 * @author [Brandon Fergerson](mailto:bfergerson@apache.org) */ -object SourceMarkerServices { +object SourceServices { object Instance { var liveService: LiveService? = null var liveInstrument: LiveInstrumentService? = null var liveView: LiveViewService? = null - var localTracing: LocalTracingService? = null var logCountIndicator: LogCountIndicatorService? = null } @@ -45,12 +43,14 @@ object SourceMarkerServices { const val LIVE_SERVICE = "spp.service.live-service" const val LIVE_INSTRUMENT = "spp.service.live-instrument" const val LIVE_VIEW = "spp.service.live-view" - const val LOCAL_TRACING = "spp.service.local-tracing" const val LOG_COUNT_INDICATOR = "spp.service.log-count-indicator" } object Provide { const val LIVE_INSTRUMENT_SUBSCRIBER = "$LIVE_INSTRUMENT.subscriber" const val LIVE_VIEW_SUBSCRIBER = "$LIVE_VIEW.subscriber" + + fun toLiveInstrumentSubscriberAddress(selfId: String): String = "$LIVE_INSTRUMENT_SUBSCRIBER:$selfId" + fun toLiveViewSubscriberAddress(selfId: String): String = "$LIVE_VIEW_SUBSCRIBER:$selfId" } } diff --git a/src/jvmMain/kotlin/spp/protocol/extend/SqlProducerSearch.kt b/src/jvmMain/kotlin/spp/protocol/extend/SqlProducerSearch.kt deleted file mode 100644 index 4d4c438d..00000000 --- a/src/jvmMain/kotlin/spp/protocol/extend/SqlProducerSearch.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.extend - -import spp.protocol.artifact.ArtifactQualifiedName -import org.jooq.Query -import java.util.* - -/** - * todo: description. - * - * @since 0.1.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -interface SqlProducerSearch { - - suspend fun determineSource( - query: Query, - searchPoint: ArtifactQualifiedName - ): Optional -} diff --git a/src/jvmMain/kotlin/spp/protocol/extend/TCPServiceFrameParser.kt b/src/jvmMain/kotlin/spp/protocol/extend/TCPServiceFrameParser.kt index 6ba42d87..9967ccd4 100644 --- a/src/jvmMain/kotlin/spp/protocol/extend/TCPServiceFrameParser.kt +++ b/src/jvmMain/kotlin/spp/protocol/extend/TCPServiceFrameParser.kt @@ -23,15 +23,12 @@ import io.vertx.core.Vertx import io.vertx.core.eventbus.DeliveryOptions import io.vertx.core.eventbus.ReplyException import io.vertx.core.eventbus.ReplyFailure -import io.vertx.core.json.JsonArray import io.vertx.core.json.JsonObject import io.vertx.core.net.NetSocket import io.vertx.ext.bridge.BridgeEventType import io.vertx.ext.eventbus.bridge.tcp.impl.protocol.FrameHelper -import spp.protocol.auth.RolePermission -import spp.protocol.error.AccessDenied -import spp.protocol.error.JWTVerificationException -import spp.protocol.error.MissingRemoteException +import org.slf4j.LoggerFactory +import spp.protocol.platform.auth.RolePermission import spp.protocol.service.error.InstrumentAccessDenied import spp.protocol.service.error.LiveInstrumentException import spp.protocol.service.error.LiveInstrumentException.ErrorType @@ -39,94 +36,58 @@ import spp.protocol.service.error.PermissionAccessDenied class TCPServiceFrameParser(val vertx: Vertx, val socket: NetSocket) : Handler> { -// companion object { -// private val log = LoggerFactory.getLogger(TCPServiceFrameParser::class.java) -// } + companion object { + private val log = LoggerFactory.getLogger(TCPServiceFrameParser::class.java) + } override fun handle(event: AsyncResult) { if (event.failed()) { - //log.error("Failed to receive frame", event.cause()) + log.error("Failed to receive frame", event.cause()) return } val frame = event.result() - //log.trace("Received frame: {}", frame) + log.trace("Received frame: {}", frame) - //todo: revisit this || after fixing below todo - if ("message" == frame.getString("type") || "send" == frame.getString("type")) { - if (frame.getString("replyAddress") != null) { - val deliveryOptions = DeliveryOptions() - frame.getJsonObject("headers").fieldNames().forEach { - deliveryOptions.addHeader(it, frame.getJsonObject("headers").getString(it)) - } - vertx.eventBus().request( - frame.getString("address"), - frame.getJsonObject("body"), - deliveryOptions - ).onComplete { - if (it.succeeded()) { - if (it.result().body() is JsonObject) { - FrameHelper.sendFrame( - BridgeEventType.SEND.name.toLowerCase(), - frame.getString("replyAddress"), - it.result().body(), - socket - ) - } else if (it.result().body() is JsonArray) { - FrameHelper.sendFrame( - BridgeEventType.SEND.name.toLowerCase(), - frame.getString("replyAddress"), - it.result().body(), - socket - ) - } else if (it.result().body() is Boolean) { - FrameHelper.sendFrame( - BridgeEventType.SEND.name.toLowerCase(), - frame.getString("replyAddress"), - it.result().body(), - socket - ) - } else { - FrameHelper.sendFrame( - BridgeEventType.SEND.name.toLowerCase(), - frame.getString("replyAddress"), - JsonObject.mapFrom(it.result().body()), - socket - ) - } - } else { - FrameHelper.sendFrame( - BridgeEventType.SEND.name.toLowerCase(), - frame.getString("replyAddress"), - JsonObject.mapFrom(it.cause()), - socket - ) - } - } - } else { - val body = frame.getValue("body") - if (body is JsonObject) { - if (body.getString("message")?.startsWith("EventBusException:") == true) { - handleErrorFrame(body.put("address", frame.getString("address"))) - } else { - if (body.fieldNames().size == 1 && body.containsKey("value")) { - //todo: understand why can't just re-send body like below - vertx.eventBus() - .send("local." + frame.getString("address"), body.getValue("value")) - } else { - vertx.eventBus() - .send("local." + frame.getString("address"), body) - } - } + if (frame.getString("replyAddress") != null) { + val deliveryOptions = DeliveryOptions() + frame.getJsonObject("headers").fieldNames().forEach { + deliveryOptions.addHeader(it, frame.getJsonObject("headers").getString(it)) + } + vertx.eventBus().request( + frame.getString("address"), frame.getJsonObject("body"), deliveryOptions + ).onComplete { + if (it.succeeded()) { + FrameHelper.sendFrame( + BridgeEventType.SEND.name.lowercase(), + frame.getString("replyAddress"), + it.result().body(), + socket + ) } else { - vertx.eventBus() - .send("local." + frame.getString("address"), body) + val replyException = it.cause() as ReplyException + FrameHelper.writeFrame( + JsonObject() + .put("type", BridgeEventType.SEND.name.lowercase()) + .put("address", frame.getString("replyAddress")) + .put("failureCode", replyException.failureCode()) + .put("failureType", replyException.failureType().name) + .put("message", replyException.message), + socket + ) } } - } else if ("err" == frame.getString("type")) { - //directly thrown event bus exceptions - handleErrorFrame(frame) + } else if (frame.getString("address") != null) { + val body = frame.getValue("body") + if (body == null && frame.getString("message")?.startsWith("EventBusException:") == true) { + handleErrorFrame(frame) + } else if (body is JsonObject && body.getString("message")?.startsWith("EventBusException:") == true) { + handleErrorFrame(body.put("address", frame.getString("address"))) + } else { + vertx.eventBus().send(frame.getString("address"), body) + } } else { - throw UnsupportedOperationException(frame.toString()) + //directly thrown event bus exceptions + throw ReplyException(ReplyFailure.ERROR, frame.getString("message")) } } @@ -155,56 +116,9 @@ class TCPServiceFrameParser(val vertx: Vertx, val socket: NetSocket) : Handler TODO() } - vertx.eventBus() - .send("local." + frame.getString("address"), error) + vertx.eventBus().send(frame.getString("address"), error) } else { - //i think these are service exceptions - val error = ReplyException( - ReplyFailure.RECIPIENT_FAILURE, - frame.getInteger("failureCode"), - frame.getString("rawFailure") - ) - var debugInfo = JsonObject(frame.getString("rawFailure")).getJsonObject("debugInfo") - if (frame.getString("message").contains("JWT")) { - error.initCause(JWTVerificationException(frame.getString("message"))) - } else if (debugInfo == null) { - debugInfo = JsonObject().put( - "causeMessage", JsonObject(frame.getString("message")).getString("message") - ) - } - - if (debugInfo.getString("causeName") == MissingRemoteException::class.java.name) { - error.initCause(MissingRemoteException(debugInfo.getString("causeMessage"))) - } else { - val causeMessage = debugInfo.getString("causeMessage") - if (causeMessage?.startsWith("EventBusException:") == true) { - val exceptionType = causeMessage.substringAfter("EventBusException:") - .substringBefore("[") - val exceptionParams = causeMessage.substringAfter("[").substringBefore("]") - val exceptionMessage = causeMessage.substringAfter("]: ").trimEnd() - when (exceptionType) { - LiveInstrumentException::class.simpleName -> { - error.initCause( - LiveInstrumentException( - ErrorType.valueOf(exceptionParams), - exceptionMessage - ) - ) - } - InstrumentAccessDenied::class.simpleName -> { - error.initCause(InstrumentAccessDenied(exceptionParams)) - } - AccessDenied::class.simpleName -> { - error.initCause(AccessDenied(exceptionParams)) - } - else -> TODO() - } - } else { - TODO() - } - } - vertx.eventBus() - .send("local." + frame.getString("address"), error) + throw UnsupportedOperationException(frame.toString()) } } } diff --git a/src/jvmMain/kotlin/spp/protocol/package-info.java b/src/jvmMain/kotlin/spp/protocol/package-info.java index 95d01d18..8938ea1e 100644 --- a/src/jvmMain/kotlin/spp/protocol/package-info.java +++ b/src/jvmMain/kotlin/spp/protocol/package-info.java @@ -1,4 +1,4 @@ -@ModuleGen(groupPackage = "spp.protocol", name = "service", useFutures = false) +@ModuleGen(groupPackage = "spp.protocol", name = "service", useFutures = true) package spp.protocol; import io.vertx.codegen.annotations.ModuleGen; diff --git a/src/jvmMain/kotlin/spp/protocol/platform/PlatformAddress.kt b/src/jvmMain/kotlin/spp/protocol/platform/PlatformAddress.kt deleted file mode 100644 index 4d3b54ea..00000000 --- a/src/jvmMain/kotlin/spp/protocol/platform/PlatformAddress.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.platform - -enum class PlatformAddress(val address: String) { - PROCESSOR_CONNECTED("spp.platform.status.processor-connected"), - PROCESSOR_DISCONNECTED("spp.platform.status.processor-disconnected"), - PROBE_CONNECTED("spp.platform.status.probe-connected"), - PROBE_DISCONNECTED("spp.platform.status.probe-disconnected"), - - LIVE_BREAKPOINT_REMOVED("spp.platform.status.live-breakpoint-removed"), - LIVE_BREAKPOINT_APPLIED("spp.platform.status.live-breakpoint-applied"), - LIVE_BREAKPOINTS("spp.platform.status.live-breakpoints"), - - LIVE_LOG_REMOVED("spp.platform.status.live-log-removed"), - LIVE_LOG_APPLIED("spp.platform.status.live-log-applied"), - LIVE_LOGS("spp.platform.status.live-logs"), - - LIVE_METER_REMOVED("spp.platform.status.live-meter-removed"), - LIVE_METER_APPLIED("spp.platform.status.live-meter-applied"), - LIVE_METERS("spp.platform.status.live-meters"), - - LIVE_SPAN_REMOVED("spp.platform.status.live-span-removed"), - LIVE_SPAN_APPLIED("spp.platform.status.live-span-applied"), - LIVE_SPANS("spp.platform.status.live-spans"), - - MARKER_CONNECTED("spp.status.marker-connected"), - MARKER_DISCONNECTED("spp.platform.status.marker-disconnected"), - GENERATE_PROBE("spp.platform.generate-probe"); -} diff --git a/src/jvmMain/kotlin/spp/protocol/platform/client/ActiveMarker.kt b/src/jvmMain/kotlin/spp/protocol/platform/client/ActiveMarker.kt deleted file mode 100644 index 7de2483e..00000000 --- a/src/jvmMain/kotlin/spp/protocol/platform/client/ActiveMarker.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.platform.client - -import java.io.Serializable - -data class ActiveMarker( - val markerId: String, - val connectedAt: Long, - val developerId: String, - val meta: Map = emptyMap() -) : Serializable diff --git a/src/jvmMain/kotlin/spp/protocol/platform/client/ActiveProcessor.kt b/src/jvmMain/kotlin/spp/protocol/platform/client/ActiveProcessor.kt deleted file mode 100644 index 7bb7ead2..00000000 --- a/src/jvmMain/kotlin/spp/protocol/platform/client/ActiveProcessor.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.platform.client - -import java.io.Serializable - -data class ActiveProcessor( - val processorId: String, - val connectedAt: Long, - val meta: MutableMap = mutableMapOf() -) : Serializable diff --git a/src/jvmMain/kotlin/spp/protocol/probe/ProbeAddress.kt b/src/jvmMain/kotlin/spp/protocol/probe/ProbeAddress.kt deleted file mode 100644 index 7afbac78..00000000 --- a/src/jvmMain/kotlin/spp/protocol/probe/ProbeAddress.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.probe - -enum class ProbeAddress(val address: String) { - REMOTE_REGISTERED("spp.probe.status.remote-registered"), - LIVE_BREAKPOINT_REMOTE("spp.probe.command.live-breakpoint-remote"), - LIVE_LOG_REMOTE("spp.probe.command.live-log-remote"), - LIVE_METER_REMOTE("spp.probe.command.live-meter-remote"), - LIVE_SPAN_REMOTE("spp.probe.command.live-span-remote"); -} diff --git a/src/jvmMain/kotlin/spp/protocol/probe/command/LiveInstrumentCommand.kt b/src/jvmMain/kotlin/spp/protocol/probe/command/LiveInstrumentCommand.kt deleted file mode 100644 index c4ce7050..00000000 --- a/src/jvmMain/kotlin/spp/protocol/probe/command/LiveInstrumentCommand.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.probe.command - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import java.beans.ConstructorProperties -import java.io.Serializable - -@JsonIgnoreProperties(ignoreUnknown = true) -data class LiveInstrumentCommand @ConstructorProperties("commandType", "context") constructor( - var commandType: CommandType, - var context: LiveInstrumentContext -) : Serializable { - - enum class CommandType { - ADD_LIVE_INSTRUMENT, - REMOVE_LIVE_INSTRUMENT - } -} diff --git a/src/jvmMain/kotlin/spp/protocol/probe/command/LiveInstrumentContext.kt b/src/jvmMain/kotlin/spp/protocol/probe/command/LiveInstrumentContext.kt deleted file mode 100644 index ec7fd9c8..00000000 --- a/src/jvmMain/kotlin/spp/protocol/probe/command/LiveInstrumentContext.kt +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.probe.command - -import com.fasterxml.jackson.annotation.JsonIgnore -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import io.vertx.core.json.Json -import spp.protocol.instrument.LiveInstrument -import spp.protocol.instrument.LiveSourceLocation -import java.io.Serializable - -//todo: treat this as a regular data class -@JsonIgnoreProperties(ignoreUnknown = true) -data class LiveInstrumentContext( - var instruments: MutableSet = HashSet(), - var locations: MutableSet = HashSet() -) : Serializable { - - @get:JsonIgnore - val liveInstruments: List - get() = instruments.toList() - - fun addLiveInstrument(liveInstrument: LiveInstrument): LiveInstrumentContext { - instruments.add(Json.encode(liveInstrument)) - return this - } - - fun addLiveInstrument(liveInstrument: String): LiveInstrumentContext { - instruments.add(liveInstrument) - return this - } - - fun addLiveInstruments(liveInstruments: Collection): LiveInstrumentContext { - instruments.addAll(liveInstruments) - return this - } - - fun addLocation(location: LiveSourceLocation) { - locations.add(Json.encode(location)) - } -} diff --git a/src/jvmMain/kotlin/spp/protocol/probe/status/ProbeConnection.kt b/src/jvmMain/kotlin/spp/protocol/probe/status/ProbeConnection.kt deleted file mode 100644 index b4186348..00000000 --- a/src/jvmMain/kotlin/spp/protocol/probe/status/ProbeConnection.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.probe.status - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import java.beans.ConstructorProperties -import java.io.Serializable - -@JsonIgnoreProperties(ignoreUnknown = true) -data class ProbeConnection @ConstructorProperties("probeId", "connectionTime", "meta") constructor( - var probeId: String, - var connectionTime: Long, - var meta: MutableMap = mutableMapOf() -) : Serializable diff --git a/src/jvmMain/kotlin/spp/protocol/processor/ProcessorAddress.kt b/src/jvmMain/kotlin/spp/protocol/processor/ProcessorAddress.kt deleted file mode 100644 index ace0151c..00000000 --- a/src/jvmMain/kotlin/spp/protocol/processor/ProcessorAddress.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.processor - -enum class ProcessorAddress(val address: String) { - BREAKPOINT_HIT("spp.provider.status.breakpoint-hit"), - LOG_HIT("spp.provider.status.log-hit"), - SET_LOG_PUBLISH_RATE_LIMIT("spp.provider.setting.log-publish-rate-limit"); -} diff --git a/src/jvmMain/kotlin/spp/protocol/processor/status/ProcessorConnection.kt b/src/jvmMain/kotlin/spp/protocol/processor/status/ProcessorConnection.kt deleted file mode 100644 index be593149..00000000 --- a/src/jvmMain/kotlin/spp/protocol/processor/status/ProcessorConnection.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.processor.status - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties -import java.beans.ConstructorProperties -import java.io.Serializable - -@JsonIgnoreProperties(ignoreUnknown = true) -data class ProcessorConnection @ConstructorProperties("processorId", "connectionTime", "meta") constructor( - var processorId: String, - var connectionTime: Long, - var meta: MutableMap = mutableMapOf() -) : Serializable diff --git a/src/jvmMain/kotlin/spp/protocol/service/LiveInstrumentService.kt b/src/jvmMain/kotlin/spp/protocol/service/LiveInstrumentService.kt new file mode 100644 index 00000000..608dbfeb --- /dev/null +++ b/src/jvmMain/kotlin/spp/protocol/service/LiveInstrumentService.kt @@ -0,0 +1,56 @@ +/* + * Source++, the open-source live coding platform. + * Copyright (C) 2022 CodeBrig, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package spp.protocol.service + +import io.vertx.codegen.annotations.ProxyGen +import io.vertx.codegen.annotations.VertxGen +import io.vertx.core.Future +import io.vertx.core.json.JsonObject +import kotlinx.datetime.Instant +import spp.protocol.instrument.* + +/** + * todo: description. + * + * @since 0.3.0 + * @author [Brandon Fergerson](mailto:bfergerson@apache.org) + */ +@ProxyGen +@VertxGen +interface LiveInstrumentService { + fun addLiveInstrument(instrument: LiveInstrument): Future + + @JvmSuppressWildcards + fun addLiveInstruments(instruments: List): Future> + fun removeLiveInstrument(id: String): Future + fun removeLiveInstruments(location: LiveSourceLocation): Future> + fun getLiveInstrumentById(id: String): Future + fun getLiveInstrumentsByIds(ids: List): Future> + fun getLiveInstrumentsByLocation(location: LiveSourceLocation): Future> + fun getLiveInstruments(type: LiveInstrumentType?): Future> + fun clearLiveInstruments(type: LiveInstrumentType?): Future + fun clearAllLiveInstruments(type: LiveInstrumentType?): Future + + fun setupLiveMeter(liveMeter: LiveMeter): Future + fun getLiveMeterMetrics( + liveMeter: LiveMeter, + start: Instant, + stop: Instant, + step: DurationStep + ): Future +} diff --git a/src/jvmMain/kotlin/spp/protocol/service/LiveService.kt b/src/jvmMain/kotlin/spp/protocol/service/LiveService.kt index d03da4bb..1f4a43a2 100644 --- a/src/jvmMain/kotlin/spp/protocol/service/LiveService.kt +++ b/src/jvmMain/kotlin/spp/protocol/service/LiveService.kt @@ -19,11 +19,10 @@ package spp.protocol.service import io.vertx.codegen.annotations.ProxyGen import io.vertx.codegen.annotations.VertxGen -import io.vertx.core.AsyncResult -import io.vertx.core.Handler -import spp.protocol.developer.SelfInfo -import spp.protocol.general.Service -import spp.protocol.platform.client.ActiveProbe +import io.vertx.core.Future +import spp.protocol.platform.developer.SelfInfo +import spp.protocol.platform.general.Service +import spp.protocol.platform.status.ActiveInstance /** * todo: description. @@ -34,7 +33,7 @@ import spp.protocol.platform.client.ActiveProbe @VertxGen interface LiveService { - fun getSelf(handler: Handler>) - fun getServices(handler: Handler>>) - fun getActiveProbes(handler: Handler>>) + fun getSelf(): Future + fun getServices(): Future> + fun getActiveProbes(): Future> } diff --git a/src/jvmMain/kotlin/spp/protocol/service/live/LiveViewService.kt b/src/jvmMain/kotlin/spp/protocol/service/LiveViewService.kt similarity index 68% rename from src/jvmMain/kotlin/spp/protocol/service/live/LiveViewService.kt rename to src/jvmMain/kotlin/spp/protocol/service/LiveViewService.kt index 6e618877..228cb7b1 100644 --- a/src/jvmMain/kotlin/spp/protocol/service/live/LiveViewService.kt +++ b/src/jvmMain/kotlin/spp/protocol/service/LiveViewService.kt @@ -15,12 +15,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.service.live +package spp.protocol.service import io.vertx.codegen.annotations.ProxyGen import io.vertx.codegen.annotations.VertxGen -import io.vertx.core.AsyncResult -import io.vertx.core.Handler +import io.vertx.core.Future import io.vertx.core.json.JsonObject import spp.protocol.view.LiveViewSubscription @@ -33,9 +32,9 @@ import spp.protocol.view.LiveViewSubscription @ProxyGen @VertxGen interface LiveViewService { - fun addLiveViewSubscription(subscription: LiveViewSubscription, handler: Handler>) - fun removeLiveViewSubscription(subscriptionId: String, handler: Handler>) - fun getLiveViewSubscriptions(handler: Handler>>) - fun clearLiveViewSubscriptions(handler: Handler>>) - fun getLiveViewSubscriptionStats(handler: Handler>) + fun addLiveViewSubscription(subscription: LiveViewSubscription): Future + fun removeLiveViewSubscription(subscriptionId: String): Future + fun getLiveViewSubscriptions(): Future> + fun clearLiveViewSubscriptions(): Future> + fun getLiveViewSubscriptionStats(): Future } diff --git a/src/jvmMain/kotlin/spp/protocol/service/logging/LogCountIndicatorService.kt b/src/jvmMain/kotlin/spp/protocol/service/LogCountIndicatorService.kt similarity index 84% rename from src/jvmMain/kotlin/spp/protocol/service/logging/LogCountIndicatorService.kt rename to src/jvmMain/kotlin/spp/protocol/service/LogCountIndicatorService.kt index deacc6a5..458a4bfa 100644 --- a/src/jvmMain/kotlin/spp/protocol/service/logging/LogCountIndicatorService.kt +++ b/src/jvmMain/kotlin/spp/protocol/service/LogCountIndicatorService.kt @@ -15,15 +15,13 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package spp.protocol.service.logging +package spp.protocol.service import io.vertx.codegen.annotations.ProxyGen import io.vertx.codegen.annotations.VertxGen -import io.vertx.core.AsyncResult -import io.vertx.core.Handler +import io.vertx.core.Future import io.vertx.core.json.JsonObject import kotlinx.datetime.Instant -import spp.protocol.artifact.log.LogCountSummary import spp.protocol.instrument.DurationStep /** @@ -41,7 +39,6 @@ interface LogCountIndicatorService { serviceName: String?, start: Instant, stop: Instant, - step: DurationStep, - handler: Handler> - ) + step: DurationStep + ): Future } diff --git a/src/jvmMain/kotlin/spp/protocol/service/error/PermissionAccessDenied.kt b/src/jvmMain/kotlin/spp/protocol/service/error/PermissionAccessDenied.kt index 3fd149bb..f633722a 100644 --- a/src/jvmMain/kotlin/spp/protocol/service/error/PermissionAccessDenied.kt +++ b/src/jvmMain/kotlin/spp/protocol/service/error/PermissionAccessDenied.kt @@ -18,8 +18,14 @@ package spp.protocol.service.error import io.vertx.serviceproxy.ServiceException -import spp.protocol.auth.RolePermission +import spp.protocol.platform.auth.RolePermission +/** + * todo: description. + * + * @since 0.3.0 + * @author [Brandon Fergerson](mailto:bfergerson@apache.org) + */ class PermissionAccessDenied(val permission: RolePermission, message: String? = null) : ServiceException(500, message) { fun toEventBusException(): PermissionAccessDenied { diff --git a/src/jvmMain/kotlin/spp/protocol/service/live/LiveInstrumentService.kt b/src/jvmMain/kotlin/spp/protocol/service/live/LiveInstrumentService.kt deleted file mode 100644 index 5742408b..00000000 --- a/src/jvmMain/kotlin/spp/protocol/service/live/LiveInstrumentService.kt +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.service.live - -import io.vertx.codegen.annotations.ProxyGen -import io.vertx.codegen.annotations.VertxGen -import io.vertx.core.AsyncResult -import io.vertx.core.Handler -import io.vertx.core.json.JsonObject -import kotlinx.datetime.Instant -import spp.protocol.instrument.DurationStep -import spp.protocol.instrument.LiveInstrument -import spp.protocol.instrument.LiveInstrumentBatch -import spp.protocol.instrument.LiveSourceLocation -import spp.protocol.instrument.breakpoint.LiveBreakpoint -import spp.protocol.instrument.log.LiveLog -import spp.protocol.instrument.meter.LiveMeter -import spp.protocol.instrument.span.LiveSpan - -/** - * todo: description. - * - * @since 0.3.0 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -@ProxyGen -@VertxGen -interface LiveInstrumentService { - fun addLiveInstrument(instrument: LiveInstrument, handler: Handler>) - fun addLiveInstruments(batch: LiveInstrumentBatch, handler: Handler>>) - fun removeLiveInstrument(id: String, handler: Handler>) - fun removeLiveInstruments(location: LiveSourceLocation, handler: Handler>>) - fun getLiveInstrumentById(id: String, handler: Handler>) - fun getLiveInstrumentsByIds(ids: List, handler: Handler>>) - fun getLiveInstruments(handler: Handler>>) - fun getLiveBreakpoints(handler: Handler>>) - fun getLiveLogs(handler: Handler>>) - fun getLiveMeters(handler: Handler>>) - fun getLiveSpans(handler: Handler>>) - fun clearLiveInstruments(handler: Handler>) - fun clearLiveBreakpoints(handler: Handler>) - fun clearLiveLogs(handler: Handler>) - fun clearLiveMeters(handler: Handler>) - fun clearLiveSpans(handler: Handler>) - fun clearAllLiveInstruments(handler: Handler>) - - fun setupLiveMeter(liveMeter: LiveMeter, handler: Handler>) - fun getLiveMeterMetrics( - liveMeter: LiveMeter, - start: Instant, - stop: Instant, - step: DurationStep, - handler: Handler> - ) -} diff --git a/src/jvmMain/kotlin/spp/protocol/service/tracing/LocalTracingService.kt b/src/jvmMain/kotlin/spp/protocol/service/tracing/LocalTracingService.kt deleted file mode 100644 index 99c36e8f..00000000 --- a/src/jvmMain/kotlin/spp/protocol/service/tracing/LocalTracingService.kt +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Source++, the open-source live coding platform. - * Copyright (C) 2022 CodeBrig, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package spp.protocol.service.tracing - -import spp.protocol.artifact.ArtifactQualifiedName -import spp.protocol.artifact.trace.TraceOrderType -import spp.protocol.artifact.trace.TraceResult -import io.vertx.codegen.annotations.ProxyGen -import io.vertx.codegen.annotations.VertxGen -import io.vertx.core.AsyncResult -import io.vertx.core.Handler -import kotlinx.datetime.Instant - -/** - * todo: description. - * - * @since 0.2.1 - * @author [Brandon Fergerson](mailto:bfergerson@apache.org) - */ -@ProxyGen -@VertxGen -interface LocalTracingService { - - fun getTraceResult( - artifactQualifiedName: ArtifactQualifiedName, - start: Instant, - stop: Instant, - orderType: TraceOrderType, - pageSize: Int, - pageNumber: Int, - handler: Handler> - ) -} diff --git a/src/jvmMain/kotlin/spp/protocol/util/ServiceExceptionConverter.kt b/src/jvmMain/kotlin/spp/protocol/util/ServiceExceptionConverter.kt new file mode 100644 index 00000000..679996f8 --- /dev/null +++ b/src/jvmMain/kotlin/spp/protocol/util/ServiceExceptionConverter.kt @@ -0,0 +1,44 @@ +/* + * Source++, the open-source live coding platform. + * Copyright (C) 2022 CodeBrig, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package spp.protocol.util + +import io.vertx.serviceproxy.ServiceException +import spp.protocol.service.error.LiveInstrumentException + +object ServiceExceptionConverter { + + fun fromEventBusException(exception: String): ServiceException { + return if (exception.startsWith("EventBusException")) { + var exceptionType = exception.substringAfter("EventBusException:") + exceptionType = exceptionType.substringBefore("[") + var exceptionParams = exception.substringAfter("[") + exceptionParams = exceptionParams.substringBefore("]") + val exceptionMessage = exception.substringAfter("]: ").trim { it <= ' ' } + if (LiveInstrumentException::class.java.simpleName == exceptionType) { + LiveInstrumentException( + LiveInstrumentException.ErrorType.valueOf(exceptionParams), + exceptionMessage + ).toEventBusException() + } else { + throw UnsupportedOperationException(exceptionType) + } + } else { + throw IllegalArgumentException(exception) + } + } +} diff --git a/src/jvmMain/resources/META-INF/vertx/json-mappers.properties b/src/jvmMain/resources/META-INF/vertx/json-mappers.properties index dd9f226c..6c4b1707 100644 --- a/src/jvmMain/resources/META-INF/vertx/json-mappers.properties +++ b/src/jvmMain/resources/META-INF/vertx/json-mappers.properties @@ -10,21 +10,19 @@ spp.protocol.instrument.LiveInstrument.serializer=spp.protocol.ProtocolMarshalle spp.protocol.instrument.LiveInstrument.deserializer=spp.protocol.ProtocolMarshaller#deserializeLiveInstrument spp.protocol.instrument.LiveSourceLocation.serializer=spp.protocol.ProtocolMarshaller#serializeLiveSourceLocation spp.protocol.instrument.LiveSourceLocation.deserializer=spp.protocol.ProtocolMarshaller#deserializeLiveSourceLocation -spp.protocol.instrument.breakpoint.LiveBreakpoint.serializer=spp.protocol.ProtocolMarshaller#serializeLiveBreakpoint -spp.protocol.instrument.breakpoint.LiveBreakpoint.deserializer=spp.protocol.ProtocolMarshaller#deserializeLiveBreakpoint -spp.protocol.instrument.log.LiveLog.serializer=spp.protocol.ProtocolMarshaller#serializeLiveLog -spp.protocol.instrument.log.LiveLog.deserializer=spp.protocol.ProtocolMarshaller#deserializeLiveLog -spp.protocol.instrument.meter.LiveMeter.serializer=spp.protocol.ProtocolMarshaller#serializeLiveMeter -spp.protocol.instrument.meter.LiveMeter.deserializer=spp.protocol.ProtocolMarshaller#deserializeLiveMeter -spp.protocol.instrument.span.LiveSpan.serializer=spp.protocol.ProtocolMarshaller#serializeLiveSpan -spp.protocol.instrument.span.LiveSpan.deserializer=spp.protocol.ProtocolMarshaller#deserializeLiveSpan -spp.protocol.instrument.LiveInstrumentBatch.serializer=spp.protocol.ProtocolMarshaller#serializeLiveInstrumentBatch -spp.protocol.instrument.LiveInstrumentBatch.deserializer=spp.protocol.ProtocolMarshaller#deserializeLiveInstrumentBatch +spp.protocol.instrument.LiveBreakpoint.serializer=spp.protocol.ProtocolMarshaller#serializeLiveBreakpoint +spp.protocol.instrument.LiveBreakpoint.deserializer=spp.protocol.ProtocolMarshaller#deserializeLiveBreakpoint +spp.protocol.instrument.LiveLog.serializer=spp.protocol.ProtocolMarshaller#serializeLiveLog +spp.protocol.instrument.LiveLog.deserializer=spp.protocol.ProtocolMarshaller#deserializeLiveLog +spp.protocol.instrument.LiveMeter.serializer=spp.protocol.ProtocolMarshaller#serializeLiveMeter +spp.protocol.instrument.LiveMeter.deserializer=spp.protocol.ProtocolMarshaller#deserializeLiveMeter +spp.protocol.instrument.LiveSpan.serializer=spp.protocol.ProtocolMarshaller#serializeLiveSpan +spp.protocol.instrument.LiveSpan.deserializer=spp.protocol.ProtocolMarshaller#deserializeLiveSpan spp.protocol.view.LiveViewSubscription.serializer=spp.protocol.ProtocolMarshaller#serializeLiveViewSubscription spp.protocol.view.LiveViewSubscription.deserializer=spp.protocol.ProtocolMarshaller#deserializeLiveViewSubscription -spp.protocol.developer.SelfInfo.serializer=spp.protocol.ProtocolMarshaller#serializeSelfInfo -spp.protocol.developer.SelfInfo.deserializer=spp.protocol.ProtocolMarshaller#deserializeSelfInfo -spp.protocol.general.Service.serializer=spp.protocol.ProtocolMarshaller#serializeService -spp.protocol.general.Service.deserializer=spp.protocol.ProtocolMarshaller#deserializeService -spp.protocol.platform.client.ActiveProbe.serializer=spp.protocol.ProtocolMarshaller#serializeActiveProbe -spp.protocol.platform.client.ActiveProbe.deserializer=spp.protocol.ProtocolMarshaller#deserializeActiveProbe \ No newline at end of file +spp.protocol.platform.developer.SelfInfo.serializer=spp.protocol.ProtocolMarshaller#serializeSelfInfo +spp.protocol.platform.developer.SelfInfo.deserializer=spp.protocol.ProtocolMarshaller#deserializeSelfInfo +spp.protocol.platform.general.Service.serializer=spp.protocol.ProtocolMarshaller#serializeService +spp.protocol.platform.general.Service.deserializer=spp.protocol.ProtocolMarshaller#deserializeService +spp.protocol.platform.status.ActiveInstance.serializer=spp.protocol.ProtocolMarshaller#serializeActiveInstance +spp.protocol.platform.status.ActiveInstance.deserializer=spp.protocol.ProtocolMarshaller#deserializeActiveInstance \ No newline at end of file diff --git a/src/jvmTest/kotlin/spp/protocol/artifact/trace/LiveStackTraceTest.kt b/src/jvmTest/kotlin/spp/protocol/artifact/trace/LiveStackTraceTest.kt index 27007a16..0b8ed56a 100644 --- a/src/jvmTest/kotlin/spp/protocol/artifact/trace/LiveStackTraceTest.kt +++ b/src/jvmTest/kotlin/spp/protocol/artifact/trace/LiveStackTraceTest.kt @@ -18,11 +18,11 @@ package spp.protocol.artifact.trace import com.google.common.io.Resources -import spp.protocol.artifact.exception.LiveStackTrace import io.vertx.core.json.JsonObject import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull import org.junit.Test +import spp.protocol.artifact.exception.LiveStackTrace class LiveStackTraceTest {