tarantool / migrations

BSD 2-Clause "Simplified" License
21 stars 5 forks source link

Add helper to check is role enabled #68

Closed Satbek closed 7 months ago

Satbek commented 9 months ago

module runs the same lua code on all instances, but I want to run some lua code only on router, some only on storage. So, i have to write something like this

local function is_storage_master()
    if box.info.ro then
        return false
    end

    local roles = cartridge_api_topology.get_enabled_roles_without_deps()
    for _, rname in pairs(roles) do
        if rname == 'crud-storage' then
            return true
        end
    end

    return false
end

please add in utils something like this utils.check_roles_enabled({'crud-storage', 'my_super_role'})

hackallcode commented 8 months ago

Also I want is_router function