Skip to content

Commit

Permalink
add some doc
Browse files Browse the repository at this point in the history
  • Loading branch information
YangSen-qn committed Nov 28, 2023
1 parent e1ed20d commit 3340c3e
Show file tree
Hide file tree
Showing 81 changed files with 3,238 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public final class Configuration implements Cloneable {
*/
public int responseTimeout = 10;

/**
* 构造函数
*/
public Configuration() {
}

/**
* Configuration copy
*
Expand Down
21 changes: 21 additions & 0 deletions library/src/main/java/com/qiniu/android/bigdata/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@ public void run() {
});
}

/**
* 异步请求
*
* @param requestBuilder 请求构造器
* @param headers 请求头
* @param upToken 上传 Token
* @param totalSize 请求体大小
* @param complete 结束回调
*/
public void asyncSend(final Request.Builder requestBuilder, StringMap headers, final UpToken upToken,
final long totalSize, final CompletionHandler complete) {
if (headers != null) {
Expand Down Expand Up @@ -287,6 +296,18 @@ public void onResponse(Call call, okhttp3.Response response) throws IOException
});
}

/**
* 异步 POST 请求
*
* @param url 请求 url
* @param body 请求 body
* @param headers 请求 header
* @param upToken 上传 token
* @param totalSize 请求总大小
* @param progressHandler 请求进度回调
* @param completionHandler 结束回调
* @param c 取消回调
*/
public void asyncPost(String url, byte[] body,
StringMap headers, final UpToken upToken,
final long totalSize, ProgressHandler progressHandler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,10 @@ public final class PostArgs {
*/
public String mimeType;

/**
* 构造函数
*/
public PostArgs() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,101 @@
/**
* Created by long on 2017/7/25.
*/

public final class Pipeline {
private static final String HTTPHeaderAuthorization = "Authorization";
private static final String TEXT_PLAIN = "text/plain";
private final Configuration config;
private final Client client;

/**
* 构造函数
*
* @param config config
*/
public Pipeline(Configuration config) {
this.config = Configuration.copy(config);
this.client = new Client(this.config.proxy, this.config.connectTimeout, this.config.responseTimeout, null, null);
}

/**
* pump
*
* @param repo repo
* @param data data
* @param token token
* @param handler handler
* @param <V> V
*/
public <V> void pump(String repo, Map<String, V> data, String token, PumpCompleteHandler handler) {
StringBuilder b = new StringBuilder();
Points.formatPoint(data, b);
send(repo, b, token, handler);
}

/**
* pump
*
* @param repo repo
* @param data data
* @param token token
* @param handler handler
*/
public void pump(String repo, Object data, String token, PumpCompleteHandler handler) {
StringBuilder b = new StringBuilder();
Points.formatPoint(data, b);
send(repo, b, token, handler);
}

/**
* pumpMulti
*
* @param repo repo
* @param data data
* @param token token
* @param handler handler
* @param <V> V
*/
public <V> void pumpMulti(String repo, Map<String, V>[] data, String token, PumpCompleteHandler handler) {
StringBuilder b = Points.formatPoints(data);
send(repo, b, token, handler);
}

/**
* pumpMultiObjects
*
* @param repo repo
* @param data data
* @param token token
* @param handler handler
*/
public void pumpMultiObjects(String repo, Object[] data, String token, PumpCompleteHandler handler) {
StringBuilder b = Points.formatPoints(data);
send(repo, b, token, handler);
}

/**
* pumpMultiObjects
*
* @param repo repo
* @param data data
* @param token token
* @param handler handler
* @param <V> V
*/
public <V> void pumpMultiObjects(String repo, List<V> data, String token, PumpCompleteHandler handler) {
StringBuilder b = Points.formatPointsObjects(data);
send(repo, b, token, handler);
}

/**
* pumpMulti
*
* @param repo repo
* @param data data
* @param token token
* @param handler handler
* @param <V> V
*/
public <V> void pumpMulti(String repo, List<Map<String, V>> data, String token, PumpCompleteHandler handler) {
StringBuilder b = Points.formatPoints(data);
send(repo, b, token, handler);
Expand Down Expand Up @@ -86,7 +142,16 @@ private String url(String repo) {
return config.pipelineHost + "/v2/repos/" + repo + "/data";
}

/**
* Pump 完成回调
*/
public interface PumpCompleteHandler {

/**
* Pump 完成回调
*
* @param info info
*/
void complete(ResponseInfo info);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
* 数据点
*/
public final class Points {

private Points() {
}

private static String buildString(Object v) {
if (v == null) {
return null;
Expand All @@ -41,6 +45,14 @@ private static String buildString(Object v) {
return str;
}

/**
* formatPoint
*
* @param data data
* @param builder builder
* @return StringBuilder
* @param <V> V
*/
public static <V> StringBuilder formatPoint(Map<String, V> data, StringBuilder builder) {
for (Map.Entry<String, V> it : data.entrySet()) {
builder.append(it.getKey()).append("=").append(buildString(it.getValue())).append("\t");
Expand All @@ -49,6 +61,13 @@ public static <V> StringBuilder formatPoint(Map<String, V> data, StringBuilder b
return builder;
}

/**
* formatPoint
*
* @param obj obj
* @param builder builder
* @return StringBuilder
*/
public static StringBuilder formatPoint(Object obj, StringBuilder builder) {
Class cls = obj.getClass();
java.lang.reflect.Field[] fields = cls.getDeclaredFields();
Expand All @@ -67,6 +86,13 @@ public static StringBuilder formatPoint(Object obj, StringBuilder builder) {
return formatPoint(map, builder);
}

/**
* formatPoint
*
* @param data data
* @return StringBuilder
* @param <V> V
*/
public static <V> StringBuilder formatPoints(Map<String, V>[] data) {
StringBuilder builder = new StringBuilder();
for (Map<String, V> aData : data) {
Expand All @@ -75,7 +101,12 @@ public static <V> StringBuilder formatPoints(Map<String, V>[] data) {
return builder;
}


/**
* formatPoint
*
* @param data data
* @return StringBuilder
*/
public static StringBuilder formatPoints(Object[] data) {
StringBuilder builder = new StringBuilder();
for (Object aData : data) {
Expand All @@ -84,6 +115,13 @@ public static StringBuilder formatPoints(Object[] data) {
return builder;
}

/**
* formatPoints
*
* @param data data
* @return StringBuilder
* @param <V> V
*/
public static <V> StringBuilder formatPoints(List<Map<String, V>> data) {
StringBuilder builder = new StringBuilder();
for (Map<String, V> aData : data) {
Expand All @@ -93,6 +131,13 @@ public static <V> StringBuilder formatPoints(List<Map<String, V>> data) {
}


/**
* formatPointsObjects
*
* @param data data
* @return StringBuilder
* @param <V> V
*/
public static <V> StringBuilder formatPointsObjects(List<V> data) {
StringBuilder builder = new StringBuilder();
for (Object aData : data) {
Expand Down
14 changes: 11 additions & 3 deletions library/src/main/java/com/qiniu/android/collect/ReportConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import com.qiniu.android.common.Config;
import com.qiniu.android.utils.Utils;

/**
* 记录配置
*/
public class ReportConfig {

/**
Expand All @@ -16,7 +19,7 @@ public class ReportConfig {
public double interval;

/**
* 记录文件大于 uploadThreshold 会触发上传,单位:字节 默认为16 * 1024
* 记录文件大于 uploadThreshold 会触发上传,单位:字节 默认为16 * 1024
*/
public long uploadThreshold;

Expand All @@ -42,7 +45,7 @@ public class ReportConfig {

private static ReportConfig instance = new ReportConfig();

private ReportConfig(){
private ReportConfig() {
this.isReportEnable = Config.isRecord;
this.interval = Config.interval;
this.serverURL = Config.upLogURL;
Expand All @@ -56,7 +59,12 @@ private ReportConfig(){
this.timeoutInterval = 10;
}

public static ReportConfig getInstance(){
/**
* 获取配置单例
*
* @return 配置单例
*/
public static ReportConfig getInstance() {
return instance;
}
}
Loading

0 comments on commit 3340c3e

Please sign in to comment.