Skip to content

Commit 543470f

Browse files
committed
Using wire
1 parent c8df521 commit 543470f

File tree

3 files changed

+23
-31
lines changed

3 files changed

+23
-31
lines changed

opamp-client/build.gradle.kts

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import groovy.json.JsonSlurper
55
plugins {
66
id("otel.java-conventions")
77
id("de.undercouch.download") version "5.6.0"
8-
id("com.google.protobuf") version "0.9.4"
8+
id("com.squareup.wire") version "5.3.1"
99
}
1010

1111
description = "Client implementation of the OpAMP spec."
@@ -16,14 +16,6 @@ java {
1616
targetCompatibility = JavaVersion.VERSION_1_8
1717
}
1818

19-
sourceSets {
20-
main {
21-
proto {
22-
srcDir("opamp-spec/proto")
23-
}
24-
}
25-
}
26-
2719
tasks.withType<JavaCompile>().configureEach {
2820
with(options) {
2921
// Suppressing warnings about the usage of deprecated methods.
@@ -32,16 +24,7 @@ tasks.withType<JavaCompile>().configureEach {
3224
}
3325
}
3426

35-
val protobufVersion = "4.28.2"
36-
37-
protobuf {
38-
protoc {
39-
artifact = "com.google.protobuf:protoc:$protobufVersion"
40-
}
41-
}
42-
4327
dependencies {
44-
implementation("com.google.protobuf:protobuf-java:$protobufVersion")
4528
annotationProcessor("com.google.auto.value:auto-value")
4629
compileOnly("com.google.auto.value:auto-value-annotations")
4730
}
@@ -52,7 +35,8 @@ val opampReleaseInfo = tasks.register<Download>("opampLastReleaseInfo") {
5235
dest(project.layout.buildDirectory.file("opamp/release.json"))
5336
}
5437

55-
tasks.register<DownloadOpampProtos>("opampProtoDownload", download).configure {
38+
val opampProtos = tasks.register<DownloadOpampProtos>("opampProtoDownload", download)
39+
opampProtos.configure {
5640
group = "opamp"
5741
dependsOn(opampReleaseInfo)
5842
lastReleaseInfoJson.set {
@@ -62,6 +46,13 @@ tasks.register<DownloadOpampProtos>("opampProtoDownload", download).configure {
6246
downloadedZipFile.set(project.layout.buildDirectory.file("intermediate/$name/release.zip"))
6347
}
6448

49+
wire {
50+
java {}
51+
sourcePath {
52+
srcDir(opampProtos)
53+
}
54+
}
55+
6556
abstract class DownloadOpampProtos @Inject constructor(
6657
private val download: DownloadExtension,
6758
private val archiveOps: ArchiveOperations,

opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/OpampClient.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
package io.opentelemetry.opamp.client.internal;
77

88
import io.opentelemetry.opamp.client.internal.response.MessageData;
9-
import opamp.proto.Opamp;
9+
import opamp.proto.AgentDescription;
10+
import opamp.proto.RemoteConfigStatus;
11+
import opamp.proto.ServerErrorResponse;
1012

1113
public interface OpampClient {
1214

@@ -42,14 +44,14 @@ public interface OpampClient {
4244
*
4345
* @param agentDescription The new agent description.
4446
*/
45-
void setAgentDescription(Opamp.AgentDescription agentDescription);
47+
void setAgentDescription(AgentDescription agentDescription);
4648

4749
/**
4850
* Sets the current remote config status which will be sent in the next agent to server request.
4951
*
5052
* @param remoteConfigStatus The new remote config status.
5153
*/
52-
void setRemoteConfigStatus(Opamp.RemoteConfigStatus remoteConfigStatus);
54+
void setRemoteConfigStatus(RemoteConfigStatus remoteConfigStatus);
5355

5456
interface Callbacks {
5557
/**
@@ -81,17 +83,16 @@ interface Callbacks {
8183
* @param client The relevant {@link OpampClient} instance.
8284
* @param errorResponse The error returned by the Server.
8385
*/
84-
void onErrorResponse(OpampClient client, Opamp.ServerErrorResponse errorResponse);
86+
void onErrorResponse(OpampClient client, ServerErrorResponse errorResponse);
8587

8688
/**
8789
* Called when the Agent receives a message that needs processing. See {@link MessageData}
8890
* definition for the data that may be available for processing. During onMessage execution the
8991
* {@link OpampClient} functions that change the status of the client may be called, e.g. if
90-
* RemoteConfig is processed then {@link
91-
* #setRemoteConfigStatus(opamp.proto.Opamp.RemoteConfigStatus)} should be called to reflect the
92-
* processing result. These functions may also be called after onMessage returns. This is
93-
* advisable if processing can take a long time. In that case returning quickly is preferable to
94-
* avoid blocking the {@link OpampClient}.
92+
* RemoteConfig is processed then {@link #setRemoteConfigStatus(opamp.proto.RemoteConfigStatus)}
93+
* should be called to reflect the processing result. These functions may also be called after
94+
* onMessage returns. This is advisable if processing can take a long time. In that case
95+
* returning quickly is preferable to avoid blocking the {@link OpampClient}.
9596
*
9697
* @param client The relevant {@link OpampClient} instance.
9798
* @param messageData The server response data that needs processing.

opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/response/MessageData.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import com.google.auto.value.AutoValue;
99
import io.opentelemetry.opamp.client.internal.OpampClient;
1010
import javax.annotation.Nullable;
11-
import opamp.proto.Opamp;
11+
import opamp.proto.AgentRemoteConfig;
1212

1313
/**
1414
* Data class provided in {@link OpampClient.Callbacks#onMessage(OpampClient, MessageData)} with
@@ -17,15 +17,15 @@
1717
@AutoValue
1818
public abstract class MessageData {
1919
@Nullable
20-
public abstract Opamp.AgentRemoteConfig getRemoteConfig();
20+
public abstract AgentRemoteConfig getRemoteConfig();
2121

2222
public static Builder builder() {
2323
return new AutoValue_MessageData.Builder();
2424
}
2525

2626
@AutoValue.Builder
2727
public abstract static class Builder {
28-
public abstract Builder setRemoteConfig(Opamp.AgentRemoteConfig remoteConfig);
28+
public abstract Builder setRemoteConfig(AgentRemoteConfig remoteConfig);
2929

3030
public abstract MessageData build();
3131
}

0 commit comments

Comments
 (0)