rmapi-js
    Preparing search index...

    Interface Platform

    everything the core needs from where it runs

    A promise rejects only when there was no answer at all: a status outside 2xx is an answer. Only a request with retryable set may be sent again after a failure.

    interface Platform {
        maxBatch?: number;
        state: StateStore;
        store: Store;
        connect(
            request: PlatformRequest,
        ): Promise<PlatformSocket | PlatformResponse>;
        download(
            request: PlatformRequest,
            received: (bytes: number) => void,
            signal: AbortSignal,
        ): Promise<PlatformResponse | Stored>;
        hash(source: BodySource): Promise<BodyHashes>;
        keep(body: Body): Promise<BodyHashes>;
        sendMany(
            requests: PlatformRequest[],
        ): Promise<PromiseSettledResult<HashedResponse>[]>;
        upload(
            request: PlatformRequest,
            source: BodySource,
        ): Promise<PlatformResponse>;
    }
    Index
    maxBatch?: number

    the most requests one sendMany call carries, and the most blobs one has or put of the store: 1024 if absent

    Read once, when a client is made from the platform.

    state: StateStore

    where a library keeps its saved state

    store: Store

    where blobs are kept

    • makes the GET and stores what it reads under its own sha-256, calling received with the bytes that have arrived so far as they do, from 0 again if it starts over, and stopping, storing nothing, when signal aborts

      Parameters

      • request: PlatformRequest
      • received: (bytes: number) => void
      • signal: AbortSignal

      Returns Promise<PlatformResponse | Stored>

    • the hashes of source, reading the whole of it unless they came with it, rejecting with an UnavailableError whose hash names a stored source the store lacks

      Parameters

      Returns Promise<BodyHashes>

    • stores body under its own sha-256, whole or not at all, and resolves to its hashes

      Parameters

      Returns Promise<BodyHashes>

    • makes every request and settles each, in order, as Promise.allSettled does: a request that produced no answer is rejected in its own place and fails none of the others

      Each answer carries the sha-256 of its body, which the core checks a blob it reads against; a statusOnly answer carries that of its empty body.

      Never more than maxBatch requests: more than that asked in the same moment come as several calls, out at once. A request that is not retryable always comes alone.

      Parameters

      Returns Promise<PromiseSettledResult<HashedResponse>[]>