Skip to content

Commit 0ff2b34

Browse files
chore: interface abstractions
1 parent abb1da8 commit 0ff2b34

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

packages/sds/src/message_channel/mem_local_history.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ export interface ILocalHistory {
4848
): number;
4949
}
5050

51+
export interface MemLocalHistoryOptions {
52+
storage?: ChannelId | PersistentStorage;
53+
maxSize?: number;
54+
}
55+
5156
export class MemLocalHistory implements ILocalHistory {
5257
private items: ContentMessage[] = [];
5358
private readonly storage?: PersistentStorage;
@@ -60,9 +65,7 @@ export class MemLocalHistory implements ILocalHistory {
6065
* - storage: Optional persistent storage backend for message persistence or channelId to use with PersistentStorage.
6166
* - maxSize: The maximum number of messages to store. Optional, defaults to DEFAULT_MAX_LENGTH.
6267
*/
63-
public constructor(
64-
opts: { storage?: ChannelId | PersistentStorage; maxSize?: number } = {}
65-
) {
68+
public constructor(opts: MemLocalHistoryOptions = {}) {
6669
const { storage, maxSize } = opts;
6770
this.maxSize = maxSize ?? DEFAULT_MAX_LENGTH;
6871
if (storage instanceof PersistentStorage) {

packages/sds/src/message_channel/message_channel.spec.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
} from "./message.js";
1616
import {
1717
DEFAULT_BLOOM_FILTER_OPTIONS,
18-
MessageChannel
18+
MessageChannel,
19+
MessageChannelOptions
1920
} from "./message_channel.js";
2021

2122
const channelId = "test-channel";
@@ -30,12 +31,7 @@ const callback = (_message: Message): Promise<{ success: boolean }> => {
3031
const createTestChannel = (
3132
channelId: string,
3233
senderId: string,
33-
options: {
34-
causalHistorySize?: number;
35-
possibleAcksThreshold?: number;
36-
timeoutForLostMessagesMs?: number;
37-
enableRepair?: boolean;
38-
} = {}
34+
options: MessageChannelOptions = {}
3935
): MessageChannel => {
4036
return new MessageChannel(
4137
channelId,

0 commit comments

Comments
 (0)