Class BinaryDiscoveryClusterAddressProvider

  • All Implemented Interfaces:
    TarantoolClusterAddressProvider, AutoCloseable

    public class BinaryDiscoveryClusterAddressProvider
    extends AbstractDiscoveryClusterAddressProvider
    Service discovery client connecting to Tarantool via the binary protocol. Gets list of cluster node addresses calling an exposed Lua function.

    Expected response format:

     
     127.0.0.1:3301> get_routers()
     ---
     - 36a1a75e-60f0-4400-8bdc-d93e2c5ca54b:
         priority: 1
         status: healthy
         uri: localhost:3301
         uuid: 9a3426db-f8f6-4e9f-ac80-e263527a59bc
       4141912c-34b8-4e40-a17e-7a6d80345954:
         priority: 1
         status: healthy
         uri: localhost:3302
         uuid: 898b4d01-4261-4006-85ea-a3500163cda0
     ...
     
     

    Lua function example:

     
      ...
      local function get_routers()
        local cartridge = require('cartridge')
        local function table_contains(table, element)
          for _, value in pairs(table) do
            if value == element then
              return true
            end
          end
          return false
        end
    
        local servers, err = cartridge.admin_get_servers()
        local routers = {}
    
        for _, server in pairs(servers) do
          if server.replicaset ~= nil then
            if table_contains(server.replicaset.roles, 'app.roles.custom') then
              routers[server.uuid] = {
                  status = server.healthy,
                  uuid = server.uuid,
                  uri = server.uri,
                  priority = server.priority
              }
            end
          end
        end
    
        return routers
      end
      ...