Public alerts API
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 15
- Forks
- 49
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 3
Description
Dev. issue: https://github.com/tarantool/tarantool/issues/10873
Product: Tarantool
Since: 3.3.0
Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/config/
SME: @ grafin
Details
Users can now raise their own alerts (similar to the alerts raised by
the config module).
New available methods:
config:new_alerts_namespace(alerts_namespace_name)- creates a new
alerts namespaces and returns it.alerts_namespace_namemust be a
string and can not contain a colon (":").alerts_namespace:add(alert)- raises new alert of type warning.
alertmust be a table.alert.messageis logged and the alert will
be shown inbox.info.config.alerts.alerts_namespace:set(key, alert)- raises new alert of type warning,
or replaces an existing, raised with the same 'key' in the namespace.
alertmust be a table.alert.messageis logged and the alert will
be shown inbox.info.config.alerts.keymust be a string and can
not contain a colon (":").alerts_namespace:unset(key)- discards the alert with the
corresponding 'key' in the namespace.keymust be a
string and can not contain a colon (":"). If an alert with the
corresponding key does not exist in the namespace, does nothing.alerts_namespace:clear()- discards all alerts from the namespace,
removing them frombox.info.config.alerts.
Alerts namespaces with the same name will point to the same alerts
namespace. During configuration update all alerts from namespaces are
removed from box.info.config.alerts.
The alert.type is forced to be "warn", anything except "warn" or
nil is considered an error.
Any keys in alert which start with an underscore will be ignored.
Example usage:
local config = require('config')
-- Create a new alerts namespace 'my_alerts'.
local alerts = config:new_alerts_namespace('my_alerts')
-- Raise a new alert.
alerts:add({
message = 'Test alert',
my_field = 'my_value',
})
-- Raise a new alert with a key.
alerts:set("my_alert", {
message = 'Test alert',
my_field = 'my_value',
})
-- Update an existing alert with a key.
alerts:set("my_alert", {
message = 'Test alert',
my_field = 'my_value',
})
-- Discard an existing alert with a key.
alerts:unset("my_alert")
-- Clear all alerts in the alerts namespace 'my_alerts'
alerts:clear()
Requested by @grafin in https://github.com/tarantool/tarantool/commit/469134625b832244398a1e9b55d08c27648a6990.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked root document for the Lua config API and review its existing alert documentation. Add the public namespace creation and alert lifecycle methods described in the issue, including validation and cleanup behavior, then verify the examples and API descriptions cover the stated acceptance details.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100