Skip to content

Commit fe8307d

Browse files
authored
Merge pull request #176 from sourceplusplus/live-insight
feat: live insight
2 parents fa724fc + 073eaf2 commit fe8307d

File tree

3 files changed

+110
-2
lines changed

3 files changed

+110
-2
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Source++, the continuous feedback platform for developers.
3+
* Copyright (C) 2022-2023 CodeBrig, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package spp.protocol.insight
18+
19+
import io.vertx.codegen.annotations.DataObject
20+
import io.vertx.core.json.JsonObject
21+
import java.time.Instant
22+
23+
/**
24+
* Represents a siloed workspace for performing live insight analyses. Every commit
25+
* to a project is analysed in a new workspace. Workspaces are isolated from
26+
* each other and can be deleted when no longer needed.
27+
*/
28+
@DataObject
29+
data class InsightWorkspace(
30+
val id: String,
31+
val createDate: Instant,
32+
val config: JsonObject = JsonObject()
33+
) {
34+
constructor(json: JsonObject) : this(
35+
id = json.getString("id"),
36+
createDate = json.getInstant("createDate")
37+
)
38+
39+
fun toJson(): JsonObject {
40+
val json = JsonObject()
41+
json.put("id", id)
42+
json.put("createDate", createDate)
43+
return json
44+
}
45+
}

src/main/kotlin/spp/protocol/instrument/LiveMeter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ data class LiveMeter(
5757
append(buildString {
5858
append("Must begin with 'spp_', ")
5959
append("contain only lowercase letters, numbers, ")
60-
append("and underscores, must be 1-64 characters in length, ")
60+
append("and underscores, must be 1-128 characters in length, ")
6161
append("and cannot end with an underscore.")
6262
})
6363
})
@@ -152,7 +152,7 @@ data class LiveMeter(
152152
}
153153

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

157157
fun formatMeterName(meterName: String): String {
158158
val sb = StringBuilder()
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Source++, the continuous feedback platform for developers.
3+
* Copyright (C) 2022-2023 CodeBrig, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package spp.protocol.service
18+
19+
import io.vertx.codegen.annotations.GenIgnore
20+
import io.vertx.codegen.annotations.ProxyGen
21+
import io.vertx.codegen.annotations.VertxGen
22+
import io.vertx.core.Future
23+
import io.vertx.core.Vertx
24+
import io.vertx.core.eventbus.DeliveryOptions
25+
import io.vertx.core.json.JsonArray
26+
import io.vertx.core.json.JsonObject
27+
import spp.protocol.artifact.ArtifactQualifiedName
28+
29+
@ProxyGen
30+
@VertxGen
31+
interface LiveInsightService {
32+
@GenIgnore
33+
companion object {
34+
@JvmStatic
35+
fun createProxy(vertx: Vertx, authToken: String? = null): LiveInsightService {
36+
val deliveryOptions = DeliveryOptions().apply {
37+
authToken?.let { addHeader("auth-token", it) }
38+
}
39+
return LiveInsightServiceVertxEBProxy(vertx, SourceServices.LIVE_INSIGHT, deliveryOptions)
40+
}
41+
}
42+
43+
/**
44+
* Uploads source code to the workspace.
45+
* @param sourceCode The source code to upload.
46+
*/
47+
fun uploadSourceCode(workspaceId: String, sourceCode: JsonObject): Future<Void>
48+
49+
/**
50+
* Uploads source code repository to the workspace.
51+
*
52+
* @param repository The source code repository to upload.
53+
*/
54+
fun uploadRepository(workspaceId: String, repository: JsonObject): Future<Void>
55+
56+
fun getArtifactInsights(workspaceId: String, artifact: ArtifactQualifiedName, types: JsonArray): Future<JsonObject>
57+
58+
fun getProjectClasses(workspaceId: String, offset: Int, limit: Int): Future<JsonArray>
59+
60+
fun getProjectFunctions(workspaceId: String, offset: Int, limit: Int): Future<JsonArray>
61+
62+
fun getFunctionCode(workspaceId: String, function: ArtifactQualifiedName): Future<JsonObject>
63+
}

0 commit comments

Comments
 (0)