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

Modify request behaviour #213

Closed
mStirner opened this issue Oct 30, 2022 · 0 comments
Closed

Modify request behaviour #213

mStirner opened this issue Oct 30, 2022 · 0 comments

Comments

@mStirner
Copy link
Member

When no interface is attached (connector) its not possible to read/write from/to the upstream.
How about to attach a event listener to the interface and backpressure the request till the interface has a attached upstream/is bridged?

Pseudo code/draft (class.interface.js)

agent.createConnection = (options, cb) => {

    let input = new PassThrough();
    let output = new PassThrough();


    this.stream.pipe(input, {
        end: false
    });
    output.pipe(this.stream, {
        end: false
    });


    let socket = Duplex.from({
        readable: input,
        writable: output
    });


    // TODO implement other socket functions?!
    if (process.env.NODE_ENV !== "production") {
        socket.ref = (...args) => {
            console.log("socket.ref called", ...args);
        };
        socket.unref = (...args) => {
            console.log("socket.unref called", ...args);
        };
        socket.setKeepAlive = (...args) => {
            console.log("socket.setKeepAlive called", ...args);
        };
        socket.setTimeout = (...args) => {
            console.log("socket.setTimeout called", ...args);
        };
        socket.setNoDelay = (...args) => {
            console.log("socket.setNoDelay called", ...args);
        };
        // socket.remoteAddress=this.settings.host
        // socket.remotePort=this.settings.port
    }

    // pseude code. "attached" does not exists
    if (this.stream.attached) {
        cb(null, socket);
        return;
    }

    this.stream.once("attached", () => {
        //return socket;
        cb(null, socket);
    });

};

Does the request timeout when the callback not get called for a long time?

@mStirner mStirner added this to the v2.0.0 release milestone Oct 30, 2022
@mStirner mStirner added close Discuss to be closed or closed soon and removed close Discuss to be closed or closed soon labels Nov 18, 2022
@mStirner mStirner mentioned this issue Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant