Skip to content

Add helper to check is role enabled #68

@Satbek

Description

@Satbek

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'})

Metadata

Metadata

Assignees

Labels

featureA new functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions