Skip to content

Commit 3c7174c

Browse files
committed
LiveSourceLocation.service should be Service object
ref: sourceplusplus/sourceplusplus#499
1 parent 2e036a4 commit 3c7174c

15 files changed

+185
-98
lines changed

src/main/kotlin/spp/protocol/instrument/location/LiveLocation.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,5 @@ import spp.protocol.platform.general.Service
2323
*/
2424
interface LiveLocation {
2525
val service: Service?
26-
val serviceInstance: String?
27-
val commitId: String?
28-
val fileChecksum: String?
2926
val probeId: String?
3027
}

src/main/kotlin/spp/protocol/instrument/location/LiveSourceLocation.kt

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ data class LiveSourceLocation @JvmOverloads constructor(
3232
val source: String,
3333
val line: Int = -1,
3434
override val service: Service? = null,
35-
override val serviceInstance: String? = null,
36-
override val commitId: String? = null,
37-
override val fileChecksum: String? = null, //todo: impl
3835
override val probeId: String? = null, //todo: impl
3936
val scope: LocationScope = LocationScope.LINE
4037
) : LiveLocation, Comparable<LiveSourceLocation> {
@@ -50,9 +47,6 @@ data class LiveSourceLocation @JvmOverloads constructor(
5047
Service.fromName(it.toString())
5148
}
5249
},
53-
serviceInstance = json.getString("serviceInstance"),
54-
commitId = json.getString("commitId"),
55-
fileChecksum = json.getString("fileChecksum"),
5650
probeId = json.getString("probeId"),
5751
scope = json.getString("scope")?.let { LocationScope.valueOf(it) } ?: LocationScope.LINE
5852
)
@@ -62,9 +56,6 @@ data class LiveSourceLocation @JvmOverloads constructor(
6256
json.put("source", source)
6357
json.put("line", line)
6458
json.put("service", service?.toJson())
65-
json.put("serviceInstance", serviceInstance)
66-
json.put("commitId", commitId)
67-
json.put("fileChecksum", fileChecksum)
6859
json.put("probeId", probeId)
6960
json.put("scope", scope.name)
7061
return json
@@ -79,18 +70,13 @@ data class LiveSourceLocation @JvmOverloads constructor(
7970
fun isSameLocation(other: LiveSourceLocation): Boolean {
8071
if (source != other.source) return false
8172
if (line != other.line && line != -1 && other.line != -1) return false //-1 is wildcard
82-
if (service != other.service) return false
83-
if (serviceInstance != other.serviceInstance) return false
84-
if (commitId != other.commitId) return false
85-
if (fileChecksum != other.fileChecksum) return false
86-
if (probeId != other.probeId) return false
73+
if (service != null && (other.service == null || !service.isSameService(other.service))) return false
74+
if (probeId != null && probeId != other.probeId) return false
8775
return true
8876
}
8977

9078
fun isSameLocation(other: InstanceConnection): Boolean {
9179
if (service != null && service.name != other.meta["service"]) return false
92-
if (serviceInstance != null && serviceInstance != other.meta["service_instance"]) return false
93-
if (commitId != null && commitId != other.meta["commit_id"]) return false
9480
if (probeId != null && probeId != other.instanceId) return false
9581
return true
9682
}
@@ -101,9 +87,6 @@ data class LiveSourceLocation @JvmOverloads constructor(
10187
append("source=$source")
10288
if (line != -1) append(", line=$line")
10389
if (service != null) append(", service=$service")
104-
if (serviceInstance != null) append(", serviceInstance=$serviceInstance")
105-
if (commitId != null) append(", commitId=$commitId")
106-
if (fileChecksum != null) append(", fileChecksum=$fileChecksum")
10790
if (probeId != null) append(", probeId=$probeId")
10891
if (scope != LocationScope.LINE) append(", scope=$scope")
10992
append(")")

src/main/kotlin/spp/protocol/platform/general/Service.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import spp.protocol.platform.general.util.IDManager
2828
@DataObject
2929
data class Service(
3030
val name: String,
31-
val group: String = "",
31+
val group: String? = null,
3232
val shortName: String? = null,
3333
val layers: List<String> = emptyList(),
3434
val normal: Boolean = true,
@@ -48,8 +48,8 @@ data class Service(
4848
json.getString("name"),
4949
json.getString("group"),
5050
json.getString("shortName"),
51-
json.getJsonArray("layers").map { it as String },
52-
json.getBoolean("normal"),
51+
json.getJsonArray("layers")?.map { it.toString() } ?: emptyList(),
52+
json.getBoolean("normal") ?: true,
5353
json.getString("environment"),
5454
json.getString("version")
5555
)
@@ -77,9 +77,9 @@ data class Service(
7777
/**
7878
* Ensures all non-null fields are equal.
7979
*/
80-
fun isSameLocation(other: Service): Boolean {
80+
fun isSameService(other: Service): Boolean {
8181
if (name != other.name) return false
82-
if (group != other.group) return false
82+
if (group != null && group != other.group) return false
8383
if (shortName != null && shortName != other.shortName) return false
8484
if (layers != other.layers) return false
8585
if (normal != other.normal) return false
@@ -118,7 +118,7 @@ data class Service(
118118
return buildString {
119119
append("Service(")
120120
append("name=$name")
121-
if (group != "") append(", group=$group")
121+
if (group != null && group != "") append(", group=$group")
122122
if (shortName != null) append(", shortName=$shortName")
123123
if (layers.isNotEmpty()) append(", layers=$layers")
124124
if (!normal) append(", normal=$normal")

src/main/resources/graphql/instrument/add-live-breakpoint.graphql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ mutation addLiveBreakpoint($input: LiveBreakpointInput!) {
2525
location {
2626
source
2727
line
28+
service {
29+
id
30+
name
31+
group
32+
shortName
33+
layers
34+
normal
35+
environment
36+
version
37+
}
38+
probeId
39+
scope
2840
}
2941
condition
3042
expiresAt

src/main/resources/graphql/instrument/add-live-log.graphql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ mutation addLiveLog($input: LiveLogInput!) {
66
location {
77
source
88
line
9+
service {
10+
id
11+
name
12+
group
13+
shortName
14+
layers
15+
normal
16+
environment
17+
version
18+
}
19+
probeId
20+
scope
921
}
1022
condition
1123
expiresAt

src/main/resources/graphql/instrument/add-live-meter.graphql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ mutation addLiveMeter($input: LiveMeterInput!) {
99
location {
1010
source
1111
line
12+
service {
13+
id
14+
name
15+
group
16+
shortName
17+
layers
18+
normal
19+
environment
20+
version
21+
}
22+
probeId
23+
scope
1224
}
1325
condition
1426
expiresAt

src/main/resources/graphql/instrument/add-live-span.graphql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ mutation addLiveSpan($input: LiveSpanInput!) {
55
location {
66
source
77
line
8+
service {
9+
id
10+
name
11+
group
12+
shortName
13+
layers
14+
normal
15+
environment
16+
version
17+
}
18+
probeId
19+
scope
820
}
921
condition
1022
expiresAt

src/main/resources/graphql/instrument/get-live-breakpoints.graphql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ query getLiveBreakpoints{
2525
location {
2626
source
2727
line
28+
service {
29+
id
30+
name
31+
group
32+
shortName
33+
layers
34+
normal
35+
environment
36+
version
37+
}
38+
probeId
39+
scope
2840
}
2941
condition
3042
expiresAt

src/main/resources/graphql/instrument/get-live-instruments.graphql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ query getLiveInstruments{
44
location {
55
source
66
line
7+
service {
8+
id
9+
name
10+
group
11+
shortName
12+
layers
13+
normal
14+
environment
15+
version
16+
}
17+
probeId
18+
scope
719
}
820
condition
921
expiresAt

src/main/resources/graphql/instrument/get-live-logs.graphql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ query getLiveLogs{
66
location {
77
source
88
line
9+
service {
10+
id
11+
name
12+
group
13+
shortName
14+
layers
15+
normal
16+
environment
17+
version
18+
}
19+
probeId
20+
scope
921
}
1022
condition
1123
expiresAt

0 commit comments

Comments
 (0)