.
This commit is contained in:
parent
aa6c8a57e3
commit
cc402a71e7
4 changed files with 33 additions and 29 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package de.kentoj.scrowlib.servermanager;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.io.Files;
|
||||
import de.kentoj.scrowlib.messaging.DocumentRepository;
|
||||
import de.kentoj.scrowlib.messaging.NatsRepository;
|
||||
import io.nats.client.Connection;
|
||||
|
|
@ -10,8 +9,6 @@ import org.jetbrains.annotations.NotNull;
|
|||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import javax.print.Doc;
|
||||
|
||||
public class CrownServerManager implements ServerManager {
|
||||
|
||||
private final NatsRepository natsRepo;
|
||||
|
|
@ -55,19 +52,15 @@ public class CrownServerManager implements ServerManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Mono<@NotNull String> getState(String handle) {
|
||||
public Mono<@NotNull ServerInstance> getInfo(String handle) {
|
||||
var payload = DocumentRepository.toBytes(new Document("handle", handle));
|
||||
return natsRepo.request("crown.get-state", payload)
|
||||
return natsRepo.request("crown.get-info", payload)
|
||||
.map(DocumentRepository::fromMessage)
|
||||
.map(doc -> doc.getString("state"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<@NotNull Integer> getPort(String handle) {
|
||||
var payload = DocumentRepository.toBytes(new Document("handle", handle));
|
||||
return natsRepo.request("crown.get-port", payload)
|
||||
.map(DocumentRepository::fromMessage)
|
||||
.map(doc -> doc.getInteger("port"));
|
||||
.map(doc -> new ServerInstance(
|
||||
handle,
|
||||
doc.getInteger("port"),
|
||||
doc.getString("state")
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -11,19 +11,17 @@ public interface ServerManager {
|
|||
*/
|
||||
Mono<@NotNull ServerInstance> deployServer(String template);
|
||||
|
||||
/**
|
||||
* @return Flux with handles of running servers
|
||||
*/
|
||||
Flux<@NotNull ServerInstance> getRunningServers();
|
||||
|
||||
/**
|
||||
* Attempts a clean shutdown, if that doesn't succeed, kills the server.
|
||||
*/
|
||||
Mono<@NotNull Void> destroyServer(String handle);
|
||||
|
||||
Mono<@NotNull String> getState(String handle);
|
||||
/**
|
||||
* @return Flux with handles of running servers
|
||||
*/
|
||||
Flux<@NotNull ServerInstance> getRunningServers();
|
||||
|
||||
Mono<@NotNull Integer> getPort(String handle);
|
||||
Mono<@NotNull ServerInstance> getInfo(String handle);
|
||||
|
||||
Mono<@NotNull Void> setState(String handle, String state);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue