Synclets logoSynclets

MetaConnectorImplementations

The MetaConnectorImplementations type lists the async functions required to read and write Timestamps.

{
  connect?: () => Promise<void>;
  disconnect?: () => Promise<void>;
  readTimestamp: (address: TimestampAddress<Depth>) => Promise<Timestamp | undefined>;
  writeTimestamp: (address: TimestampAddress<Depth>, timestamp: Timestamp) => Promise<void>;
  readChildIds: (address: AnyParentAddress<Depth>) => Promise<string[]>;
}
TypeDescription
connect?() => Promise<void>

The connect callback is invoked when the Synclet starts. It can perform one-time initialization tasks such as creating database tables for timestamp storage or opening file handles. Unlike DataConnector's connect, this callback does not receive a change notification function since timestamps are only modified by the Synclet itself.

disconnect?() => Promise<void>

The disconnect callback is invoked when the Synclet is destroyed. It should clean up any resources allocated during connect, such as closing file handles, database connections, or removing event listeners. The connector will not be used after this callback returns.

readTimestamp(address: TimestampAddress<Depth>) => Promise<Timestamp | undefined>

The readTimestamp callback must retrieve the Timestamp string stored at the specified address in the metadata tree. Return the Timestamp if it exists, or undefined if the address contains no timestamp. This callback is called frequently during conflict resolution, so efficient implementations are important for sync performance.

writeTimestamp(address: TimestampAddress<Depth>, timestamp: Timestamp) => Promise<void>

The writeTimestamp callback must persist the provided Timestamp string at the specified address in the metadata tree, overwriting any existing timestamp. Timestamps use Hybrid Logical Clock (HLC) format and are critical for conflict resolution. Ensure the write is atomic to prevent inconsistent metadata states.

readChildIds(address: AnyParentAddress<Depth>) => Promise<string[]>

The readChildIds callback must return an array of child ID strings that have timestamps stored under the specified parent address. The structure mirrors the data tree but contains timestamp child IDs instead of Atom child IDs. Return an empty array if the address has no children with timestamps.

Since

v0.0.0