#
cl
20 小时以前 35d8c09fd1ea3f72684c5921939fa20c92bd330b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.vincent.rsf.httpaudit.service;
 
import com.vincent.rsf.httpaudit.entity.HttpAuditLog;
import org.springframework.scheduling.annotation.Async;
 
import java.util.List;
 
/**
 * 异步写入已配置的日志目标;单路失败不影响其他路与业务
 */
public class HttpAuditAsyncRecorder {
 
    private final List<HttpAuditLogSink> sinks;
 
    public HttpAuditAsyncRecorder(List<HttpAuditLogSink> sinks) {
        this.sinks = sinks;
    }
 
    @Async("httpAuditExecutor")
    public void save(HttpAuditLog entity) {
        for (HttpAuditLogSink sink : sinks) {
            sink.write(entity);
        }
    }
}