leftiness / cometd-client

MIT License
0 stars 0 forks source link

Subscribe to events on CLI #3

Open leftiness opened 3 years ago

leftiness commented 3 years ago

todo

notes

links

leftiness commented 3 years ago

Work in progress.

[brandon@localhost cometd-client]$ ./gradlew run --quiet --args='s /test'
/test
leftiness commented 3 years ago

Working on BayeuxClient things.

notes

links

leftiness commented 3 years ago

Making progress.

[brandon@localhost cometd-client]$ ./gradlew run --quiet --args='subscribe http://localhost:8080/cometd /chat/**'
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
{chat=brandon has joined, membership=join, user=brandon}
{chat=hello, user=brandon}
{chat=goodbye, user=brandon}
{chat=brandon has left, membership=leave, user=brandon}
<==========---> 80% EXECUTING [16s]
> :app:run
leftiness commented 3 years ago
[brandon@localhost cometd-client]$ ./gradlew run --quiet --args='subscribe http://localhost:8080/cometd /chat/**'
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
DEAD
ESTABLISHED
ALIVE
ALIVE
LOST
DEAD
DEAD
DEAD
DEAD
{chat=asdf has joined, membership=join, user=asdf}
ESTABLISHED
ALIVE
ALIVE
ALIVE
leftiness commented 3 years ago

Doesn't make sense to add a listener to log connection status. It's already there in debug logs.

[brandon@localhost cometd-client]$ ./gradlew run -P logLevel=debug --quiet --args='subscribe http://localhost:8080/cometd /chat/**' 2>&1 | grep 'State updated'
[main] DEBUG org.cometd.client.BayeuxClient.437da279 - State updated: DISCONNECTED -> HANDSHAKING
[OkHttp http://localhost:8080/...] DEBUG org.cometd.client.BayeuxClient.437da279 - State updated: HANDSHAKING -> HANDSHAKEN
[OkHttp http://localhost:8080/...] DEBUG org.cometd.client.BayeuxClient.437da279 - State updated: HANDSHAKEN -> CONNECTING
[OkHttp http://localhost:8080/...] DEBUG org.cometd.client.BayeuxClient.437da279 - State updated: CONNECTING -> CONNECTED
[OkHttp http://localhost:8080/...] DEBUG org.cometd.client.BayeuxClient.437da279 - State updated: CONNECTED -> CONNECTED
[OkHttp http://localhost:8080/...] DEBUG org.cometd.client.BayeuxClient.437da279 - State updated: CONNECTED -> UNCONNECTED
[pool-1-thread-1] DEBUG org.cometd.client.BayeuxClient.437da279 - State updated: UNCONNECTED -> UNCONNECTED
[pool-1-thread-1] DEBUG org.cometd.client.BayeuxClient.437da279 - State updated: UNCONNECTED -> UNCONNECTED
[OkHttp http://localhost:8080/...] DEBUG org.cometd.client.BayeuxClient.437da279 - State updated: UNCONNECTED -> REHANDSHAKING
[OkHttp http://localhost:8080/...] DEBUG org.cometd.client.BayeuxClient.437da279 - State updated: REHANDSHAKING -> HANDSHAKEN
[OkHttp http://localhost:8080/...] DEBUG org.cometd.client.BayeuxClient.437da279 - State updated: HANDSHAKEN -> CONNECTING
[OkHttp http://localhost:8080/...] DEBUG org.cometd.client.BayeuxClient.437da279 - State updated: CONNECTING -> CONNECTED
leftiness commented 3 years ago

Don't use a Gradle project property. Use java -D.

[brandon@localhost cometd-client]$ JAVA_OPTS='-Dorg.slf4j.simpleLogger.defaultLogLevel=debug' ./app/build/distributions/app/bin/app subscribe http://localhost:8080/cometd /chat/**/ 2>&1 | grep 'State updated'
[main] DEBUG org.cometd.client.BayeuxClient.1725dc0f - State updated: DISCONNECTED -> HANDSHAKING
[OkHttp http://localhost:8080/...] DEBUG org.cometd.client.BayeuxClient.1725dc0f - State updated: HANDSHAKING -> HANDSHAKEN
[OkHttp http://localhost:8080/...] DEBUG org.cometd.client.BayeuxClient.1725dc0f - State updated: HANDSHAKEN -> CONNECTING
[OkHttp http://localhost:8080/...] DEBUG org.cometd.client.BayeuxClient.1725dc0f - State updated: CONNECTING -> CONNECTED
leftiness commented 3 years ago

Now I have tests for SubscribeCommand. Kind of repetitive. Maybe I want to use parameterized tests, but I need to figure out Java modules.

[brandon@localhost cometd-client]$ ./gradlew test

> Configure project :app
Project :app => 'cometd.client' Java module

BUILD SUCCESSFUL in 408ms
3 actionable tasks: 3 up-to-date