mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 09:45:36 +08:00
Share durable permits across manual, scheduled and recovered runs, prioritize short ready tasks with aging, and record global queue occupancy. Reduce launch, log polling, dashboard and SQLite overhead while preserving transactional receipts, cancellation, recovery and script hook compatibility. Keep ordinary CRUD in ORM and bound SQL on measured execution hot paths. Fix supervisor descendant tracking, asynchronous log draining, concurrent log directory creation, Linux fallback launches and snapshot clock rollback. Include regression coverage, SQL audits and evolution/review documentation. Validation: five review rounds; local full suite 1478 passed, 28 platform skips; dev suites 415 passed, no failures/skips; backend types and formatting passed.
26 lines
907 B
TypeScript
26 lines
907 B
TypeScript
import type {
|
|
UntypedServiceImplementation,
|
|
sendUnaryData,
|
|
} from '@grpc/grpc-js';
|
|
import { ApiService } from '../protos/api';
|
|
|
|
// Registration/health never need the script API's HTTP-oriented services.
|
|
// Keep their dependency graph out of an ordinary scheduler's resident heap.
|
|
// Dynamic import shares initialization across simultaneous first calls; the
|
|
// normal handlers retain validation, callback errors and service singletons.
|
|
export function lazyApiHandlers(): UntypedServiceImplementation {
|
|
return Object.fromEntries(
|
|
Object.keys(ApiService).map((method) => [
|
|
method,
|
|
(call: unknown, callback: sendUnaryData<unknown>) => {
|
|
void import('./api')
|
|
.then((handlers) => {
|
|
const handler = handlers[method as keyof typeof ApiService];
|
|
return handler(call as never, callback);
|
|
})
|
|
.catch(callback);
|
|
},
|
|
]),
|
|
);
|
|
}
|