File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
server/api-service/lowcoder-infra
src/main/java/org/lowcoder/infra/serverlog Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 127
127
<groupId >org.springframework.boot</groupId >
128
128
<artifactId >spring-boot-starter-webflux</artifactId >
129
129
</dependency >
130
+ <dependency >
131
+ <groupId >org.lowcoder.plugin</groupId >
132
+ <artifactId >lowcoder-plugin-api</artifactId >
133
+ <version >2.1.0</version >
134
+ <scope >compile</scope >
135
+ </dependency >
130
136
131
137
</dependencies >
132
138
Original file line number Diff line number Diff line change 8
8
9
9
import org .apache .commons .collections4 .CollectionUtils ;
10
10
import org .lowcoder .infra .perf .PerfHelper ;
11
+ import org .lowcoder .plugin .events .ServerLogEvent ;
11
12
import org .springframework .beans .factory .annotation .Autowired ;
13
+ import org .springframework .context .ApplicationEventPublisher ;
12
14
import org .springframework .scheduling .annotation .Scheduled ;
13
15
import org .springframework .stereotype .Service ;
14
16
@@ -23,6 +25,9 @@ public class ServerLogService {
23
25
@ Autowired
24
26
private PerfHelper perfHelper ;
25
27
28
+ @ Autowired
29
+ private ApplicationEventPublisher applicationEventPublisher ;
30
+
26
31
private volatile Queue <ServerLog > serverLogs = new ConcurrentLinkedQueue <>();
27
32
28
33
public void record (ServerLog serverLog ) {
@@ -39,7 +44,15 @@ private void scheduledInsert() {
39
44
serverLogRepository .saveAll (tmp )
40
45
.collectList ()
41
46
.subscribe (result -> {
47
+ int count = result .size ();
42
48
perfHelper .count (SERVER_LOG_BATCH_INSERT , Tags .of ("size" , String .valueOf (result .size ())));
49
+ publishServerLogEvent (count );
43
50
});
44
51
}
52
+
53
+ private void publishServerLogEvent (int count ) {
54
+ ServerLogEvent event = new ServerLogEvent ();
55
+ event .setApiCallsCount (count );
56
+ applicationEventPublisher .publishEvent (event );
57
+ }
45
58
}
You can’t perform that action at this time.
0 commit comments