-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComfyClientConfig.java
More file actions
53 lines (47 loc) · 1.74 KB
/
Copy pathComfyClientConfig.java
File metadata and controls
53 lines (47 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Copyright (c) 2018-present, easy-4-java (https://github.com/easy-4-java).
*
* Licensed under the Apache License, Version 2.0 (the "License");
*/
package io.github.easy4j.comfy;
import java.util.Map;
import java.util.Objects;
import lombok.Data;
/**
* Runtime configuration for the local {@code comfy} CLI subprocess route.
*
* <p>Credentials belong in {@link #environment}, never in argv, because
* command-line arguments can be visible to other local processes.</p>
*/
@Data
public class ComfyClientConfig {
private String localExecutable = "comfy";
private Map<String, String> environment;
private int localTimeoutSeconds = 600;
private int localProbeTimeoutSeconds = 5;
private int maxOutputBytes = 16 * 1024 * 1024;
private String defaultWhere;
public void validate() {
Objects.requireNonNull(localExecutable, "localExecutable");
if (localExecutable.trim().isEmpty()) {
throw new IllegalStateException("localExecutable must not be blank");
}
if (localTimeoutSeconds <= 0) {
throw new IllegalStateException("localTimeoutSeconds must be > 0");
}
if (localProbeTimeoutSeconds <= 0) {
throw new IllegalStateException("localProbeTimeoutSeconds must be > 0");
}
if (maxOutputBytes == 0 || maxOutputBytes < -1) {
throw new IllegalStateException("maxOutputBytes must be -1 (unbounded) or > 0");
}
if (defaultWhere != null) {
requireWhere(defaultWhere);
}
}
public static void requireWhere(String where) {
if (!"local".equals(where) && !"cloud".equals(where)) {
throw new IllegalArgumentException("where must be 'local' or 'cloud': " + where);
}
}
}