Skip to content

Commit

Permalink
add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dcdh committed Mar 4, 2024
1 parent 3764ed2 commit 1759a83
Show file tree
Hide file tree
Showing 12 changed files with 277 additions and 17 deletions.
11 changes: 11 additions & 0 deletions docs/modules/ROOT/examples/InMemorySchedulerLockService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import jakarta.enterprise.context.ApplicationScoped;

import io.quarkiverse.shedlock.providers.inmemory.runtime.InMemorySchedulerLock;

@ApplicationScoped
public class InMemorySchedulerLockService {
@InMemorySchedulerLock
public void runUsingLock() {
// do something
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import jakarta.enterprise.context.ApplicationScoped;

import io.quarkiverse.shedlock.common.runtime.LockDuration;
import io.quarkiverse.shedlock.providers.inmemory.runtime.InMemorySchedulerLock;

@ApplicationScoped
public class InMemorySchedulerLockServiceOptions {
@InMemorySchedulerLock(lockDuration = @LockDuration(lockAtMostFor = "PT30S", lockAtLeastFor = "PT10S"))
public void runUsingLock() {
// TODO do something
}
}
11 changes: 11 additions & 0 deletions docs/modules/ROOT/examples/JdbcSchedulerLockService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import jakarta.enterprise.context.ApplicationScoped;

import io.quarkiverse.shedlock.providers.jdbc.runtime.JdbcSchedulerLock;

@ApplicationScoped
public class JdbcSchedulerLockService {
@JdbcSchedulerLock
public void runUsingLock() {
// do something
}
}
12 changes: 12 additions & 0 deletions docs/modules/ROOT/examples/JdbcSchedulerLockServiceOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import jakarta.enterprise.context.ApplicationScoped;

import io.quarkiverse.shedlock.common.runtime.LockDuration;
import io.quarkiverse.shedlock.providers.jdbc.runtime.JdbcSchedulerLock;

@ApplicationScoped
public class JdbcSchedulerLockServiceOptions {
@JdbcSchedulerLock(dataSourceName = "master", lockDuration = @LockDuration(lockAtMostFor = "PT30S", lockAtLeastFor = "PT10S"))
public void runUsingLock() {
// do something
}
}
11 changes: 11 additions & 0 deletions docs/modules/ROOT/examples/MongoSchedulerLockService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import jakarta.enterprise.context.ApplicationScoped;

import io.quarkiverse.shedlock.providers.mongo.runtime.MongoSchedulerLock;

@ApplicationScoped
public class MongoSchedulerLockService {
@MongoSchedulerLock
public void runUsingLock() {
// do something
}
}
12 changes: 12 additions & 0 deletions docs/modules/ROOT/examples/MongoSchedulerLockServiceOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import jakarta.enterprise.context.ApplicationScoped;

import io.quarkiverse.shedlock.common.runtime.LockDuration;
import io.quarkiverse.shedlock.providers.mongo.runtime.MongoSchedulerLock;

@ApplicationScoped
public class MongoSchedulerLockServiceOptions {
@MongoSchedulerLock(mongoClientName = "cluster1", lockDuration = @LockDuration(lockAtMostFor = "PT30S", lockAtLeastFor = "PT10S"))
public void runUsingLock() {
// do something
}
}
7 changes: 3 additions & 4 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
* xref:index.adoc[Getting started]
TODO faire chaque page ou autres ... voir le service amazon
mais je pense que je ne devrais pas l'utiliser ...
* xref:shedlock-in-memory.adoc[Shedlock in memory provider]
* xref:shedlock-jdbc.adoc[Shedlock JDBC provider]
* xref:shedlock-mongo.adoc[Shedlock mongo provider]
26 changes: 13 additions & 13 deletions docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

include::./includes/attributes.adoc[]

TIP: Distributed lock for your scheduled tasks.
Propose a set of shedlock provider as extensions

== Installation
TIP: Each provider is autonomous and can be used in conjunction with others.

If you want to use this extension, you need to add the `io.quarkiverse.shedlock:quarkus-shedlock` extension first to your build file.
== Configuration

For instance, with Maven, add the following dependency to your POM file:
Each provider come with specific configuration regarding lock storage.

[source,xml,subs=attributes+]
The lock duration configuration is common for each provider and there values are overridable on the interceptor annotation.
The `lockAtMostFor` and `lockAtLeastFor` can be defined. You can have a look to link:++https://github.com/lukas-krecan/ShedLock?tab=readme-ov-file#annotate-your-scheduled-tasks++[shedlock documentation] to know more about them.

The `quarkus.shedlock.defaults-lock-at-most-for` application property is mandatory.

[source,properties]
.src/main/resources/application.properties
----
<dependency>
<groupId>io.quarkiverse.shedlock</groupId>
<artifactId>quarkus-shedlock</artifactId>
<version>{project-version}</version>
</dependency>
quarkus.shedlock.defaults-lock-at-most-for=PT30S
----

[[extension-configuration-reference]]
== Extension Configuration Reference

TIP: Remove this section if you don't have Quarkus configuration properties in your extension.

include::includes/quarkus-shedlock.adoc[leveloffset=+1, opts=optional]
include::includes/quarkus-shedlock.adoc[opts=optional, leveloffset=+1]
54 changes: 54 additions & 0 deletions docs/modules/ROOT/pages/shedlock-in-memory.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
= Shedlock In Memory Provider

include::./includes/attributes.adoc[]

Shedlock In Memory provider give the ability to apply `local` locks. Under the hood an `HashMap` is used to store the locks.

[[installation]]
== Installation

If you want to use this extension, you need to add the `io.quarkiverse.shedlock:quarkus-shedlock-provider-inmemory` extension first to your build file.

For instance, with Maven, add the following dependency to your POM file:

[source,xml,subs=attributes+]
----
<dependency>
<groupId>io.quarkiverse.shedlock</groupId>
<artifactId>quarkus-shedlock-provider-inmemory</artifactId>
<version>{project-version}</version>
</dependency>
----

[[configuring]]
== Configuring

The `quarkus.shedlock.defaults-lock-at-most-for` application property is mandatory.

[[extension-configuration-reference]]
== Extension Configuration Reference

include::includes/quarkus-shedlock.adoc[opts=optional, leveloffset=+1]

[source,properties]
.src/main/resources/application.properties
----
quarkus.shedlock.defaults-lock-at-most-for=PT30S
----

[[how-to-use-it]]
== How to use it

To activate the lock on a method just annotate it with `@InMemorySchedulerLock`.

[source,java]
----
include::{examples-dir}/InMemorySchedulerLockService.java[indent=0,tabsize=2]
----

The lock duration can be defined on the annotation directly likes this way:

[source,java]
----
include::{examples-dir}/InMemorySchedulerLockServiceOptions.java[indent=0,tabsize=2]
----
79 changes: 79 additions & 0 deletions docs/modules/ROOT/pages/shedlock-jdbc.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
= Shedlock In Memory Provider

include::./includes/attributes.adoc[]

Shedlock Jdbc provider give the ability to apply `distributed` locks using a jdbc database.

[[installation]]
== Installation

If you want to use this extension, you need to add the `io.quarkiverse.shedlock:quarkus-shedlock-provider-jdbc` extension first to your build file with a `jdbc datasource`.

For instance, with Maven, add the following dependency to your POM file:

[source,xml,subs=attributes+]
----
<dependency>
<groupId>io.quarkiverse.shedlock</groupId>
<artifactId>quarkus-shedlock-provider-jdbc</artifactId>
<version>{project-version}</version>
</dependency>
----

and a jdbc datasource likes postgresql

[source,xml,subs=attributes+]
----
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
----

[[configuring]]
== Configuring

The `quarkus.shedlock.defaults-lock-at-most-for` application property is mandatory. The table name is defined to `shedlock` and can be overridden for the default datasource or another named jdbc datasource.

[source,properties]
.src/main/resources/application.properties
----
quarkus.shedlock.defaults-lock-at-most-for=PT30S
quarkus.datasource.db-kind=postgresql
----

[[extension-configuration-reference]]
== Extension Configuration Reference

include::includes/quarkus-shedlock.adoc[opts=optional, leveloffset=+1]

include::includes/quarkus-shedlock-jdbc.adoc[opts=optional, leveloffset=+1]

== How to use it

To activate the lock on a method just annotate it with `@JdbcSchedulerLock`.

[source,java]
----
include::{examples-dir}/JdbcSchedulerLockService.java[indent=0,tabsize=2]
----

By default, the lock is bound to the `default` datasource.

The lock duration and dataSourceName can be defined on the annotation directly likes this way:

[source,java]
----
include::{examples-dir}/JdbcSchedulerLockServiceOptions.java[indent=0,tabsize=2]
----

Regarding this sample a `master` datasource must be defined has well.

[source,properties]
.src/main/resources/application.properties
----
quarkus.shedlock.defaults-lock-at-most-for=PT30S
quarkus.datasource.master.db-kind=postgresql
----

if the datasource does not exist the application will refuse to start and a message will be produce to help configuring the application.
59 changes: 59 additions & 0 deletions docs/modules/ROOT/pages/shedlock-mongo.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
= Shedlock In Memory Provider

include::./includes/attributes.adoc[]

Shedlock Mongo provider give the ability to apply `distributed` locks using a mongo database.

[[installation]]
== Installation

If you want to use this extension, you need to add the `io.quarkiverse.shedlock:quarkus-shedlock-provider-mongo` extension first to your build file.

For instance, with Maven, add the following dependency to your POM file:

[source,xml,subs=attributes+]
----
<dependency>
<groupId>io.quarkiverse.shedlock</groupId>
<artifactId>quarkus-shedlock-provider-mongo</artifactId>
<version>{project-version}</version>
</dependency>
----

[[configuring]]
== Configuring

The `quarkus.shedlock.defaults-lock-at-most-for` application property is mandatory. The collection naming is defined to `shedlock` and cannot be overridden.
The database name is defined to `shedlock` and it is possible to override it depending on the mongo client name.

[source,properties]
.src/main/resources/application.properties
----
quarkus.shedlock.defaults-lock-at-most-for=PT30S
quarkus.shedlock.mongo.cluster1.database-name=customDatabase
----

[[extension-configuration-reference]]
== Extension Configuration Reference

include::includes/quarkus-shedlock.adoc[opts=optional, leveloffset=+1]

include::includes/quarkus-shedlock-mongo.adoc[opts=optional, leveloffset=+1]

== How to use it

To activate the lock on a method just annotate it with `@MongoSchedulerLock`.

[source,java]
----
include::{examples-dir}/MongoSchedulerLockService.java[indent=0,tabsize=2]
----

By default, the lock is bound to the `default` mongo client.

The lock duration and mongoClientName can be defined on the annotation directly likes this way:

[source,java]
----
include::{examples-dir}/MongoSchedulerLockServiceOptions.java[indent=0,tabsize=2]
----
Empty file.

0 comments on commit 1759a83

Please sign in to comment.