Main lane

This commit is contained in:
Andrea Cavalli 2022-09-22 16:05:56 +02:00
parent 83c064220f
commit b322400d87
4 changed files with 11 additions and 3 deletions

View File

@ -1,5 +1,6 @@
package it.tdlight.reactiveapi; package it.tdlight.reactiveapi;
import static it.tdlight.reactiveapi.Lanes.MAIN_LANE;
import static java.util.Collections.unmodifiableSet; import static java.util.Collections.unmodifiableSet;
import it.tdlight.reactiveapi.CreateSessionRequest.CreateBotSessionRequest; import it.tdlight.reactiveapi.CreateSessionRequest.CreateBotSessionRequest;
@ -114,7 +115,7 @@ public class Cli {
if (parts.length == 4) { if (parts.length == 4) {
lane = parts[3]; lane = parts[3];
} else { } else {
lane = ""; lane = MAIN_LANE;
} }
CreateSessionRequest request = switch (parts[0]) { CreateSessionRequest request = switch (parts[0]) {
case "bot" -> new CreateBotSessionRequest(Long.parseLong(parts[1]), parts[2], lane); case "bot" -> new CreateBotSessionRequest(Long.parseLong(parts[1]), parts[2], lane);

View File

@ -1,5 +1,7 @@
package it.tdlight.reactiveapi; package it.tdlight.reactiveapi;
import static it.tdlight.reactiveapi.Lanes.MAIN_LANE;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonInclude.Include;
@ -23,7 +25,7 @@ public class DiskSession {
@JsonProperty("lane") @Nullable String lane) { @JsonProperty("lane") @Nullable String lane) {
this.token = token; this.token = token;
this.phoneNumber = phoneNumber; this.phoneNumber = phoneNumber;
this.lane = Objects.requireNonNullElse(lane, ""); this.lane = Objects.requireNonNullElse(lane, MAIN_LANE);
this.validate(); this.validate();
} }

View File

@ -16,7 +16,7 @@ public record KafkaParameters(String groupId, String clientId, String bootstrapS
public Set<String> getAllLanes() { public Set<String> getAllLanes() {
var lanes = new LinkedHashSet<String>(this.lanes.size() + 1); var lanes = new LinkedHashSet<String>(this.lanes.size() + 1);
lanes.add(""); lanes.add("main");
lanes.addAll(this.lanes); lanes.addAll(this.lanes);
return lanes; return lanes;
} }

View File

@ -0,0 +1,5 @@
package it.tdlight.reactiveapi;
public class Lanes {
public static final String MAIN_LANE = "main";
}