Skip to content

feat: live insight #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3af3c3f
Revert "chore: clean"
BFergerson May 2, 2023
fbd49e1
Merge branch 'master' into live-insight
BFergerson May 25, 2023
c93ad3c
Merge branch 'master' into live-insight
BFergerson Jun 7, 2023
25ae5cd
Merge branch 'master' into live-insight
BFergerson Jun 25, 2023
b89a192
Merge branch 'master' into live-insight
BFergerson Jun 26, 2023
8f3cb98
Increase LiveMeter ID length limit to 128
BFergerson Jun 27, 2023
89c115b
Update copyright year
BFergerson Jun 27, 2023
bcb9590
refactor: migrate LiveSourceLocation.service to Service type
BFergerson Jun 28, 2023
8d05676
style: detekt
BFergerson Jun 28, 2023
3acba0c
Refactor LiveView implementation and Service object structure
BFergerson Jun 28, 2023
289dcaa
fix: Service serialization
BFergerson Jun 29, 2023
cf47d95
Add 'withId' function to Service class
BFergerson Jun 29, 2023
9e37645
chore(deps): update dependency gradle to v8.2
renovate[bot] Jun 30, 2023
33ee82f
chore: add insomnia workspace
BFergerson Jul 2, 2023
fa370d2
Refactor Service.kt to eliminate bug in ID analysis
BFergerson Jul 2, 2023
9287f5f
chore: support serializing old format
BFergerson Jul 2, 2023
d5d07f0
fix: get live logs, meters, traces with wildcard service
BFergerson Jul 3, 2023
842bf30
Replace 'commitId' with 'version' in Service & Tests
BFergerson Jul 3, 2023
7574888
Rename 'commitId' to 'version'
BFergerson Jul 3, 2023
e635c23
LiveSourceLocation.service should be Service object
BFergerson Jul 3, 2023
6912cc4
Merge branch 'master' into live-insight
BFergerson Jul 3, 2023
3ea86f1
Merge branch 'master' into live-insight
BFergerson Jul 10, 2023
65630d0
Merge branch 'master' into live-insight
BFergerson Aug 5, 2023
0c093bd
chore: insight work
BFergerson Aug 5, 2023
073eaf2
Merge branch 'master' into live-insight
BFergerson Aug 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/main/kotlin/spp/protocol/insight/InsightWorkspace.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Source++, the continuous feedback platform for developers.
* Copyright (C) 2022-2023 CodeBrig, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package spp.protocol.insight

import io.vertx.codegen.annotations.DataObject
import io.vertx.core.json.JsonObject
import java.time.Instant

/**
* Represents a siloed workspace for performing live insight analyses. Every commit
* to a project is analysed in a new workspace. Workspaces are isolated from
* each other and can be deleted when no longer needed.
*/
@DataObject
data class InsightWorkspace(
val id: String,
val createDate: Instant,
val config: JsonObject = JsonObject()
) {
constructor(json: JsonObject) : this(
id = json.getString("id"),
createDate = json.getInstant("createDate")
)

fun toJson(): JsonObject {
val json = JsonObject()
json.put("id", id)
json.put("createDate", createDate)
return json
}
}
4 changes: 2 additions & 2 deletions src/main/kotlin/spp/protocol/instrument/LiveMeter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ data class LiveMeter(
append(buildString {
append("Must begin with 'spp_', ")
append("contain only lowercase letters, numbers, ")
append("and underscores, must be 1-64 characters in length, ")
append("and underscores, must be 1-128 characters in length, ")
append("and cannot end with an underscore.")
})
})
Expand Down Expand Up @@ -152,7 +152,7 @@ data class LiveMeter(
}

companion object {
val VALID_ID_PATTERN = Regex("spp_[a-zA-Z0-9_]{1,63}(?<!_)")
val VALID_ID_PATTERN = Regex("spp_[a-zA-Z0-9_]{1,127}(?<!_)")

fun formatMeterName(meterName: String): String {
val sb = StringBuilder()
Expand Down
63 changes: 63 additions & 0 deletions src/main/kotlin/spp/protocol/service/LiveInsightService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Source++, the continuous feedback platform for developers.
* Copyright (C) 2022-2023 CodeBrig, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package spp.protocol.service

import io.vertx.codegen.annotations.GenIgnore
import io.vertx.codegen.annotations.ProxyGen
import io.vertx.codegen.annotations.VertxGen
import io.vertx.core.Future
import io.vertx.core.Vertx
import io.vertx.core.eventbus.DeliveryOptions
import io.vertx.core.json.JsonArray
import io.vertx.core.json.JsonObject
import spp.protocol.artifact.ArtifactQualifiedName

@ProxyGen
@VertxGen
interface LiveInsightService {
@GenIgnore
companion object {
@JvmStatic
fun createProxy(vertx: Vertx, authToken: String? = null): LiveInsightService {
val deliveryOptions = DeliveryOptions().apply {
authToken?.let { addHeader("auth-token", it) }
}
return LiveInsightServiceVertxEBProxy(vertx, SourceServices.LIVE_INSIGHT, deliveryOptions)
}
}

/**
* Uploads source code to the workspace.
* @param sourceCode The source code to upload.
*/
fun uploadSourceCode(workspaceId: String, sourceCode: JsonObject): Future<Void>

/**
* Uploads source code repository to the workspace.
*
* @param repository The source code repository to upload.
*/
fun uploadRepository(workspaceId: String, repository: JsonObject): Future<Void>

fun getArtifactInsights(workspaceId: String, artifact: ArtifactQualifiedName, types: JsonArray): Future<JsonObject>

fun getProjectClasses(workspaceId: String, offset: Int, limit: Int): Future<JsonArray>

fun getProjectFunctions(workspaceId: String, offset: Int, limit: Int): Future<JsonArray>

fun getFunctionCode(workspaceId: String, function: ArtifactQualifiedName): Future<JsonObject>
}