mirror of
https://github.com/whyour/qinglong.git
synced 2026-09-21 01:00:24 +08:00
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import type { RunDispatchLeaseRecord } from '../domain/runDispatchLease';
|
|
import type { ReleaseRunDispatchLeaseResult } from '../ports/runDispatchLeaseRepository';
|
|
import type { WorkerRunLeaseClient } from '../ports/workerRunLeaseClient';
|
|
import type {
|
|
FencedRunDispatchLeaseRequest,
|
|
ReleaseRunDispatchLeaseRequest,
|
|
} from './runDispatchLeaseService';
|
|
import { RunDispatchLeaseService } from './runDispatchLeaseService';
|
|
import type { AuthenticatedWorkerPrincipal } from './workerControlService';
|
|
|
|
/**
|
|
* Transport seam: the authenticated principal is fixed when the client is
|
|
* constructed and can never be supplied by a Worker request body.
|
|
*/
|
|
export class BoundWorkerRunLeaseClient implements WorkerRunLeaseClient {
|
|
constructor(
|
|
private readonly service: RunDispatchLeaseService,
|
|
private readonly principal: AuthenticatedWorkerPrincipal,
|
|
) {}
|
|
|
|
renew(
|
|
request: FencedRunDispatchLeaseRequest,
|
|
): Promise<RunDispatchLeaseRecord> {
|
|
return this.service.renew(this.principal, request);
|
|
}
|
|
|
|
release(
|
|
request: ReleaseRunDispatchLeaseRequest,
|
|
): Promise<ReleaseRunDispatchLeaseResult> {
|
|
return this.service.release(this.principal, request);
|
|
}
|
|
}
|