Skip to content

Commit 99f8d67

Browse files
committed
endpoint: ProducerHandler returns Promisable
1 parent e9de9a3 commit 99f8d67

6 files changed

Lines changed: 9 additions & 7 deletions

File tree

pkg/endpoint/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"@ndn/packet": "workspace:*",
3131
"@ndn/util": "workspace:*",
3232
"streaming-iterables": "^8.0.1",
33-
"tslib": "^2.8.1"
33+
"tslib": "^2.8.1",
34+
"type-fest": "^5.7.0"
3435
},
3536
"devDependencies": {
3637
"@ndn/keychain": "workspace:*",

pkg/endpoint/src/producer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Forwarder, type FwFace, FwPacket } from "@ndn/fw";
22
import { Data, Interest, Name, type NameLike, Signer } from "@ndn/packet";
33
import { flatTransform } from "streaming-iterables";
4+
import type { Promisable } from "type-fest";
45

56
import { type CommonOptions, exactOptions } from "./common";
67
import type { DataBuffer } from "./data-buffer";
@@ -19,7 +20,7 @@ import type { DataBuffer } from "./data-buffer";
1920
* - {@link ProducerOptions.dataBuffer} is unset: cause a timeout.
2021
* - {@link ProducerOptions.dataBuffer} is provided: query the DataBuffer.
2122
*/
22-
export type ProducerHandler = (interest: Interest, producer: Producer) => Promise<Data | undefined>;
23+
export type ProducerHandler = (interest: Interest, producer: Producer) => Promisable<Data | undefined>;
2324

2425
/** {@link produce} options. */
2526
export interface ProducerOptions extends CommonOptions {
@@ -29,7 +30,7 @@ export interface ProducerOptions extends CommonOptions {
2930
* @defaultValue `true`
3031
*
3132
* @remarks
32-
* If all nexthops of a FIB entry are set to non-capture, FIB lookup may continue onto nexthops
33+
* If all next-hops of a FIB entry are set to non-capture, FIB lookup may continue onto next-hops
3334
* on FIB entries with shorter prefixes. One use case is in dataset synchronization protocols,
3435
* where both local and remote sync participants want to receive each other's Interests.
3536
*/

pkg/ndncert/src/server/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class Server {
122122
}
123123
}
124124

125-
private readonly handleInfoInterest: ProducerHandler = async () => this.profile.data;
125+
private readonly handleInfoInterest: ProducerHandler = () => this.profile.data;
126126

127127
private readonly handleProbeInterest: ProducerHandler = async (interest) => {
128128
let request: ProbeRequest;

pkg/psync/src/partial-publisher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class PartialPublisher extends TypedEventTarget<EventMap> implements Sync
115115
return this.c.add(prefix);
116116
}
117117

118-
private readonly handleHelloInterest: ProducerHandler = async (interest) => {
118+
private readonly handleHelloInterest: ProducerHandler = (interest) => {
119119
if (interest.name.length !== this.syncPrefix.length + 1) {
120120
// segment Interest should be satisfied by StateProducerBuffer
121121
return undefined;

pkg/segmented-object/src/serve/data-producer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export abstract class DataProducer {
4141
}
4242
}
4343

44-
public readonly processInterest: ProducerHandler = (interest: Interest): Promise<Data | undefined> => {
44+
public readonly processInterest: ProducerHandler = (interest) => {
4545
const segmentNum = this.parseInterest(interest);
4646
return this.getData(segmentNum);
4747
};

pkg/svs/src/publisher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class SvPublisher {
126126
return seqNum;
127127
}
128128

129-
private readonly handleOuter: ProducerHandler = async (interest) => {
129+
private readonly handleOuter: ProducerHandler = (interest) => {
130130
if (!interest.name.get(this.nodeSyncPrefix.length)?.is(GenericNumber)) {
131131
return undefined;
132132
}

0 commit comments

Comments
 (0)