Skip to content

Commit

Permalink
Merge pull request #1447 from lowcoder-org/feature/deploymentid
Browse files Browse the repository at this point in the history
add deploymentid into events published
  • Loading branch information
FalkWolsky authored Jan 17, 2025
2 parents 7d8efc0 + 5738280 commit 7149282
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.lowcoder.infra.event;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.lowcoder.plugin.api.event.LowcoderEvent;

Expand All @@ -18,6 +19,8 @@ public abstract class AbstractEvent implements LowcoderEvent
protected final Boolean isAnonymous;
private final String ipAddress;
protected Map<String, Object> details;
@Setter
private static String deploymentID;

public Map<String, Object> details()
{
Expand All @@ -33,6 +36,7 @@ public B detail(String name, String value)
details = new HashMap<>();
}
this.details.put(name, value);
this.details.put("deploymentID", deploymentID);
return self();
}
}
Expand All @@ -51,5 +55,6 @@ public void populateDetails() {
}

}
details.put("deploymentID", deploymentID);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
package org.lowcoder.runner.eventlistener;

import lombok.RequiredArgsConstructor;
import org.lowcoder.infra.config.model.ServerConfig;
import org.lowcoder.infra.config.repository.ServerConfigRepository;
import org.lowcoder.infra.event.AbstractEvent;
import org.lowcoder.sdk.exception.BizError;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;
import reactor.core.publisher.Mono;

@Slf4j
@Component
@RequiredArgsConstructor
public class AppEventListener {

private final ServerConfigRepository serverConfigRepository;
@EventListener
public void onApplicationEvent(ApplicationReadyEvent event) {
System.out.println(
Expand All @@ -23,5 +30,7 @@ public void onApplicationEvent(ApplicationReadyEvent event) {
"""
);
log.info("check BizError duplicates: {}", BizError.values().length);
String deploymentId = (String)(serverConfigRepository.findByKey("deployment.id").map(ServerConfig::getValue).switchIfEmpty(Mono.just("")).block());
AbstractEvent.setDeploymentID(deploymentId);
}
}

0 comments on commit 7149282

Please sign in to comment.