-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add onKeyExchanged listener on PrometheusRSocketClient, improve closi…
…ng of stale rsockets in proxy
- Loading branch information
Jon Schneider
committed
Apr 7, 2020
1 parent
f954f2d
commit af4a01a
Showing
4 changed files
with
129 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
client/src/test/java/io/micrometer/prometheus/rsocket/SampleClientThatClosesManually.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright 2019 Pivotal Software, Inc. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.micrometer.prometheus.rsocket; | ||
|
||
import io.micrometer.core.instrument.Counter; | ||
import io.micrometer.prometheus.PrometheusConfig; | ||
import io.micrometer.prometheus.PrometheusMeterRegistry; | ||
import io.rsocket.transport.netty.client.WebsocketClientTransport; | ||
import reactor.core.publisher.Flux; | ||
|
||
import java.lang.management.ManagementFactory; | ||
import java.time.Duration; | ||
import java.util.Random; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class SampleClientThatClosesManually { | ||
public static void main(String[] args) throws InterruptedException { | ||
PrometheusMeterRegistry meterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); | ||
meterRegistry.config().commonTags("process.id", ManagementFactory.getRuntimeMXBean().getName()); | ||
|
||
CountDownLatch keyExchanges = new CountDownLatch(1); | ||
|
||
PrometheusRSocketClient client = new PrometheusRSocketClient(meterRegistry, | ||
WebsocketClientTransport.create("localhost", 8081), | ||
c -> c.retry(Long.MAX_VALUE), | ||
keyExchanges::countDown); | ||
|
||
Random r = new Random(); | ||
|
||
Counter counter = meterRegistry.counter("my.counter", "instance", Integer.toString(r.nextInt(10))); | ||
counter.increment(); | ||
|
||
keyExchanges.await(10, TimeUnit.SECONDS); | ||
client.pushAndClose(); | ||
|
||
Flux.interval(Duration.ofSeconds(1)).blockLast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters