Skip to content

Commit

Permalink
Add metadata in reponse for demo
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzhiguo committed Dec 30, 2024
1 parent 390d473 commit a5475f3
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ public class LiveLocation implements Serializable {
private String ruleId;
private String laneSpaceId;
private String lane;
private String group;
private String ip;

public LiveLocation() {

}

public LiveLocation(String liveSpaceId, String unit, String cell, String cluster, String cloud, String ruleId, String laneSpaceId, String lane) {
public LiveLocation(String liveSpaceId, String unit, String cell, String cluster, String cloud, String ruleId, String laneSpaceId, String lane, String group) {
this.liveSpaceId = liveSpaceId;
this.unit = unit;
this.cell = cell;
Expand All @@ -47,6 +48,7 @@ public LiveLocation(String liveSpaceId, String unit, String cell, String cluster
this.ruleId = ruleId;
this.laneSpaceId = laneSpaceId;
this.lane = lane;
this.group = group;
this.ip = Ipv4.getLocalIp();
}

Expand All @@ -59,7 +61,8 @@ public static LiveLocation build() {
System.getProperty(LiveTransmission.X_LIVE_CLOUD),
System.getProperty(LiveTransmission.X_LIVE_RULE_ID),
System.getProperty(LiveTransmission.X_LANE_SPACE_ID),
System.getProperty(LiveTransmission.X_LANE_CODE)
System.getProperty(LiveTransmission.X_LANE_CODE),
System.getProperty(LiveTransmission.X_SERVICE_GROUP)
);
}

Expand All @@ -74,6 +77,7 @@ public String toString() {
", ruleId=" + (ruleId == null ? "null" : ('\'' + ruleId + '\'')) +
", lane-space-id=" + (laneSpaceId == null ? "null" : ('\'' + laneSpaceId + '\'')) +
", lane=" + (lane == null ? "null" : ('\'' + lane + '\'')) +
", group=" + (group == null ? "null" : ('\'' + group + '\'')) +
", ip=" + (ip == null ? "null" : ('\'' + ip + '\'')) +
'}';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.jd.live.agent.demo.response;

import com.jd.live.agent.core.util.network.Ipv4;
import lombok.Getter;
import lombok.Setter;

Expand All @@ -33,23 +34,32 @@ public class LiveTransmission implements Serializable {
public static final String X_LIVE_UID = "x-live-uid";
public static final String X_LANE_SPACE_ID = "x-lane-space-id";
public static final String X_LANE_CODE = "x-lane-code";
public static final String X_SERVICE_GROUP = "x-service-group";
private String carrier;
private String liveSpaceId;
private String ruleId;
private String uid;
private String laneSpaceId;
private String lane;
private String cluster;
private String cloud;
private String group;
private String ip;

public LiveTransmission() {
}

public LiveTransmission(String carrier, String liveSpaceId, String ruleId, String uid, String laneSpaceId, String lane) {
public LiveTransmission(String carrier, String liveSpaceId, String ruleId, String uid, String laneSpaceId, String lane, String cluster, String cloud, String group) {
this.carrier = carrier;
this.liveSpaceId = liveSpaceId;
this.ruleId = ruleId;
this.uid = uid;
this.laneSpaceId = laneSpaceId;
this.lane = lane;
this.cluster = cluster;
this.cloud = cloud;
this.group = group;
this.ip = Ipv4.getLocalIp();
}

public static LiveTransmission build(String carrier, Function<String, String> tagFunc) {
Expand All @@ -58,7 +68,10 @@ public static LiveTransmission build(String carrier, Function<String, String> ta
tagFunc.apply(X_LIVE_RULE_ID),
tagFunc.apply(X_LIVE_UID),
tagFunc.apply(X_LANE_SPACE_ID),
tagFunc.apply(X_LANE_CODE)
tagFunc.apply(X_LANE_CODE),
tagFunc.apply(X_LIVE_CLUSTER),
tagFunc.apply(X_LIVE_CLOUD),
tagFunc.apply(X_SERVICE_GROUP)
);
}

Expand All @@ -70,6 +83,9 @@ public String toString() {
", x-live-uid=" + (uid == null ? "null" : ('\'' + uid + '\'')) +
", x-lane-space-id=" + (laneSpaceId == null ? "null" : ('\'' + laneSpaceId + '\'')) +
", x-lane-code=" + (lane == null ? "null" : ('\'' + lane + '\'')) +
", x-live-cluster=" + (cluster == null ? "null" : ('\'' + cluster + '\'')) +
", x-live-cloud=" + (cloud == null ? "null" : ('\'' + cloud + '\'')) +
", x-service-group=" + (group == null ? "null" : ('\'' + group + '\'')) +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.jd.live.agent.demo.util;

import com.jd.live.agent.core.util.network.Ipv4;
import lombok.Getter;
import lombok.Setter;

Expand All @@ -26,13 +27,21 @@ public class LiveLocation {
private String cell;
private String laneSpaceId;
private String lane;
private String cluster;
private String cloud;
private String group;
private String ip;

public LiveLocation() {
liveSpaceId = System.getProperty("x-live-space-id");
unit = System.getProperty("x-live-unit");
cell = System.getProperty("x-live-cell");
laneSpaceId = System.getProperty("x-lane-space-id");
lane = System.getProperty("x-lane-code");
cluster = System.getProperty("x-live-cluster");
cloud = System.getProperty("x-live-cloud");
group = System.getProperty("x-service-group");
ip = Ipv4.getLocalIp();
}

@Override
Expand All @@ -43,6 +52,10 @@ public String toString() {
", cell=" + (cell == null ? "null" : ('\'' + cell + '\'')) +
", lane-space-id=" + (laneSpaceId == null ? "null" : ('\'' + laneSpaceId + '\'')) +
", lane=" + (lane == null ? "null" : ('\'' + lane + '\'')) +
", cluster=" + (cluster == null ? "null" : ('\'' + cluster + '\'')) +
", cloud=" + (cloud == null ? "null" : ('\'' + cloud + '\'')) +
", group=" + (group == null ? "null" : ('\'' + group + '\'')) +
", ip=" + (ip == null ? "null" : ('\'' + ip + '\'')) +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
*/
package com.jd.live.agent.demo.util;

import com.jd.live.agent.core.util.network.Ipv4;
import lombok.Getter;
import lombok.Setter;

import java.util.function.Function;

import static com.jd.live.agent.demo.response.LiveTransmission.X_LIVE_CLOUD;
import static com.jd.live.agent.demo.response.LiveTransmission.X_LIVE_CLUSTER;

@Getter
@Setter
public class LiveTransmission {
Expand All @@ -28,20 +32,29 @@ public class LiveTransmission {
public static final String X_LIVE_UID = "x-live-uid";
public static final String X_LANE_SPACE_ID = "x-lane-space-id";
public static final String X_LANE_CODE = "x-lane-code";
public static final String X_SERVICE_GROUP = "x-service-group";
private String carrier;
private String liveSpaceId;
private String ruleId;
private String uid;
private String laneSpaceId;
private String lane;
private String cluster;
private String cloud;
private String group;
private String ip;

public LiveTransmission(String carrier, String liveSpaceId, String ruleId, String uid, String laneSpaceId, String lane) {
public LiveTransmission(String carrier, String liveSpaceId, String ruleId, String uid, String laneSpaceId, String lane, String cluster, String cloud, String group) {
this.carrier = carrier;
this.liveSpaceId = liveSpaceId;
this.ruleId = ruleId;
this.uid = uid;
this.laneSpaceId = laneSpaceId;
this.lane = lane;
this.cluster = cluster;
this.cloud = cloud;
this.group = group;
this.ip = Ipv4.getLocalIp();
}

public LiveTransmission(String carrier, Function<String, String> tagFunc) {
Expand All @@ -51,6 +64,9 @@ public LiveTransmission(String carrier, Function<String, String> tagFunc) {
uid = tagFunc.apply(X_LIVE_UID);
laneSpaceId = tagFunc.apply(X_LANE_SPACE_ID);
lane = tagFunc.apply(X_LANE_CODE);
cluster = tagFunc.apply(X_LIVE_CLUSTER);
cloud = tagFunc.apply(X_LIVE_CLOUD);
group = tagFunc.apply(X_SERVICE_GROUP);
}

@Override
Expand All @@ -61,6 +77,9 @@ public String toString() {
", x-live-uid=" + (uid == null ? "null" : ('\'' + uid + '\'')) +
", x-lane-space-id=" + (laneSpaceId == null ? "null" : ('\'' + laneSpaceId + '\'')) +
", x-lane-code=" + (lane == null ? "null" : ('\'' + lane + '\'')) +
", x-live-cluster=" + (cluster == null ? "null" : ('\'' + cluster + '\'')) +
", x-live-cloud=" + (cloud == null ? "null" : ('\'' + cloud + '\'')) +
", x-service-group=" + (group == null ? "null" : ('\'' + group + '\'')) +
'}';
}
}

0 comments on commit a5475f3

Please sign in to comment.