remake of REST Controllers
This commit is contained in:
@@ -5,6 +5,10 @@ import com.htopweb.system.linux.*;
|
|||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
import reactor.core.scheduler.Schedulers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/system")
|
@RequestMapping("/api/system")
|
||||||
@@ -12,9 +16,7 @@ public class SystemMetricsController {
|
|||||||
|
|
||||||
private final SystemMetricsService _systemMetricsService;
|
private final SystemMetricsService _systemMetricsService;
|
||||||
private final LinuxDetailsService _linuxDetailsService;
|
private final LinuxDetailsService _linuxDetailsService;
|
||||||
|
|
||||||
private final CpuDetailsService _cpuDetailsService;
|
private final CpuDetailsService _cpuDetailsService;
|
||||||
|
|
||||||
private final LinuxMemoryService _linuxMemoryService;
|
private final LinuxMemoryService _linuxMemoryService;
|
||||||
private final LinuxDiskService _linuxDiskService;
|
private final LinuxDiskService _linuxDiskService;
|
||||||
private final LinuxNetworkService _linuxNetworkService;
|
private final LinuxNetworkService _linuxNetworkService;
|
||||||
@@ -23,8 +25,9 @@ public class SystemMetricsController {
|
|||||||
SystemMetricsService systemMetricsService,
|
SystemMetricsService systemMetricsService,
|
||||||
LinuxDetailsService linuxDetailsService,
|
LinuxDetailsService linuxDetailsService,
|
||||||
CpuDetailsService cpuDetailsService,
|
CpuDetailsService cpuDetailsService,
|
||||||
LinuxMemoryService linuxMemoryService, LinuxDiskService linuxDiskService, LinuxNetworkService linuxNetworkService
|
LinuxMemoryService linuxMemoryService,
|
||||||
|
LinuxDiskService linuxDiskService,
|
||||||
|
LinuxNetworkService linuxNetworkService
|
||||||
) {
|
) {
|
||||||
_systemMetricsService = systemMetricsService;
|
_systemMetricsService = systemMetricsService;
|
||||||
_linuxDetailsService = linuxDetailsService;
|
_linuxDetailsService = linuxDetailsService;
|
||||||
@@ -35,32 +38,38 @@ public class SystemMetricsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/metrics")
|
@GetMapping("/metrics")
|
||||||
public SystemMetricsResponse getMetrics() {
|
public Mono<SystemMetricsResponse> getMetrics() {
|
||||||
return _systemMetricsService.getMetrics();
|
return Mono.fromCallable(_systemMetricsService::getMetrics)
|
||||||
|
.subscribeOn(Schedulers.boundedElastic());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/linux")
|
@GetMapping("/linux")
|
||||||
public LinuxDetailsResponse getLinuxDetails() {
|
public Mono<LinuxDetailsResponse> getLinuxDetails() {
|
||||||
return _linuxDetailsService.getDetails();
|
return Mono.fromCallable(_linuxDetailsService::getDetails)
|
||||||
|
.subscribeOn(Schedulers.boundedElastic());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/cpu")
|
@GetMapping("/cpu")
|
||||||
public CpuDetailsResponse getCpuDetails() {
|
public Mono<CpuDetailsResponse> getCpuDetails() {
|
||||||
return _cpuDetailsService.getDetails();
|
return Mono.fromCallable(_cpuDetailsService::getDetails)
|
||||||
|
.subscribeOn(Schedulers.boundedElastic());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/linux/memory")
|
@GetMapping("/linux/memory")
|
||||||
public LinuxMemoryResponse getLinuxMemory() {
|
public Mono<LinuxMemoryResponse> getLinuxMemory() {
|
||||||
return _linuxMemoryService.getDetails();
|
return Mono.fromCallable(_linuxMemoryService::getDetails)
|
||||||
|
.subscribeOn(Schedulers.boundedElastic());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/linux/disks")
|
@GetMapping("/linux/disks")
|
||||||
public java.util.List<LinuxDiskResponse> getLinuxDisks() {
|
public Mono<List<LinuxDiskResponse>> getLinuxDisks() {
|
||||||
return _linuxDiskService.getDisks();
|
return Mono.fromCallable(_linuxDiskService::getDisks)
|
||||||
|
.subscribeOn(Schedulers.boundedElastic());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/linux/network")
|
@GetMapping("/linux/network")
|
||||||
public java.util.List<LinuxNetworkResponse> getLinuxNetwork() {
|
public Mono<List<LinuxNetworkResponse>> getLinuxNetwork() {
|
||||||
return _linuxNetworkService.getInterfaces();
|
return Mono.fromCallable(_linuxNetworkService::getInterfaces)
|
||||||
|
.subscribeOn(Schedulers.boundedElastic());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
|
|
||||||
package com.htopweb.system;
|
package com.htopweb.system;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
import reactor.core.scheduler.Schedulers;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -19,7 +22,8 @@ public class SystemProcessesController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/processes")
|
@GetMapping("/processes")
|
||||||
public List<ProcessInfoResponse> getProcesses() {
|
public Mono<List<ProcessInfoResponse>> getProcesses() {
|
||||||
return _systemProcessesService.getProcesses();
|
return Mono.fromCallable(_systemProcessesService::getProcesses)
|
||||||
|
.subscribeOn(Schedulers.boundedElastic());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user