Skip to content

Commit 300e4a9

Browse files
committed
refactor: general add/hit event listeners
1 parent 7499cce commit 300e4a9

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

src/main/kotlin/spp/protocol/service/listen/LiveInstrumentListener.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ interface LiveInstrumentListener {
2626
fun afterInstrumentEvent(event: LiveInstrumentEvent) {
2727
}
2828

29+
fun onInstrumentAddedEvent(event: LiveInstrumentAdded) {
30+
}
31+
32+
fun onInstrumentHitEvent(event: LiveInstrumentHit) {
33+
}
34+
2935
fun onLogHitEvent(event: LiveLogHit) {
3036
}
3137

src/main/kotlin/spp/protocol/service/listen/LiveInstrumentListenerImpl.kt

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,43 @@ class LiveInstrumentListenerImpl(
4646
listener.onInstrumentEvent(event)
4747

4848
when (event.eventType) {
49-
LOG_HIT -> listener.onLogHitEvent(event as LiveLogHit)
50-
BREAKPOINT_HIT -> listener.onBreakpointHitEvent(event as LiveBreakpointHit)
51-
BREAKPOINT_ADDED -> listener.onBreakpointAddedEvent(event as LiveInstrumentAdded)
49+
BREAKPOINT_HIT -> {
50+
listener.onInstrumentHitEvent(event as LiveBreakpointHit)
51+
listener.onBreakpointHitEvent(event)
52+
}
53+
54+
LOG_HIT -> {
55+
listener.onInstrumentHitEvent(event as LiveLogHit)
56+
listener.onLogHitEvent(event)
57+
}
58+
59+
BREAKPOINT_ADDED -> {
60+
listener.onInstrumentAddedEvent(event as LiveInstrumentAdded)
61+
listener.onBreakpointAddedEvent(event)
62+
}
63+
5264
BREAKPOINT_REMOVED -> listener.onInstrumentRemovedEvent(event as LiveInstrumentRemoved)
53-
LOG_ADDED -> listener.onLogAddedEvent(event as LiveInstrumentAdded)
65+
LOG_ADDED -> {
66+
listener.onInstrumentAddedEvent(event as LiveInstrumentAdded)
67+
listener.onLogAddedEvent(event)
68+
}
69+
5470
LOG_REMOVED -> listener.onInstrumentRemovedEvent(event as LiveInstrumentRemoved)
5571
BREAKPOINT_APPLIED -> listener.onInstrumentAppliedEvent(event as LiveInstrumentApplied)
5672
LOG_APPLIED -> listener.onInstrumentAppliedEvent(event as LiveInstrumentApplied)
57-
METER_ADDED -> listener.onMeterAddedEvent(event as LiveInstrumentAdded)
73+
METER_ADDED -> {
74+
listener.onInstrumentAddedEvent(event as LiveInstrumentAdded)
75+
listener.onMeterAddedEvent(event)
76+
}
77+
5878
METER_APPLIED -> listener.onInstrumentAppliedEvent(event as LiveInstrumentApplied)
5979
METER_UPDATED -> Unit // TODO
6080
METER_REMOVED -> listener.onInstrumentRemovedEvent(event as LiveInstrumentRemoved)
61-
SPAN_ADDED -> listener.onSpanAddedEvent(event as LiveInstrumentAdded)
81+
SPAN_ADDED -> {
82+
listener.onInstrumentAddedEvent(event as LiveInstrumentAdded)
83+
listener.onSpanAddedEvent(event)
84+
}
85+
6286
SPAN_APPLIED -> listener.onInstrumentAppliedEvent(event as LiveInstrumentApplied)
6387
SPAN_REMOVED -> listener.onInstrumentRemovedEvent(event as LiveInstrumentRemoved)
6488
}

0 commit comments

Comments
 (0)