asset workspace progress
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package p.packer.events;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PackerEvent(
|
||||
String projectId,
|
||||
String operationId,
|
||||
long sequence,
|
||||
PackerEventKind kind,
|
||||
Instant timestamp,
|
||||
String summary,
|
||||
PackerProgress progress,
|
||||
List<String> affectedAssets) {
|
||||
|
||||
public PackerEvent {
|
||||
projectId = Objects.requireNonNull(projectId, "projectId").trim();
|
||||
operationId = Objects.requireNonNull(operationId, "operationId").trim();
|
||||
Objects.requireNonNull(kind, "kind");
|
||||
timestamp = Objects.requireNonNull(timestamp, "timestamp");
|
||||
summary = Objects.requireNonNull(summary, "summary").trim();
|
||||
affectedAssets = List.copyOf(Objects.requireNonNull(affectedAssets, "affectedAssets"));
|
||||
if (projectId.isBlank() || operationId.isBlank() || summary.isBlank()) {
|
||||
throw new IllegalArgumentException("projectId, operationId, and summary must not be blank");
|
||||
}
|
||||
if (sequence < 0L) {
|
||||
throw new IllegalArgumentException("sequence must not be negative");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package p.packer.events;
|
||||
|
||||
public enum PackerEventKind {
|
||||
ASSET_DISCOVERED,
|
||||
DIAGNOSTICS_UPDATED,
|
||||
ACTION_APPLIED,
|
||||
ACTION_FAILED
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package p.packer.events;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PackerEventSink {
|
||||
void publish(PackerEvent event);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package p.packer.events;
|
||||
|
||||
public record PackerProgress(
|
||||
double value,
|
||||
boolean indeterminate) {
|
||||
|
||||
public PackerProgress {
|
||||
if (!indeterminate && (value < 0.0 || value > 1.0)) {
|
||||
throw new IllegalArgumentException("value must be between 0.0 and 1.0 when determinate");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user