Before this commit the following happened sometimes: 1. action status is connected 2. action config is updated to something that should change the status to disconnected 3. action status is still connected and the old config is being used by the connector even though the config has been correctly updated. The reason for this bug is that the post_config_hook runs before the global EMQX config is updated. The post config hook is adding the new config to the connector. Since the new config causes the action to get status disconnected, the adding of the action to the connector is retried when the health check runs but this time the config will be loaded from the global config which could cause the old config to be loaded (this happens when the global config has not had time to get updated). The above problem has been fixed in this commit by only reading action configs from the global config when the connector starts/restarts and instead store the latest configs for the actions in the connector. Fixes: https://emqx.atlassian.net/browse/EMQX-12376 |
||
|---|---|---|
| .. | ||
| include | ||
| src | ||
| test | ||
| README.md | ||
| rebar.config | ||
emqx_resource
The emqx_resource is a behavior that manages configuration specs and runtime states
for resources like mysql or redis backends.
It is intended to be used by the emqx_bridges and all other resources that need CRUD operations to their configs, and need to initialize the states when creating.
There can be foreign references between resource instances via resource-id. So they may find each other via this Id.
The main idea of the emqx resource is to put all the general code in a common lib, including
the config operations (like config validation, config dump back to files), and the state management.
And we put all the specific codes to the callback modules.
See
test/emqx_connector_demo.erlfor a minimalemqx_resourceimplementation;test/emqx_resource_SUITE.erlfor examples ofemqx_resourceusage.