Skip to content

Commit

Permalink
Update documentation and convert to LDoc format
Browse files Browse the repository at this point in the history
expirationd contains documentation in source code and in a README.
In both places descriptions of API methods are incomplete and
looks sloppy. My experience with LDoc shows that it can help to
place documentation as close to the code as it possible
and generate documentation in HTML format that are looks nice
and convenient for reading.

This change moves all descriptions of API methods to comments in a Lua
source code and removes API descriptions in the README. Descriptions of
API functions contains a types of arguments and these types conforms to
types used by checks module for validation functions arguments. I have
discovered two options that expirationd.start() uses but both were not
documented: `options.vinyl_assumed_space_len` and
`options.vinyl_assumed_space_len_factor`.

Closes #14
Closes #60
Part of #79
  • Loading branch information
ligurio committed Sep 27, 2021
1 parent 135f033 commit ae702c9
Show file tree
Hide file tree
Showing 2 changed files with 355 additions and 160 deletions.
87 changes: 4 additions & 83 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Table below may help you to choose a proper module for your requirements:
| expirationd | Medium (sec) | No | Yes | synchronous (fiber with condition) |
| moonwalker | NA | No | Yes | asynchronous (using crontab etc) |

### Documentation

See https://tarantool.github.io/expirationd/

### Examples

Simple version:
Expand Down Expand Up @@ -91,89 +95,6 @@ expirationd.start(job_name, space.id, is_expired, {
})
```

## Expirationd API

### `expirationd.start (name, space_id, is_tuple_expired, options)`

Run a scheduled task to check and process (expire) tuples in a given space.

* `name` - task name
* `space_id` - space to look in for expired tuples
* `is_tuple_expired` - a function, must accept tuple and return true/false
(is tuple expired or not), receives `(args, tuple)` as arguments
* `options` -- (table with named options, may be nil)
* `process_expired_tuple` - Applied to expired tuples, receives (space_id, args, tuple) as arguments.
Can be nil: by default, tuples are removed.
* `index` - Name or id of the index to iterate on. If omitted, will use the primary index.
If there's no index with this name, will throw an error.
Supported index types are TREE and HASH, using other types will result in an error.
* `iterator_type` - Type of the iterator to use, as string or box.index constant, for example, "EQ" or box.index.EQ.
Default is box.index.ALL.
See https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_index/pairs/.
* `start_key` - Start iterating from the tuple with this index value. If the iterator is "EQ", iterate over tuples with this index value.
The index value may be a single value, if the index consists of one field, a tuple with the index key parts, or a function which returns such value.
If omitted or nil, all tuples will be checked.
* `tuples_per_iteration` - Number of tuples to check in one batch (iteration). Default is 1024.
* `atomic_iteration` - Boolean, false (default) to process each tuple as a single transaction.
True to process tuples from each batch in a single transaction.
* `process_while` - Function to call before checking each tuple.
If it returns false, the current tuple scan task finishes.
* `iterate_with` - Function which returns an iterator object which provides tuples to check, considering the start_key, process_while and other options.
There's a default function which can be overriden with this parameter.
* `on_full_scan_start` - Function to call before starting a tuple scan.
* `on_full_scan_complete` - Function to call after completing a full scan.
* `on_full_scan_success` - Function to call after successfully completing a full scan.
* `on_full_scan_error` - Function to call after terminating a full scan due to an error.
* `args` - Passed to is_tuple_expired and process_expired_tuple() as an additional context.
* `full_scan_time` - Time required for a full index scan (in seconds).
* `iteration_delay` - Max sleep time between batches (in seconds).
* `full_scan_delay` - Sleep time between full scans (in seconds).
* `force` - Run task even on replica.


### `expirationd.kill (name)`

Kill an existing task with name "name"

* `name` - task's name

### `expirationd.stats ([name])`

if `name` is nil, then return map of `name`:`stats`, else return map with stats.

* `name` - task's name, may be nil

### `expirationd.task (name)`

Get task with name `name`

### `expirationd.tasks ()`

Get copy of task list

### `expirationd.update ()`

Update expirationd version and restart all tasks

## Task API

### `task:start()`

Force start `task` (old guardian_fiber will be garbage collected,
so do `task:stop()` before or `task:restart()` instead)

### `task:stop()`

### `task:restart()`

### `task:kill()`

Stop task and delete it from list of tasks.

### `task:statistics()`

Get statistics of task

## Testing

Simply start `make test`
Loading

0 comments on commit ae702c9

Please # to comment.