blob: b3135e6796ff43e6f2a55b66c62710541479b036 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
local methods = {};
local resolver_mt = { __index = methods };
-- Find the next target to connect to, and
-- pass it to cb()
function methods:next(cb)
if self.resolvers then
if not self.resolver then
if #self.resolvers == 0 then
cb(nil);
return;
end
local next_resolver = table.remove(self.resolvers, 1);
self.resolver = next_resolver;
end
self.resolver:next(function (...)
if self.resolver then
self.last_error = self.resolver.last_error;
end
if ... == nil then
self.resolver = nil;
self:next(cb);
else
cb(...);
end
end);
return;
end
end
local function new(resolvers)
return setmetatable({ resolvers = resolvers }, resolver_mt);
end
return {
new = new;
};
|