Skip to content

tarantool.config: add wait_status helper #5643

@mandesero

Description

@mandesero

Related dev. issue(s): tarantool/tarantool#12439

Product: Tarantool
Since: 3.7
Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/config/
SME: @georgiy-belyanin, @mandesero

Details

Introduce a new helper function config:wait_status() that allows waiting for one of the specified configuration statuses.

config API

config:wait_status(statuses[, timeout])

Wait until the instance reaches one of the specified configuration statuses.

The call is blocking: it suspends the current fiber until the instance transitions to any of the given statuses. If no timeout is specified, the function waits indefinitely.

Parameters:

  • statuses (table) - a list of statuses to wait for
  • timeout (number) - maximum time to wait (in seconds); if not specified, waits indefinitely

Return: the reached status

Example:

local function apply(cfg)
    fiber.create(function()
        -- Wait until status changes to one of the expected values.
        -- If the status never reaches 'check_errors', this fiber will block indefinitely.
        local status = config:wait_status({'check_errors'})

        if status == 'check_errors' then
            -- Handle configuration errors
        end
    end)

    -- Continue applying configuration
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions