tarantool / tarantool/doc

Public alerts API

Open Beginner friendly
#4,667 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.3 server
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_name must be a
    string and can not contain a colon (":").
  • alerts_namespace:add(alert) - raises new alert of type warning.
    alert must be a table. alert.message is logged and the alert will
    be shown in box.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.
    alert must be a table. alert.message is logged and the alert will
    be shown in box.info.config.alerts. key must be a string and can
    not contain a colon (":").
  • alerts_namespace:unset(key) - discards the alert with the
    corresponding 'key' in the namespace. key must 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 from box.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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.