io.vertx.up.uca.job.center.OnceAgha Maven / Gradle / Ivy
package io.vertx.up.uca.job.center;
import io.vertx.core.Future;
import io.vertx.up.atom.worker.Mission;
import io.vertx.up.eon.em.JobStatus;
/**
* Start one time
*/
class OnceAgha extends AbstractAgha {
@Override
public Future begin(final Mission mission) {
/*
* 1. Execute this mission directly
* - This category could not be started when worker deployed, instead, this Agha should
* check whether this task is in `JobPool` because it will be triggered in future.
* 2. This task is only once execution, invoke `@On / @Off` at the same time.
* 3. This kind fo task must be triggered, could not be in plan here. It's not needed to call
* Interval to process task.
* */
final Future future = Future.future();
interval().startAt((timeId) -> {
if (JobStatus.STARTING == mission.getStatus()) {
/*
* Preparing for job
**/
preparing(mission);
future.complete(timeId);
} else if (JobStatus.READY == mission.getStatus()) {
/*
* Running the job next time when current job get event
* from event bus trigger
*/
working(mission).compose(envelop -> {
/*
* Complete future and returned: Async
*/
future.complete(timeId);
return Future.succeededFuture(envelop);
});
}
});
return future;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy