Add this Maven plugin to your project to enable automatic validation of JVM tests against our standards:
<plugin>
<groupId>uk.co.crunch</groupId>
<artifactId>crunch-tests-maven-plugin</artifactId>
</plugin>
Wire is an independent implementation of the Protocol Buffers schema language and binary encoding from Square that’s specifically designed for Android, Java, and Kotlin.
When Square decided they could not maintain Wire’s existing Maven plugin and removed it from their repo with version 3.0.3, we re-implemented it in our fork, and brought it up to the latest v. 3.2.2.
We use this in many of our busiest services for schema-driven inter-service messaging, as follows:
<dependency>
<groupId>com.squareup.wire</groupId>
<artifactId>wire-runtime</artifactId>
<version>3.2.2</version>
</dependency>
[...]
<plugin>
<groupId>uk.co.crunch</groupId>
<artifactId>wire-maven-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<configuration>
<protoPaths>${basedir}/shared-message-schemas</protoPaths>
<protoFiles>
<param>uk/co/crunch/example.proto</param>
</protoFiles>
</configuration>
</execution>
</executions>
</plugin>
class Example {
private final PrometheusMetrics metrics;
public void onUserLogin(Object event) {
metrics.gauge("Sessions.open").inc();
metrics.counter("Sessions.total").inc();
}
public String handleLogin() {
try (Context timer = metrics.summary("Sessions.handleLogin").time()) {
return "Login handled!";
}
}
}
class Example(private val metrics: PrometheusMetrics) {
fun onUserLogin(event: Any) {
metrics.gauge("Sessions.open").inc()
}
fun onUserLogout(event: Any) {
metrics.gauge("Sessions.open").dec()
}
fun onError(event: Any) {
metrics.error("generic", "Generic errors")
}
fun handleLogin(): String {
metrics.timer("Sessions.handleLogin").time().use { return "Login handled!" }
}
}