6
6
package io .opentelemetry .opamp .client .internal ;
7
7
8
8
import io .opentelemetry .opamp .client .internal .response .MessageData ;
9
+ import javax .annotation .Nullable ;
9
10
import opamp .proto .AgentDescription ;
10
11
import opamp .proto .RemoteConfigStatus ;
11
12
import opamp .proto .ServerErrorResponse ;
12
13
13
14
public interface OpampClient {
14
15
16
+ static OpampClientBuilder builder () {
17
+ return new OpampClientBuilder ();
18
+ }
19
+
15
20
/**
16
21
* Starts the client and begin attempts to connect to the Server. Once connection is established
17
22
* 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.
20
24
*
21
25
* <p>This method does not wait until the connection to the Server is established and will likely
22
26
* return before the connection attempts are even made.
@@ -40,7 +44,7 @@ public interface OpampClient {
40
44
* the Server. When called after {@link #start(Callbacks)}, the attributes will be included in the
41
45
* next outgoing status report. This is typically used by Agents which allow their
42
46
* 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)}.
44
48
*
45
49
* @param agentDescription The new agent description.
46
50
*/
@@ -59,31 +63,27 @@ interface Callbacks {
59
63
* {@link #start(Callbacks)} is called and every time a connection is established to the Server.
60
64
* For WebSocket clients this is called after the handshake is completed without any error. For
61
65
* HTTP clients this is called for any request if the response status is OK.
62
- *
63
- * @param client The relevant {@link OpampClient} instance.
64
66
*/
65
- void onConnect (OpampClient client );
67
+ void onConnect ();
66
68
67
69
/**
68
70
* Called when the connection to the Server cannot be established. May be called after {@link
69
71
* #start(Callbacks)} is called and tries to connect to the Server. May also be called if the
70
72
* connection is lost and reconnection attempt fails.
71
73
*
72
- * @param client The relevant {@link OpampClient} instance.
73
74
* @param throwable The exception.
74
75
*/
75
- void onConnectFailed (OpampClient client , Throwable throwable );
76
+ void onConnectFailed (@ Nullable Throwable throwable );
76
77
77
78
/**
78
79
* Called when the Server reports an error in response to some previously sent request. Useful
79
80
* for logging purposes. The Agent should not attempt to process the error by reconnecting or
80
81
* retrying previous operations. The client handles the ErrorResponse_UNAVAILABLE case
81
82
* internally by performing retries as necessary.
82
83
*
83
- * @param client The relevant {@link OpampClient} instance.
84
84
* @param errorResponse The error returned by the Server.
85
85
*/
86
- void onErrorResponse (OpampClient client , ServerErrorResponse errorResponse );
86
+ void onErrorResponse (ServerErrorResponse errorResponse );
87
87
88
88
/**
89
89
* Called when the Agent receives a message that needs processing. See {@link MessageData}
@@ -94,9 +94,8 @@ interface Callbacks {
94
94
* onMessage returns. This is advisable if processing can take a long time. In that case
95
95
* returning quickly is preferable to avoid blocking the {@link OpampClient}.
96
96
*
97
- * @param client The relevant {@link OpampClient} instance.
98
97
* @param messageData The server response data that needs processing.
99
98
*/
100
- void onMessage (OpampClient client , MessageData messageData );
99
+ void onMessage (MessageData messageData );
101
100
}
102
101
}
0 commit comments