@@ -35,16 +35,17 @@ import io.vertx.ext.eventbus.bridge.tcp.impl.protocol.FrameParser
3535import io.vertx.kotlin.coroutines.await
3636import kotlinx.coroutines.runBlocking
3737import spp.cli.PlatformCLI
38- import spp.protocol.marshall.ProtocolMarshaller.deserializeLiveInstrumentRemoved
3938import spp.protocol.SourceServices.Provide.toLiveInstrumentSubscriberAddress
4039import spp.protocol.extend.TCPServiceFrameParser
4140import spp.protocol.instrument.event.LiveInstrumentEvent
4241import spp.protocol.instrument.event.LiveInstrumentEventType
4342import spp.protocol.instrument.event.LiveLogHit
4443import spp.protocol.marshall.ProtocolMarshaller
44+ import spp.protocol.marshall.ProtocolMarshaller.deserializeLiveInstrumentRemoved
4545
46- class SubscribeEvents : CliktCommand (
47- help = " Listens for and outputs live events. Subscribes to all events by default"
46+ class SubscribeInstrument : CliktCommand (
47+ name = " instrument" ,
48+ help = " Listen to live instruments. Subscribes to all events by default"
4849) {
4950
5051 val instrumentIds by argument(
@@ -62,7 +63,8 @@ class SubscribeEvents : CliktCommand(
6263 .flag(default = false )
6364
6465 override fun run () {
65- var eventCount = 1
66+ PlatformCLI .connectToPlatform()
67+
6668 runBlocking {
6769 val vertx = Vertx .vertx()
6870 val client = if (PlatformCLI .certFingerprint != null ) {
@@ -77,6 +79,7 @@ class SubscribeEvents : CliktCommand(
7779 vertx.createNetClient(options)
7880 } else {
7981 val options = NetClientOptions ()
82+ .setTrustAll(true )
8083 .setReconnectAttempts(Int .MAX_VALUE ).setReconnectInterval(5000 )
8184 .setSsl(PlatformCLI .platformHost.startsWith(" https" ))
8285 vertx.createNetClient(options)
@@ -118,38 +121,18 @@ class SubscribeEvents : CliktCommand(
118121
119122 if (! includeBreakpoints && ! includeLogs && ! includeMeters && ! includeTraces) {
120123 // listen for all events
121- println (
122- " \n Event (${eventCount++ } ):\n " +
123- " \t Type: ${liveEvent.eventType} \n " +
124- " \t Data: ${liveEvent.data} "
125- )
124+ println (" \n Type: ${liveEvent.eventType} \n Data: ${liveEvent.data} " )
126125 } else {
127126 // todo: impl filtering on platform
128127 // listen for specific events
129128 if (includeBreakpoints && liveEvent.eventType.name.startsWith(" breakpoint" , true )) {
130- println (
131- " \n Event (${eventCount++ } ):\n " +
132- " \t Type: ${liveEvent.eventType} \n " +
133- " \t Data: ${liveEvent.data} "
134- )
129+ println (" \n Type: ${liveEvent.eventType} \n Data: ${liveEvent.data} " )
135130 } else if (includeLogs && liveEvent.eventType.name.startsWith(" log" , true )) {
136- println (
137- " \n Event (${eventCount++ } ):\n " +
138- " \t Type: ${liveEvent.eventType} \n " +
139- " \t Data: ${liveEvent.data} "
140- )
131+ println (" \n Type: ${liveEvent.eventType} \n Data: ${liveEvent.data} " )
141132 } else if (includeMeters && liveEvent.eventType.name.startsWith(" meter" , true )) {
142- println (
143- " \n Event (${eventCount++ } ):\n " +
144- " \t Type: ${liveEvent.eventType} \n " +
145- " \t Data: ${liveEvent.data} "
146- )
133+ println (" \n Type: ${liveEvent.eventType} \n Data: ${liveEvent.data} " )
147134 } else if (includeTraces && liveEvent.eventType.name.startsWith(" trace" , true )) {
148- println (
149- " \n Event (${eventCount++ } ):\n " +
150- " \t Type: ${liveEvent.eventType} \n " +
151- " \t Data: ${liveEvent.data} "
152- )
135+ println (" \n Type: ${liveEvent.eventType} \n Data: ${liveEvent.data} " )
153136 }
154137 }
155138 }
0 commit comments