Package io.tarantool.driver.cluster
Class HTTPDiscoveryClusterAddressProvider
- java.lang.Object
 - 
- io.tarantool.driver.cluster.AbstractDiscoveryClusterAddressProvider
 - 
- io.tarantool.driver.cluster.HTTPDiscoveryClusterAddressProvider
 
 
 
- 
- All Implemented Interfaces:
 TarantoolClusterAddressProvider,AutoCloseable
public class HTTPDiscoveryClusterAddressProvider extends AbstractDiscoveryClusterAddressProvider
Tarantool server address provider with service discovery via HTTP. Gets list of nodes from API endpoint in json format. Expected response format example:
Tarantool cartridge application lua http endpoint 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 } }... 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 Summary
Constructors Constructor Description HTTPDiscoveryClusterAddressProvider(TarantoolClusterDiscoveryConfig config) 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()protected Collection<TarantoolServerAddress>discoverAddresses()- 
Methods inherited from class io.tarantool.driver.cluster.AbstractDiscoveryClusterAddressProvider
getAddresses, getDiscoveryConfig, getExecutorService, setRefreshCallback, startDiscoveryTask 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
HTTPDiscoveryClusterAddressProvider
public HTTPDiscoveryClusterAddressProvider(TarantoolClusterDiscoveryConfig config)
 
 - 
 
- 
Method Detail
- 
discoverAddresses
protected Collection<TarantoolServerAddress> discoverAddresses()
- Specified by:
 discoverAddressesin classAbstractDiscoveryClusterAddressProvider
 
- 
close
public void close()
- Specified by:
 closein interfaceAutoCloseable- Specified by:
 closein interfaceTarantoolClusterAddressProvider- Overrides:
 closein classAbstractDiscoveryClusterAddressProvider
 
 - 
 
 -