Skip to content

Commit 3c6fc8a

Browse files
feat/support for uncaught exception handling, single interfaces for syn/async http clients, multiple improvements
1 parent c6d5af6 commit 3c6fc8a

24 files changed

Lines changed: 417 additions & 198 deletions

.idea/misc.xml

Lines changed: 10 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 50 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

traceo-sdk-core/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@
6767
<groupId>org.apache.maven.plugins</groupId>
6868
<artifactId>maven-compiler-plugin</artifactId>
6969
<configuration>
70-
<source>11</source>
71-
<target>11</target>
70+
<source>8</source>
71+
<target>8</target>
7272
</configuration>
7373
</plugin>
7474
</plugins>
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
package com.traceo.sdk;
2+
3+
import com.traceo.sdk.http.HttpAsyncClient;
4+
import com.traceo.sdk.http.IHttpClient;
5+
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
9+
/**
10+
* Base client configuration class.
11+
*/
12+
public class ClientOptions {
13+
14+
/**
15+
* Api key generated in Traceo project.
16+
*/
17+
private String apiKey = null;
18+
19+
/**
20+
* The host on which the Traceo instance is running.
21+
* Host should be in format: [protocol]://[domain]:[port]
22+
*/
23+
private String host = null;
24+
25+
/**
26+
* Specifies whether the SDK should be launched. If not then it will not collect any information.
27+
* After changing the settings, it is necessary to restart the entire application.
28+
*/
29+
private boolean isEnabled = true;
30+
31+
/**
32+
* Specifies if SDK should display internal logs.
33+
*/
34+
private boolean isDebug = false;
35+
36+
/**
37+
* Specifies if SDK should catch every uncaught exception.
38+
*/
39+
private boolean isCatchUncaughtException = false;
40+
41+
/**
42+
* List of handlers to run on SDK initialization.
43+
*/
44+
private List<IHandler> handlers = new ArrayList<>();
45+
46+
/**
47+
* Http client used to requests.
48+
*/
49+
private IHttpClient<?,?> httpClient;
50+
51+
public ClientOptions() {}
52+
53+
public ClientOptions(ClientOptions configuration) {
54+
this.apiKey = configuration.getApiKey();
55+
this.host = configuration.getHost();
56+
this.isEnabled = configuration.isEnabled();
57+
this.isDebug = configuration.isDebug();
58+
this.isCatchUncaughtException = configuration.isCatchUncaughtException();
59+
this.handlers = configuration.getHandlers();
60+
this.httpClient = configuration.getHttpClient();
61+
}
62+
63+
public void setHandlers(List<IHandler> handlers) {
64+
this.handlers = handlers;
65+
}
66+
67+
public IHttpClient<?, ?> getHttpClient() {
68+
return httpClient;
69+
}
70+
71+
public void setHttpClient(IHttpClient<?, ?> httpClient) {
72+
this.httpClient = httpClient;
73+
}
74+
75+
public void addHandler(IHandler handler) {
76+
this.handlers.add(handler);
77+
}
78+
79+
public List<IHandler> getHandlers() {
80+
return this.handlers;
81+
}
82+
83+
public boolean isCatchUncaughtException() {
84+
return isCatchUncaughtException;
85+
}
86+
87+
public void setCatchUncaughtException(boolean catchUncaughtException) {
88+
isCatchUncaughtException = catchUncaughtException;
89+
}
90+
91+
public String getApiKey() {
92+
return this.apiKey;
93+
}
94+
95+
public String getHost() {
96+
return this.host;
97+
}
98+
99+
public void setApiKey(String apiKey) {
100+
this.apiKey = apiKey;
101+
}
102+
103+
public void setHost(String host) {
104+
this.host = host;
105+
}
106+
107+
public boolean isEnabled() {
108+
return isEnabled;
109+
}
110+
111+
public void setEnabled(boolean enabled) {
112+
isEnabled = enabled;
113+
}
114+
115+
public boolean isDebug() {
116+
return isDebug;
117+
}
118+
119+
public void setDebug(boolean debug) {
120+
isDebug = debug;
121+
}
122+
}

traceo-sdk-core/src/main/java/com/traceo/sdk/DefaultRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class DefaultRequest<T> implements IRequest<T> {
3030

3131
/**
3232
* Path used to build full URI which is needed for request.
33-
* URI is created with using provided host in {@link com.traceo.sdk.builder.ClientCoreConfiguration} concatenated with this value.
33+
* URI is created with using provided host in {@link ClientOptions} concatenated with this value.
3434
*/
3535
private String endpoint;
3636

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.traceo.sdk;
2+
3+
public interface IHandler {
4+
void run(ClientOptions configs);
5+
}

traceo-sdk-core/src/main/java/com/traceo/sdk/builder/ClientCoreConfiguration.java

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)