Skip to content

Commit

Permalink
Refactor GateClientAbstract and GateClientJobStream constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
namtzigla committed Oct 22, 2024
1 parent 0225245 commit 2265258
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ public abstract class GateClientAbstract implements ApplicationEventListener<Con
*/
public abstract void start();

public GateClientAbstract() {}

public GateClientAbstract(ConfigEvent configEvent) {
this.event = configEvent;
start();
}

/**
* Handles configuration changes.
* @param event The new configuration event.
Expand Down Expand Up @@ -156,7 +163,13 @@ public List<Agent> listAgents() throws UnconfiguredException {
var res = client.listAgents(Service.ListAgentsReq.newBuilder().build());
while (res.hasNext()) {
var r = res.next();
ret.add(new Agent(r.getAgent().getUserId(), r.getAgent().getFirstName(), r.getAgent().getLastName(), r.getAgent().getUsername(), r.getAgent().getPartnerAgentId()));
ret.add(new Agent(
r.getAgent().getUserId(),
r.getAgent().getPartnerAgentId(),
r.getAgent().getUsername(),
r.getAgent().getFirstName(),
r.getAgent().getLastName()
));
}
return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.tcn.exile.gateclients;

import com.tcn.exile.config.ConfigEvent;
import com.tcn.exile.plugin.PluginInterface;
import io.grpc.ManagedChannel;
import io.grpc.stub.StreamObserver;
Expand All @@ -37,7 +38,16 @@ public class GateClientJobStream extends GateClientAbstract implements StreamObs
private StreamObserver<Service.JobStreamRequest> requestObserver;

public GateClientJobStream() {
// throw new RuntimeException("Unimplemented");
log.debug("GateClientJobStream created");
// start();
}

public GateClientJobStream(PluginInterface plugin, ConfigEvent event) {
this.plugin = plugin;
this.event = event;
log.debug("GateClientJobStream created with plugin {}", plugin.getName());
// start();
}

@Override
Expand All @@ -48,6 +58,7 @@ public void start() {

public boolean isRunning() {
if (channel == null) {
log.debug("channel is null, JobStream is not running");
return false;
}
log.debug("channel {} shutdown {} terminated {} -> {}", channel, channel.isShutdown(), channel.isTerminated(), !channel.isShutdown() && !channel.isTerminated());
Expand All @@ -56,6 +67,7 @@ public boolean isRunning() {

public synchronized void eventStream() {
if (!isRunning()) {
log.debug("starting JobStream");
try {
channel = getChannel();
var client = ExileGateServiceGrpc.newStub(channel).withWaitForReady();
Expand Down

0 comments on commit 2265258

Please sign in to comment.