Skip to content

Commit e0c1f90

Browse files
committed
refactor: convenience functions
1 parent 56b47fc commit e0c1f90

File tree

1 file changed

+126
-2
lines changed

1 file changed

+126
-2
lines changed

src/main/kotlin/spp/protocol/service/LiveInstrumentService.kt

Lines changed: 126 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import io.vertx.codegen.annotations.VertxGen
2222
import io.vertx.core.Future
2323
import io.vertx.core.Vertx
2424
import io.vertx.core.eventbus.DeliveryOptions
25-
import io.vertx.core.json.JsonObject
2625
import spp.protocol.SourceServices
2726
import spp.protocol.instrument.*
2827

@@ -47,18 +46,143 @@ interface LiveInstrumentService {
4746
}
4847
}
4948

49+
/**
50+
* Applies the given [LiveInstrument].
51+
*/
5052
fun addLiveInstrument(instrument: LiveInstrument): Future<LiveInstrument>
5153

54+
/**
55+
* Applies the given [LiveBreakpoint].
56+
*/
57+
fun addLiveBreakpoint(liveBreakpoint: LiveBreakpoint): Future<LiveBreakpoint> {
58+
return addLiveInstrument(liveBreakpoint).map { it as LiveBreakpoint }
59+
}
60+
61+
/**
62+
* Applies the given [LiveLog].
63+
*/
64+
fun addLiveLog(liveLog: LiveLog): Future<LiveLog> {
65+
return addLiveInstrument(liveLog).map { it as LiveLog }
66+
}
67+
68+
/**
69+
* Applies the given [LiveSpan].
70+
*/
71+
fun addLiveMeter(liveMeter: LiveMeter): Future<LiveMeter> {
72+
return addLiveInstrument(liveMeter).map { it as LiveMeter }
73+
}
74+
75+
/**
76+
* Applies the given [LiveSpan].
77+
*/
78+
fun addLiveSpan(liveSpan: LiveSpan): Future<LiveSpan> {
79+
return addLiveInstrument(liveSpan).map { it as LiveSpan }
80+
}
81+
5282
@JvmSuppressWildcards
5383
fun addLiveInstruments(instruments: List<LiveInstrument>): Future<List<LiveInstrument>>
5484
fun removeLiveInstrument(id: String): Future<LiveInstrument?>
5585
fun removeLiveInstruments(location: LiveSourceLocation): Future<List<LiveInstrument>>
5686
fun getLiveInstrumentById(id: String): Future<LiveInstrument?>
5787
fun getLiveInstrumentsByIds(ids: List<String>): Future<List<LiveInstrument>>
5888
fun getLiveInstrumentsByLocation(location: LiveSourceLocation): Future<List<LiveInstrument>>
89+
90+
/**
91+
* Gets [LiveInstrument]s with the given [type].
92+
*/
5993
fun getLiveInstruments(type: LiveInstrumentType?): Future<List<LiveInstrument>>
94+
95+
/**
96+
* Removes [LiveInstrument]s with the given [type] created by the developer invoking this method.
97+
*/
6098
fun clearLiveInstruments(type: LiveInstrumentType?): Future<Boolean>
99+
100+
/**
101+
* Removes [LiveInstrument]s with the given [type] created by all developers.
102+
*/
61103
fun clearAllLiveInstruments(type: LiveInstrumentType?): Future<Boolean>
62104

63-
fun setupLiveMeter(liveMeter: LiveMeter): Future<JsonObject>
105+
/**
106+
* Gets all [LiveBreakpoint]s.
107+
*/
108+
fun getLiveBreakpoints(): Future<List<LiveBreakpoint>> {
109+
return getLiveInstruments(LiveInstrumentType.BREAKPOINT).map { it as List<LiveBreakpoint> }
110+
}
111+
112+
/**
113+
* Gets all [LiveLog]s.
114+
*/
115+
fun getLiveLogs(): Future<List<LiveLog>> {
116+
return getLiveInstruments(LiveInstrumentType.LOG).map { it as List<LiveLog> }
117+
}
118+
119+
/**
120+
* Gets all [LiveMeter]s.
121+
*/
122+
fun getLiveMeters(): Future<List<LiveMeter>> {
123+
return getLiveInstruments(LiveInstrumentType.METER).map { it as List<LiveMeter> }
124+
}
125+
126+
/**
127+
* Gets all [LiveSpan]s.
128+
*/
129+
fun getLiveSpans(): Future<List<LiveSpan>> {
130+
return getLiveInstruments(LiveInstrumentType.SPAN).map { it as List<LiveSpan> }
131+
}
132+
133+
/**
134+
* Removes [LiveBreakpoint]s created by the developer invoking this method.
135+
*/
136+
fun clearLiveBreakpoints(): Future<Boolean> {
137+
return clearLiveInstruments(LiveInstrumentType.BREAKPOINT)
138+
}
139+
140+
/**
141+
* Removes [LiveLog]s created by the developer invoking this method.
142+
*/
143+
fun clearLiveLogs(): Future<Boolean> {
144+
return clearLiveInstruments(LiveInstrumentType.LOG)
145+
}
146+
147+
/**
148+
* Removes [LiveMeter]s created by the developer invoking this method.
149+
*/
150+
fun clearLiveMeters(): Future<Boolean> {
151+
return clearLiveInstruments(LiveInstrumentType.METER)
152+
}
153+
154+
/**
155+
* Removes [LiveSpan]s created by the developer invoking this method.
156+
*/
157+
fun clearLiveSpans(): Future<Boolean> {
158+
return clearLiveInstruments(LiveInstrumentType.SPAN)
159+
}
160+
161+
/**
162+
* Removes [LiveBreakpoint]s created by all developers.
163+
*/
164+
fun clearAllLiveBreakpoints(): Future<Boolean> {
165+
return clearAllLiveInstruments(LiveInstrumentType.BREAKPOINT)
166+
}
167+
168+
/**
169+
* Removes [LiveLog]s created by all developers.
170+
*/
171+
fun clearAllLiveLogs(): Future<Boolean> {
172+
return clearAllLiveInstruments(LiveInstrumentType.LOG)
173+
}
174+
175+
/**
176+
* Removes [LiveMeter]s created by all developers.
177+
*/
178+
fun clearAllLiveMeters(): Future<Boolean> {
179+
return clearAllLiveInstruments(LiveInstrumentType.METER)
180+
}
181+
182+
/**
183+
* Removes [LiveSpan]s created by all developers.
184+
*/
185+
fun clearAllLiveSpans(): Future<Boolean> {
186+
return clearAllLiveInstruments(LiveInstrumentType.SPAN)
187+
}
64188
}

0 commit comments

Comments
 (0)