Skip to content

Commit

Permalink
Updat openapi worker
Browse files Browse the repository at this point in the history
  • Loading branch information
stelin committed Feb 6, 2024
1 parent 6303061 commit 4f93aa9
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class DateUtilTest {
@Test
public void testFormatDateByTimestamp() {
Integer dateTime = DateUtil.formatDateByTimestamp(DateUtil.timestamp());
Integer dateTime = DateUtil.formatDateByTimestamp(DateUtil.timestamp()* 1000);
Integer HourTime = DateUtil.formatHourByTimestamp(DateUtil.timestamp());

Assertions.assertNotNull(dateTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.List;

/**
Expand All @@ -23,7 +24,8 @@ public class WorkerHeartbeatRequest {
private String appName;

@NotBlank
@ApiModelProperty("Worker internet address")
@Pattern(regexp = "^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}:\\d{1,5}$", message = "must be in format 'IP:PORT'")
@ApiModelProperty("Worker address.")
private String address;

@NotBlank
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package io.openjob.server.openapi.request;

import io.openjob.common.constant.ProtocolTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
* @author zhenghongyang [email protected]
Expand All @@ -13,24 +15,24 @@
public class WorkerStartRequest {

@NotBlank
@ApiModelProperty("Worker key")
@ApiModelProperty("Worker unique id.")
private String workerKey;

@NotBlank
@ApiModelProperty("App name")
private String appName;

@NotBlank
@Pattern(regexp = "^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}:\\d{1,5}$", message = "must be in format 'IP:PORT'")
@ApiModelProperty("Worker address")
private String address;

@NotBlank
@ApiModelProperty("Worker agent version")
private String version;

@NotBlank
@ApiModelProperty("Worker current protocol type")
private String protocolType;
@ApiModelProperty("Worker current protocol type, http is default.")
private String protocolType = ProtocolTypeEnum.HTTP.getType();

@ApiModelProperty("metric")
private Metric metric;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
* @author zhenghongyang [email protected]
Expand All @@ -13,14 +14,15 @@
public class WorkerStopRequest {

@NotBlank
@ApiModelProperty("Worker key")
@ApiModelProperty("Worker unique id.")
private String workerKey;

@NotBlank
@ApiModelProperty("App name")
private String appName;

@NotBlank
@Pattern(regexp = "^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}:\\d{1,5}$", message = "must be in format 'IP:PORT'")
@ApiModelProperty("worker address")
private String address;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
### Worker start
POST http://localhost:8080/openapi/worker/start
Content-Type: application/json

{
"address": "127.0.0.2:8088",
"appName": "openjob",
"metric": {},
"version": "1.0.6",
"workerKey": "SZ2C7FNQRkktQdv"
}

### Worker start
POST http://localhost:8080/openapi/worker/stop
Content-Type: application/json

{
"address": "127.0.0.2:8088",
"appName": "openjob",
"workerKey": "SZ2C7FNQRkktQdv"
}


### Worker heartbeat
POST http://localhost:8080/openapi/worker/heartbeat
Content-Type: application/json

{
"address": "127.0.0.2:8088",
"appId": 1,
"appName": "openjob",
"runningJobInstanceIds": [
],
"version": "1.0.6"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server.port=${SERVER_PORT:8080}
#spring.profiles.active=mysql
spring.profiles.active=mysql
#spring.profiles.active=pgsql
#spring.profiles.active=oracle
#spring.profiles.active=tidb
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.openjob.worker.processor;

import io.openjob.common.constant.TaskStatusEnum;
import lombok.Data;

/**
Expand Down

0 comments on commit 4f93aa9

Please sign in to comment.