Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rca support #148

Merged
merged 14 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/tdf3/src/client/DecoratedReadableStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export abstract class DecoratedReadableStream {
manifest: Manifest;
upsertResponse?: UpsertResponse;

constructor(byteLimit: number, underlyingSource: UnderlyingSource) {
this.stream = new ReadableStream(underlyingSource, { highWaterMark: byteLimit });
constructor(underlyingSource: UnderlyingSource) {
this.stream = new ReadableStream(underlyingSource, { highWaterMark: 1 });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC this will always immediately write whatever to the underlying stream. Which makes sense, as this is just supposed to be a proxy, not a buffer.

this.ee = new EventEmitter();
this.on = (...args) => this.ee.on(...args);
this.emit = (...args) => this.ee.emit(...args);
Expand Down
2 changes: 1 addition & 1 deletion lib/tdf3/src/client/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { EntityObject } from '../../../src/tdf/EntityObject.js';

const { get } = axios;

export const DEFAULT_SEGMENT_SIZE: number = 1000 * 1000;
export const DEFAULT_SEGMENT_SIZE: number = 1024 * 1024;
export type VirtruS3Config = S3ClientConfig & {
Bucket?: string;
};
Expand Down
2 changes: 1 addition & 1 deletion lib/tdf3/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export class Client {
return null;
}

return makeStream(windowSize, {
return makeStream({
pull(controller: ReadableStreamDefaultController) {
controller.enqueue(htmlBuf);
controller.close();
Expand Down
7 changes: 2 additions & 5 deletions lib/tdf3/src/client/tdf-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ export function registerModuleType(factory: AnyTdfStreamCtor) {
_stream.factory = factory;
}

export function makeStream(
a: ConstructorParameters<AnyTdfStreamCtor>[0],
b: ConstructorParameters<AnyTdfStreamCtor>[1]
): DecoratedReadableStream {
export function makeStream(a: ConstructorParameters<AnyTdfStreamCtor>[0]): DecoratedReadableStream {
if (!_stream.factory) {
throw Error('Stream factory misconfigured');
}
return new _stream.factory(a, b);
return new _stream.factory(a);
}
4 changes: 2 additions & 2 deletions lib/tdf3/src/tdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ class TDF extends EventEmitter {
},
};

const plaintextStream = makeStream(segmentSizeDefault, underlingSource);
const plaintextStream = makeStream(underlingSource);

if (upsertResponse) {
plaintextStream.upsertResponse = upsertResponse;
Expand Down Expand Up @@ -923,7 +923,7 @@ class TDF extends EventEmitter {

// eslint-disable-next-line @typescript-eslint/no-this-alias
const that = this;
const outputStream = makeStream(this.segmentSizeDefault, {
const outputStream = makeStream({
async pull(controller: ReadableStreamDefaultController) {
while (
segments.length &&
Expand Down
6 changes: 3 additions & 3 deletions lib/tests/mocha/client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ describe('tdf stream tests', function () {
});
it('plaintext stream string', async function () {
const pt = new TextEncoder().encode('hello world');
const stream = new NodeTdfStream(1000, {
const stream = new NodeTdfStream({
start(controller) {
controller.enqueue(pt);
controller.close();
Expand All @@ -166,7 +166,7 @@ describe('tdf stream tests', function () {
});
it('plaintext stream buffer', async function () {
const pt = new TextEncoder().encode('hello world');
const stream = new NodeTdfStream(1000, {
const stream = new NodeTdfStream({
start(controller) {
controller.enqueue(pt);
controller.close();
Expand All @@ -177,7 +177,7 @@ describe('tdf stream tests', function () {
it('plaintext stream file', async function () {
const pt = 'hello world';
const filename = `${TEMP_DIR}/plain.txt`;
const stream = new NodeTdfStream(1000, {
const stream = new NodeTdfStream({
start(controller) {
controller.enqueue(pt);
controller.close();
Expand Down