mirror of
https://github.com/InsanusMokrassar/docs.git
synced 2026-04-02 08:12:30 +00:00
several fixes and krontab migration
This commit is contained in:
19
docs/krontab/introduction/faq.md
Normal file
19
docs/krontab/introduction/faq.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# FAQ
|
||||
|
||||
#### How oftern new versions are releasing?
|
||||
|
||||
Not very often. It depend on libraries (coroutines, korlibs/klock) updates and on some new awesome, but lightweight, features coming.
|
||||
|
||||
#### Where this library could be useful?
|
||||
|
||||
First of all, this library will be useful for long uptime applications which have some tasks to do from time to time.
|
||||
|
||||
#### How to use crontab-like syntax?
|
||||
|
||||
In two words, you should call `buildSchedule` or `createSimpleScheduler`:
|
||||
|
||||
```kotlin
|
||||
buildSchedule("5 * * * *").asFlow().collect { /* do something */ }
|
||||
```
|
||||
|
||||
You can read more about syntax in [String format](../describing/string-format.md) section.
|
||||
57
docs/krontab/introduction/how-to-use.md
Normal file
57
docs/krontab/introduction/how-to-use.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# How to use
|
||||
|
||||
## Previous pages
|
||||
|
||||
* [Including in project](including-in-project.md)
|
||||
|
||||
## `buildSchedule`
|
||||
|
||||
> NOTE: **Custom KronScheduler**
|
||||
> You always able to create your own scheduler. In this section will be presented different ways and examples around standard `CronDateTimeScheduler` builders `buildSchedule`. You can read about schedulers in [KrontabScheduler](../describing/krontabscheduler.md)
|
||||
|
||||
Currently, `buildSchedule` is the recommended start point for every scheduler. Usually, it is look like:
|
||||
|
||||
```kotlin
|
||||
val scheduler = buildSchedule("5 * * * *")
|
||||
```
|
||||
|
||||
Or:
|
||||
|
||||
```kotlin
|
||||
val scheduler = buildSchedule {
|
||||
seconds {
|
||||
at(5)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
On the top of any `KronScheduler` currently there are several groups of extensions:
|
||||
|
||||
* Executes
|
||||
* Shortcuts
|
||||
* Flows
|
||||
|
||||
### Executes
|
||||
|
||||
All executes are look like `do...`. All executes are described below:
|
||||
|
||||
* `doOnce` - will get the next time for executing, delay until that time and call `block` with returning of the `block` result
|
||||
* `doWhile` - will call `doOnce` while it will return `true` (that means that `block` must return `true` if it expects that next call must happen). In two words: it will run while `block` returning `true`
|
||||
* `doInfinity` - will call the `block` using `doWhile` with predefined returning `true`. In two words: it will call `block` while it do not throw error
|
||||
|
||||
### Shortcuts
|
||||
|
||||
Shortcuts are the constants that are initializing in a lazy way to provide preset `KronScheduler`s. For more info about `KrontabScheduler` you can read its own [page](../describing/krontabscheduler.md).
|
||||
|
||||
* `AnyTimeScheduler` - will always return incoming `DateTime` as next
|
||||
* `Every*Scheduler` - return near * since the passed `relatively`:
|
||||
* `EverySecondScheduler`
|
||||
* `EveryMinuteScheduler`
|
||||
* `EveryHourScheduler`
|
||||
* `EveryDayOfMonthScheduler`
|
||||
* `EveryMonthScheduler`
|
||||
* `EveryYearScheduler`
|
||||
|
||||
### Flows
|
||||
|
||||
Here currently there is only one extension for `KronScheduler`: `KronScheduler#asFlow`. As a result you will get `Flow<DateTime>` (in fact `SchedulerFlow`) which will trigger next `emit` on each not null `next` `DateTime`
|
||||
35
docs/krontab/introduction/including-in-project.md
Normal file
35
docs/krontab/introduction/including-in-project.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# Including in project
|
||||
|
||||
In two words, you must add dependency `dev.inmo:krontab:$krontab_version` to your project. The latest version presented by next badge:
|
||||
|
||||
[](https://maven-badges.herokuapp.com/maven-central/dev.inmo/krontab)
|
||||
|
||||
### Notice about repository
|
||||
|
||||
To use this library, you will need to include `MavenCentral` repository in you project
|
||||
|
||||
###### build.gradle
|
||||
|
||||
```groovy
|
||||
mavenCentral()
|
||||
```
|
||||
|
||||
### Dependencies
|
||||
|
||||
Next snippets must be placed into your `dependencies` part of `build.gradle` (for gradle) or `pom.xml` (for maven).
|
||||
|
||||
#### Gradle
|
||||
|
||||
```groovy
|
||||
implementation "dev.inmo:krontab:$krontab_version"
|
||||
```
|
||||
|
||||
#### Maven
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>dev.inmo</groupId>
|
||||
<artifactId>krontab</artifactId>
|
||||
<version>${krontab_version}</version>
|
||||
</dependency>
|
||||
```
|
||||
Reference in New Issue
Block a user