Skip to content

Commit db5fcc3

Browse files
committed
Docs: Control API and reloading modules.
1 parent 640a95b commit db5fcc3

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

docs/api.md

+4
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,10 @@ Execute Action - Sends the given action into execution queue.
401401
You can see the enabled actions in [`/config/control.yml`](configuration/control.md), available are:
402402

403403
- `make_snapshots` - Makes an out-of-order snapshot of all entities
404+
- `refresh_on_entity_creation` - Re-runs the `on_entity_creation` callback for selected `etype`
405+
- `refresh_module_config` - Re-runs the `load_config` for selected module and will refresh the values derived by the module when configured to do so
406+
407+
You can learn more about the actions in the [Actions](configuration/control.md#actions) section of the `Control` configuration documentation.
404408

405409
### Request
406410

docs/configuration/control.md

+34-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Control
22

3-
The `Control` module serves the [`/control/...`](../api.md#control) endpoint.
3+
The `Control` module serves the [`/control/...`](../api.md#control) endpoints.
44
This is used to execute actions that are not part of the normal operation of the application,
55
at a time when the user decides to do so.
66
Useful for management of the application, especially when there are changes made to the configuration.
@@ -9,9 +9,40 @@ The `control.yml` file looks like this:
99

1010
```yaml
1111
allowed_actions: [
12-
make_snapshots, # Makes an out-of-order snapshot of all entities
12+
make_snapshots, # (1)!
13+
refresh_on_entity_creation, # (2)!
14+
refresh_module_config, # (3)!
1315
]
1416
```
1517

18+
1. Makes an out-of-order snapshot of all entities
19+
2. Re-runs the `on_entity_creation` callback for selected `etype`
20+
3. Re-runs the `load_config` for selected module and will refresh the values derived by the module
21+
1622
The `allowed_actions` parameter is a list of actions that are allowed to be executed.
17-
The way to use this file is to simply comment out the actions that you do not want to be allowed.
23+
The way to use this file is to simply comment out the actions that you do not want to be allowed.
24+
25+
## Actions
26+
27+
The swagger API documentation provides a simple GUI for executing the actions,
28+
but they can also be executed directly by sending a `GET` request to the endpoint.
29+
These are the actions that are currently available:
30+
31+
### `make_snapshots`
32+
33+
This action will make an out-of-order snapshot of all entities.
34+
35+
### `refresh_on_entity_creation`
36+
37+
This action will re-run the `on_entity_creation` callback for a selected `etype`, which is passed as a query parameter.
38+
Will fail if the `etype` is not provided.
39+
40+
### `refresh_module_config`
41+
42+
This action will re-run the `load_config` for selected module and will refresh the values derived by the module.
43+
The module name is to be passed as a query parameter and the action will fail without it.
44+
45+
The refreshing part of this action covers the `on_entity_creation` and `on_new_attr` callbacks
46+
when the `refresh` argument is set on callback registration, otherwise no refresh is performed,
47+
only the `load_config` is re-run.
48+

docs/modules.md

+14
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ This configuration will be then loaded into the `module_config` dictionary for c
109109
Please place code that loads the module configuration into the `load_config` method,
110110
where you will recieve both the `platform_config` and `module_config` as arguments.
111111

112+
## Reloading configuration
113+
114+
The module configuration can be reloaded during runtime using the [Control](configuration/control.md) API, specifically the [`refresh_module_config`](configuration/control.md#refresh_module_config) action.
115+
This will cause the `load_config` method to be called again, with the new configuration.
116+
For this reason it is recommended to place all configuration loading code into the `load_config` method.
117+
118+
Some callbacks may be called only sparsely in the lifetime of an entity,
119+
and it may be useful to refresh all the values derived by the module when the configuration changes.
120+
This is implemented for the [`on_entity_creation`](#entity-on_entity_creation-hook)
121+
and [`on_new_attr`](#attribute-hooks) callbacks,
122+
and you can enable it by passing the `refresh` keyword argument
123+
to the callback registration. See the Callbacks section for more details.
124+
125+
112126
## Callbacks
113127

114128
The `registrar:` [`CallbackRegistrar`][dp3.common.callback_registrar.CallbackRegistrar] object

0 commit comments

Comments
 (0)