Skip to content

Commit 96575b2

Browse files
authored
Merge pull request #6 from muverystrong/feat/add-expire-time
feat: queue task add expireTime property
2 parents 46ec66d + 71b1dd0 commit 96575b2

File tree

6 files changed

+25
-9
lines changed

6 files changed

+25
-9
lines changed

api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>top.bella</groupId>
88
<artifactId>openai-java</artifactId>
9-
<version>0.23.41</version>
9+
<version>0.23.42</version>
1010
</parent>
1111
<packaging>jar</packaging>
1212
<artifactId>openai-api</artifactId>

api/src/main/java/com/theokanning/openai/queue/Put.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ public class Put {
2828
private String queue;
2929

3030
/**
31-
* The priority level of the task in the queue (default: 0)
31+
* Used for fine-grained priority control in callback mode Lower numbers have higher priority (1 > 2 > 3) Currently not supported
3232
*/
33-
@Builder.Default
34-
private Integer level = 0;
33+
private Integer level;
3534

3635
/**
3736
* The data payload to be processed

api/src/main/java/com/theokanning/openai/queue/Task.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public class Task {
4747
/**
4848
* The priority level of the task in the queue
4949
*/
50-
private Integer level;
50+
@Builder.Default
51+
private Integer level = 0;
5152

5253
/**
5354
* The data payload for the task
@@ -82,6 +83,12 @@ public class Task {
8283
@JsonProperty("running_time")
8384
private long runningTime;
8485

86+
/**
87+
* Timestamp when the task is set to expire
88+
*/
89+
@JsonProperty("expire_time")
90+
private long expireTime;
91+
8592
/**
8693
* Timestamp when the task completed execution
8794
*/
@@ -117,6 +124,16 @@ public String getFullQueueName() {
117124
*/
118125
@JsonIgnore
119126
public boolean isFinish() {
120-
return "succeeded".equals(status) || "failed".equals(status) || "cancelled".equals(status);
127+
return "succeeded".equals(status) || "failed".equals(status) || "cancelled".equals(status) || "timeout".equals(status);
128+
}
129+
130+
/**
131+
* Checks if the task has expired based on the current time and its expireTime
132+
*
133+
* @return true if the task is expired
134+
*/
135+
@JsonIgnore
136+
public boolean isExpire() {
137+
return System.currentTimeMillis() > expireTime;
121138
}
122139
}

client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>top.bella</groupId>
88
<artifactId>openai-java</artifactId>
9-
<version>0.23.41</version>
9+
<version>0.23.42</version>
1010
</parent>
1111
<packaging>jar</packaging>
1212

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>top.bella</groupId>
77
<artifactId>openai-java</artifactId>
8-
<version>0.23.41</version>
8+
<version>0.23.42</version>
99
<packaging>pom</packaging>
1010
<description>openai java 版本</description>
1111
<name>openai-java</name>

service/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>top.bella</groupId>
88
<artifactId>openai-java</artifactId>
9-
<version>0.23.41</version>
9+
<version>0.23.42</version>
1010
</parent>
1111
<packaging>jar</packaging>
1212

0 commit comments

Comments
 (0)