66package io .opentelemetry .opamp .client .internal ;
77
88import io .opentelemetry .opamp .client .internal .response .MessageData ;
9+ import javax .annotation .Nullable ;
910import opamp .proto .AgentDescription ;
1011import opamp .proto .RemoteConfigStatus ;
1112import opamp .proto .ServerErrorResponse ;
1213
1314public interface OpampClient {
1415
16+ static OpampClientBuilder builder () {
17+ return new OpampClientBuilder ();
18+ }
19+
1520 /**
1621 * Starts the client and begin attempts to connect to the Server. Once connection is established
1722 * the client will attempt to maintain it by reconnecting if the connection is lost. All failed
18- * connection attempts will be reported via {@link Callbacks#onConnectFailed(OpampClient,
19- * Throwable)} callback.
23+ * connection attempts will be reported via {@link Callbacks#onConnectFailed(Throwable)} callback.
2024 *
2125 * <p>This method does not wait until the connection to the Server is established and will likely
2226 * return before the connection attempts are even made.
@@ -40,7 +44,7 @@ public interface OpampClient {
4044 * the Server. When called after {@link #start(Callbacks)}, the attributes will be included in the
4145 * next outgoing status report. This is typically used by Agents which allow their
4246 * AgentDescription to change dynamically while the OpAMPClient is started. May be also called
43- * from {@link Callbacks#onMessage(OpampClient, MessageData)}.
47+ * from {@link Callbacks#onMessage(MessageData)}.
4448 *
4549 * @param agentDescription The new agent description.
4650 */
@@ -59,31 +63,27 @@ interface Callbacks {
5963 * {@link #start(Callbacks)} is called and every time a connection is established to the Server.
6064 * For WebSocket clients this is called after the handshake is completed without any error. For
6165 * HTTP clients this is called for any request if the response status is OK.
62- *
63- * @param client The relevant {@link OpampClient} instance.
6466 */
65- void onConnect (OpampClient client );
67+ void onConnect ();
6668
6769 /**
6870 * Called when the connection to the Server cannot be established. May be called after {@link
6971 * #start(Callbacks)} is called and tries to connect to the Server. May also be called if the
7072 * connection is lost and reconnection attempt fails.
7173 *
72- * @param client The relevant {@link OpampClient} instance.
7374 * @param throwable The exception.
7475 */
75- void onConnectFailed (OpampClient client , Throwable throwable );
76+ void onConnectFailed (@ Nullable Throwable throwable );
7677
7778 /**
7879 * Called when the Server reports an error in response to some previously sent request. Useful
7980 * for logging purposes. The Agent should not attempt to process the error by reconnecting or
8081 * retrying previous operations. The client handles the ErrorResponse_UNAVAILABLE case
8182 * internally by performing retries as necessary.
8283 *
83- * @param client The relevant {@link OpampClient} instance.
8484 * @param errorResponse The error returned by the Server.
8585 */
86- void onErrorResponse (OpampClient client , ServerErrorResponse errorResponse );
86+ void onErrorResponse (ServerErrorResponse errorResponse );
8787
8888 /**
8989 * Called when the Agent receives a message that needs processing. See {@link MessageData}
@@ -94,9 +94,8 @@ interface Callbacks {
9494 * onMessage returns. This is advisable if processing can take a long time. In that case
9595 * returning quickly is preferable to avoid blocking the {@link OpampClient}.
9696 *
97- * @param client The relevant {@link OpampClient} instance.
9897 * @param messageData The server response data that needs processing.
9998 */
100- void onMessage (OpampClient client , MessageData messageData );
99+ void onMessage (MessageData messageData );
101100 }
102101}
0 commit comments