public class HTTPDiscoveryClusterAddressProvider extends AbstractDiscoveryClusterAddressProvider
Expected response format example:
{
"4141912c-34b8-4e40-a17e-7a6d80345954": {
"uuid": "898b4d01-4261-4006-85ea-a3500163cda0",
"uri": "localhost:3304",
"status": "healthy",
"priority": 1
},
"36a1a75e-60f0-4400-8bdc-d93e2c5ca54b": {
"uuid": "9a3426db-f8f6-4e9f-ac80-e263527a59bc",
"uri": "localhost:3302",
"status": "healthy",
"priority": 1
}
}
Tarantool cartridge application lua http endpoint 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
local httpd = cartridge.service_get('httpd')
local vshard = require('vshard')
httpd:route({method = 'GET', path = '/endpoints'}, function(req)
local json = require('json')
local result = get_routers();
return {body = json.encode(result)}
end)
...
Constructor and Description |
---|
HTTPDiscoveryClusterAddressProvider(TarantoolClusterDiscoveryConfig config) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected Collection<TarantoolServerAddress> |
discoverAddresses() |
getAddresses, getDiscoveryConfig, getExecutorService, setRefreshCallback, startDiscoveryTask
public HTTPDiscoveryClusterAddressProvider(TarantoolClusterDiscoveryConfig config)
protected Collection<TarantoolServerAddress> discoverAddresses()
discoverAddresses
in class AbstractDiscoveryClusterAddressProvider
public void close()
close
in interface TarantoolClusterAddressProvider
close
in interface AutoCloseable
close
in class AbstractDiscoveryClusterAddressProvider
Copyright © 2025 Picodata. All rights reserved.