chore: interface abstractions

This commit is contained in:
Danish Arora 2025-11-26 21:20:01 -05:00
parent 959cad9a4d
commit b437e19d3c
No known key found for this signature in database
GPG Key ID: 1C6EF37CDAE1426E
2 changed files with 9 additions and 10 deletions

View File

@ -48,6 +48,11 @@ export interface ILocalHistory {
): number;
}
export interface MemLocalHistoryOptions {
storage?: ChannelId | PersistentStorage;
maxSize?: number;
}
export class MemLocalHistory implements ILocalHistory {
private items: ContentMessage[] = [];
private readonly storage?: PersistentStorage;
@ -60,9 +65,7 @@ export class MemLocalHistory implements ILocalHistory {
* - storage: Optional persistent storage backend for message persistence or channelId to use with PersistentStorage.
* - maxSize: The maximum number of messages to store. Optional, defaults to DEFAULT_MAX_LENGTH.
*/
public constructor(
opts: { storage?: ChannelId | PersistentStorage; maxSize?: number } = {}
) {
public constructor(opts: MemLocalHistoryOptions = {}) {
const { storage, maxSize } = opts;
this.maxSize = maxSize ?? DEFAULT_MAX_LENGTH;
if (storage instanceof PersistentStorage) {

View File

@ -15,7 +15,8 @@ import {
} from "./message.js";
import {
DEFAULT_BLOOM_FILTER_OPTIONS,
MessageChannel
MessageChannel,
MessageChannelOptions
} from "./message_channel.js";
const channelId = "test-channel";
@ -30,12 +31,7 @@ const callback = (_message: Message): Promise<{ success: boolean }> => {
const createTestChannel = (
channelId: string,
senderId: string,
options: {
causalHistorySize?: number;
possibleAcksThreshold?: number;
timeoutForLostMessagesMs?: number;
enableRepair?: boolean;
} = {}
options: MessageChannelOptions = {}
): MessageChannel => {
return new MessageChannel(
channelId,