Skip to content

Commit

Permalink
Merge pull request #16 from agorapulse/chore/force-run-java-friendly
Browse files Browse the repository at this point in the history
more options for forceRun and run methods
  • Loading branch information
musketyr authored May 18, 2022
2 parents d6d9183 + d349d33 commit cc9934f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ config {
enabled = false
}
}
sourceHtml {
aggregate {
enabled = false
}
}
}

}
Expand Down
2 changes: 0 additions & 2 deletions docs/guide/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ include::{includedir}/usage.adoc[]
= Links

link:api/index.html[Javadoc, window="_blank"]

link:api-html/index.html[Source, window="_blank"]
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import com.agorapulse.worker.tck.queue.AbstractQueuesSpec
import io.micronaut.context.ApplicationContext
import org.testcontainers.containers.GenericContainer
import org.testcontainers.spock.Testcontainers
import spock.lang.Retry
import spock.lang.Shared

@Retry
@Testcontainers
class RedisQueuesSpec extends AbstractQueuesSpec {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@

public interface JobManager {

static String getDefaultJobName(Class<?> jobClass) {
return NameUtils.hyphenate(jobClass.getSimpleName());
}

static String getDefaultJobName(Class<?> jobClass, String methodName) {
return NameUtils.hyphenate(jobClass.getSimpleName() + "-" + methodName);
}

/**
* Registers a new job.
*
Expand Down Expand Up @@ -70,10 +78,22 @@ default void forceRun(String jobName) {
void enqueue(String jobName, Object message);

default void run(Class<?> jobClass) {
run(NameUtils.hyphenate(jobClass.getSimpleName()));
run(getDefaultJobName(jobClass));
}

default void run(Class<?> jobClass, String methodName) {
run(getDefaultJobName(jobClass, methodName));
}

default void forceRun(Class<?> jobClass) {
forceRun(getDefaultJobName(jobClass));
}

default void forceRun(Class<?> jobClass, String methodName) {
forceRun(getDefaultJobName(jobClass, methodName));
}

default <T> void enqueue(Class<? extends Consumer<? extends T>> jobClass, T message) {
enqueue(NameUtils.hyphenate(jobClass.getSimpleName()), message);
enqueue(getDefaultJobName(jobClass), message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ private String getJobName(BeanDefinition<?> beanDefinition, ExecutableMethod<?,

// there are more then one job definition
if (beanDefinition.getExecutableMethods().size() > 1) {
return NameUtils.hyphenate(method.getDeclaringType().getSimpleName() + "-" + method.getMethodName());
return JobManager.getDefaultJobName(method.getDeclaringType(), method.getMethodName());
}

return NameUtils.hyphenate(method.getDeclaringType().getSimpleName());
return JobManager.getDefaultJobName(method.getDeclaringType());
}

private JobConfiguration getJobConfiguration(BeanDefinition<?> beanDefinition, ExecutableMethod<?, ?> method) {
Expand Down

0 comments on commit cc9934f

Please sign in to comment.