Skip to content

Commit

Permalink
feature: update scheduler module
Browse files Browse the repository at this point in the history
  • Loading branch information
kalencaya committed Nov 17, 2024
1 parent 73259c8 commit d5ede8b
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 3 deletions.
2 changes: 1 addition & 1 deletion carp-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>carp-module-scheduler-base</artifactId>
<artifactId>carp-module-scheduler-manage</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,10 @@
</parent>
<artifactId>carp-module-scheduler-executor</artifactId>

<dependencies>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>carp-framework-common</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cn.sliew.carp.module.scheduler.executor;

import cn.hutool.core.date.DatePattern;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.util.Date;
import java.util.Map;

@Data
public class JobContext {

private String jobId;
private Map<String, Object> params;
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
private Date triggerTime;
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
private Date fireTime;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cn.sliew.carp.module.scheduler.executor;

import cn.sliew.carp.module.scheduler.executor.entity.ScheduleResponse;
import cn.sliew.carp.module.scheduler.executor.entity.trigger.TriggerParam;

public interface JobExecutor {

ScheduleResponse execute(TriggerParam param);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cn.sliew.carp.module.scheduler.executor;

import cn.sliew.carp.module.scheduler.executor.entity.job.JobExecutionResult;

public interface JobHandler {

JobExecutionResult execute(JobContext context);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cn.sliew.carp.module.scheduler.executor.entity;

import cn.sliew.carp.module.scheduler.executor.entity.job.JobExecutionResult;
import lombok.Data;

@Data
public class ScheduleResponse {

public static final JobExecutionResult SUCCESS = new JobExecutionResult("0", "success");
public static final JobExecutionResult FAILED = new JobExecutionResult("1", "failed");

private String code;
private String message;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cn.sliew.carp.module.scheduler.executor.entity.job;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class JobExecutionResult {

public static final JobExecutionResult SUCCESS = new JobExecutionResult("0", "success");
public static final JobExecutionResult FAILED = new JobExecutionResult("1", "failed");

private String code;
private String message;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package cn.sliew.carp.module.scheduler.executor.entity.trigger;

import cn.hutool.core.date.DatePattern;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.util.Date;
import java.util.Map;

@Data
public class TriggerParam {

private String jobId;
private String jobHandler;
private Map<String, Object> params;
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
private Date triggerTime;
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
private Date fireTime;

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<dependencies>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>carp-module-scheduler-base</artifactId>
<artifactId>carp-module-scheduler-manage</artifactId>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>carp-module-scheduler-base</artifactId>
<artifactId>carp-module-scheduler-manage</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down

0 comments on commit d5ede8b

Please sign in to comment.