本文整理汇总了TypeScript中wicked-sdk.Callback类的典型用法代码示例。如果您正苦于以下问题:TypeScript Callback类的具体用法?TypeScript Callback怎么用?TypeScript Callback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Callback类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: callback
}, function (err, results) {
if (err)
return callback(err);
const services = results.services as KongCollection<KongService>;
const routes = results.routes as KongCollection<KongRoute>;
// Step 1: Build a service id to service map
const serviceIdMap = new Map<string, KongService>();
for (let i = 0; i < services.data.length; ++i) {
const s = services.data[i];
serviceIdMap.set(s.id, s);
}
// Step 2: Match the routes to the services
const kongApis: KongApi[] = [];
for (let i = 0; i < routes.data.length; ++i) {
const r = routes.data[i];
if (!serviceIdMap.has(r.service.id)) {
warn(`kongGetAllApis: Route ${r.id} with paths ${r.paths} has an unknown service id ${r.service.id}`);
continue;
}
kongApis.push(wicked.kongServiceRouteToApi(serviceIdMap.get(r.service.id), r));
}
return callback(null, {
data: kongApis
});
});
示例2: callback
}, function (err, authServers: WickedAuthServer[]) {
if (err)
return callback(err);
debug(JSON.stringify(authServers, null, 2));
// Fix auth server and API auth server IDs; also adapt
// the upstream_url (canonicalize it).
for (let i = 0; i < authServers.length; ++i) {
const as = authServers[i] as WickedAuthServer;
const id = `${authServerNames[i]}-auth`;
as.id = id;
if (as.config.api.hasOwnProperty('id'))
delete as.config.api.id;
as.config.api.name = id;
try {
const url = new URL(as.config.api.upstream_url);
as.config.api.upstream_url = url.toString();
} catch (err) {
const msg = `getAuthServerApis(): upstream_url for auth server ${authServerNames[i]} is not a valid URL: ${as.config.api.upstream_url}`;
return callback(new WickedError(msg, 500));
}
checkApiConfig(as.config);
}
callback(null, authServers);
});
示例3: callback
wicked.getWebhookEvents('kong-adapter', function (err, pendingEvents) {
if (err) {
error('COULD NOT RETRIEVE WEBHOOKS')
return callback(err);
}
const duration = (new Date().getTime() - now);
debug(`processPendingWebhooks: Retrieved ${pendingEvents.length} events in ${duration}ms`);
const onlyDelete = false;
if (pendingEvents.length === 0)
return callback(null, false);
async.eachSeries(pendingEvents, (webhookData: WickedEvent, callback) => {
const now = new Date().getTime();
dispatchWebhookAction(webhookData, onlyDelete, function (err) {
const duration = (new Date().getTime() - now);
debug(`processPendingWebhooks: Processed ${webhookData.action} ${webhookData.entity} event in ${duration}ms`);
if (err)
return callback(err);
return callback(null);
});
}, function (err) {
if (err) {
error('An error occurred during dispatching events.');
error(err);
return callback(err);
}
return callback(null, true);
});
});
示例4: callback
function (err, results) {
if (err) {
error(err);
error(err.stack);
return callback(err);
}
debug('getKongConsumers() succeeded.');
return callback(null, results as ConsumerInfo[]);
});