Skip to content

Commit 7149282

Browse files
authored
Merge pull request #1447 from lowcoder-org/feature/deploymentid
add deploymentid into events published
2 parents 7d8efc0 + 5738280 commit 7149282

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

server/api-service/lowcoder-infra/src/main/java/org/lowcoder/infra/event/AbstractEvent.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.lowcoder.infra.event;
22

33
import lombok.Getter;
4+
import lombok.Setter;
45
import lombok.experimental.SuperBuilder;
56
import org.lowcoder.plugin.api.event.LowcoderEvent;
67

@@ -18,6 +19,8 @@ public abstract class AbstractEvent implements LowcoderEvent
1819
protected final Boolean isAnonymous;
1920
private final String ipAddress;
2021
protected Map<String, Object> details;
22+
@Setter
23+
private static String deploymentID;
2124

2225
public Map<String, Object> details()
2326
{
@@ -33,6 +36,7 @@ public B detail(String name, String value)
3336
details = new HashMap<>();
3437
}
3538
this.details.put(name, value);
39+
this.details.put("deploymentID", deploymentID);
3640
return self();
3741
}
3842
}
@@ -51,5 +55,6 @@ public void populateDetails() {
5155
}
5256

5357
}
58+
details.put("deploymentID", deploymentID);
5459
}
5560
}

server/api-service/lowcoder-server/src/main/java/org/lowcoder/runner/eventlistener/AppEventListener.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
package org.lowcoder.runner.eventlistener;
22

3+
import lombok.RequiredArgsConstructor;
4+
import org.lowcoder.infra.config.model.ServerConfig;
5+
import org.lowcoder.infra.config.repository.ServerConfigRepository;
6+
import org.lowcoder.infra.event.AbstractEvent;
37
import org.lowcoder.sdk.exception.BizError;
48
import org.springframework.boot.context.event.ApplicationReadyEvent;
59
import org.springframework.context.event.EventListener;
610
import org.springframework.stereotype.Component;
711

812
import lombok.extern.slf4j.Slf4j;
13+
import reactor.core.publisher.Mono;
914

1015
@Slf4j
1116
@Component
17+
@RequiredArgsConstructor
1218
public class AppEventListener {
1319

20+
private final ServerConfigRepository serverConfigRepository;
1421
@EventListener
1522
public void onApplicationEvent(ApplicationReadyEvent event) {
1623
System.out.println(
@@ -23,5 +30,7 @@ public void onApplicationEvent(ApplicationReadyEvent event) {
2330
"""
2431
);
2532
log.info("check BizError duplicates: {}", BizError.values().length);
33+
String deploymentId = (String)(serverConfigRepository.findByKey("deployment.id").map(ServerConfig::getValue).switchIfEmpty(Mono.just("")).block());
34+
AbstractEvent.setDeploymentID(deploymentId);
2635
}
2736
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy