66package io .opentelemetry .opamp .client .internal ;
77
88import io .opentelemetry .opamp .client .internal .response .MessageData ;
9+ import java .io .Closeable ;
910import javax .annotation .Nullable ;
1011import opamp .proto .AgentDescription ;
1112import opamp .proto .RemoteConfigStatus ;
1213import opamp .proto .ServerErrorResponse ;
1314
14- public interface OpampClient {
15+ public interface OpampClient extends Closeable {
1516
1617 static OpampClientBuilder builder () {
1718 return new OpampClientBuilder ();
1819 }
1920
2021 /**
21- * Starts the client and begin attempts to connect to the Server. Once connection is established
22- * the client will attempt to maintain it by reconnecting if the connection is lost. All failed
23- * connection attempts will be reported via {@link Callbacks#onConnectFailed(Throwable)} callback.
24- *
25- * <p>This method does not wait until the connection to the Server is established and will likely
26- * return before the connection attempts are even made.
27- *
28- * <p>This method may be called only once.
29- *
30- * @param callbacks The Callback to which the Client will notify about any Server requests and
31- * responses.
32- */
33- void start (Callbacks callbacks );
34-
35- /**
36- * Stops the client. May be called only after {@link #start(Callbacks)}. May be called only once.
37- * After this call returns successfully it is guaranteed that no callbacks will be called. Once
38- * stopped, the client cannot be started again.
39- */
40- void stop ();
41-
42- /**
43- * Sets attributes of the Agent. The attributes will be included in the next status report sent to
44- * the Server. When called after {@link #start(Callbacks)}, the attributes will be included in the
45- * next outgoing status report. This is typically used by Agents which allow their
46- * AgentDescription to change dynamically while the OpAMPClient is started. May be also called
47- * from {@link Callbacks#onMessage(MessageData)}.
22+ * Sets attributes of the Agent. The attributes will be included in the next outgoing status
23+ * report. This is typically used by Agents which allow their AgentDescription to change
24+ * dynamically while the OpAMPClient is started. May be also called from {@link
25+ * Callbacks#onMessage(MessageData)}.
4826 *
4927 * @param agentDescription The new agent description.
5028 */
@@ -59,16 +37,14 @@ static OpampClientBuilder builder() {
5937
6038 interface Callbacks {
6139 /**
62- * Called when the connection is successfully established to the Server. May be called after
63- * {@link #start(Callbacks)} is called and every time a connection is established to the Server.
64- * For WebSocket clients this is called after the handshake is completed without any error. For
65- * HTTP clients this is called for any request if the response status is OK.
40+ * Called when the connection is successfully established to the Server. For WebSocket clients
41+ * this is called after the handshake is completed without any error. For HTTP clients this is
42+ * called for any request if the response status is OK.
6643 */
6744 void onConnect ();
6845
6946 /**
70- * Called when the connection to the Server cannot be established. May be called after {@link
71- * #start(Callbacks)} is called and tries to connect to the Server. May also be called if the
47+ * Called when the connection to the Server cannot be established. May also be called if the
7248 * connection is lost and reconnection attempt fails.
7349 *
7450 * @param throwable The exception.
0 commit comments