Skip to content
Please note that GitHub no longer supports your web browser.

We recommend upgrading to the latest Google Chrome or Firefox.

Learn more
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

Feature Request: Deno.Listener.rid #2862

Open
ozjd opened this issue Sep 4, 2019 · 15 comments
Open

Feature Request: Deno.Listener.rid #2862

ozjd opened this issue Sep 4, 2019 · 15 comments

Comments

@ozjd
Copy link

@ozjd ozjd commented Sep 4, 2019

As per the title, it seems strange that Deno.Listener instances do not have an exposed rid property.

@bartlomieju

This comment has been minimized.

Copy link
Contributor

@bartlomieju bartlomieju commented Sep 4, 2019

@sidntrivedi012 this is good first issue

@lucacasonato

This comment has been minimized.

Copy link
Contributor

@lucacasonato lucacasonato commented Sep 5, 2019

I'll take this one

@lucacasonato

This comment has been minimized.

Copy link
Contributor

@lucacasonato lucacasonato commented Sep 5, 2019

Before I do this, should Deno.Listener even have an rid? The description of listener is "A Listener is a generic network listener for stream-oriented protocols.". This to me means it does not per se have to have an rid because it is not per se one of "open files, sockets, and other concepts". It could also be implemented by a different library in which case it does not need an rid. I might also be completely misunderstanding this. In any case the implementation of Listener, ListenerImpl already has an rid. Can someone clarify if Listener should have an rid?

@bartlomieju

This comment has been minimized.

Copy link
Contributor

@bartlomieju bartlomieju commented Sep 5, 2019

Before I do this, should Deno.Listener even have an rid? The description of listener is "A Listener is a generic network listener for stream-oriented protocols.". This to me means it does not per se have to have an rid because it is not per se one of "open files, sockets, and other concepts". It could also be implemented by a different library in which case it does not need an rid. I might also be completely misunderstanding this. In any case the implementation of Listener, ListenerImpl already has an rid. Can someone clarify if Listener should have an rid?

You're right, there is rid field on ListenerImpl - it's marked as readonly so it already should be possible to get it's value by listener.rid.

@lucacasonato

This comment has been minimized.

Copy link
Contributor

@lucacasonato lucacasonato commented Sep 5, 2019

So this can be closed?

@ozjd

This comment has been minimized.

Copy link
Author

@ozjd ozjd commented Sep 5, 2019

There's no current way (that I can see) of accessing the rid.

https://github.com/denoland/deno/blob/master/js/net.ts#L146
The returned object is of type ListenerImpl which contains the rid, but as it's returned as a Deno.Listener in TypeScript, it can not be accessed from TS. (without using 'as any', etc.),

Am I missing something?

@bartlomieju

This comment has been minimized.

Copy link
Contributor

@bartlomieju bartlomieju commented Sep 5, 2019

There's no current way (that I can see) of accessing the rid.

https://github.com/denoland/deno/blob/master/js/net.ts#L146
The returned object is of type ListenerImpl which contains the rid, but as it's returned as a Deno.Listener in TypeScript, it can not be accessed from TS. (without using 'as any', etc.),

Am I missing something?

You're also right, basically rid should be exposed on the interface like on Conn

@sidntrivedi012

This comment has been minimized.

Copy link

@sidntrivedi012 sidntrivedi012 commented Sep 5, 2019

@sidntrivedi012 this is good first issue

Hey @bartlomieju , thanks a lot for pointing this issue out. Will look into it. Thanks :).

@kevinkassimo

This comment has been minimized.

Copy link
Contributor

@kevinkassimo kevinkassimo commented Sep 5, 2019

For @sidntrivedi012 @lucacasonato and other new contributors, also notice that we have https://github.com/denoland/deno_std that needs quite a bit help (it is the standard modules of Deno). It is modeled after Go (and maybe a bit of Python)'s standard library (to avoid unneeded dependency problems that happened in Node), but we are still lacking a lot of features there. It would also be very cool if you want to contribute to it (deno_std is about TypeScript, in comparison to Deno core, which is the bare minimum and more involving in coding in Rust)

@kevinkassimo

This comment has been minimized.

Copy link
Contributor

@kevinkassimo kevinkassimo commented Sep 5, 2019

Also I agree that Deno.Listener itself should not expose rid as it is quite a general interface. We might however make ListenerImpl implement something like NetListener with rid property that extends from Deno.Listener, since I do feel that direct access to rid is probably useful

@ozjd

This comment has been minimized.

Copy link
Author

@ozjd ozjd commented Sep 5, 2019

The actual rid property already exists on the object, it's just a question of the best way to expose it.

I guess the question is where is Listener used outside of ListenerImpl? Does it have a rid? Would a null rid be appropriate?

It seems logical to me that Listener would expose the ListenerImpl.rid, just as Conn exposes ConnImpl.rid - but I'm not sure of Listener's uses (or planned uses)

@nayeemrmn

This comment has been minimized.

Copy link
Contributor

@nayeemrmn nayeemrmn commented Sep 5, 2019

Confusing questions like this will always arise when you have interface Thing and class ThingImpl implements Thing 😔

@sidntrivedi012

This comment has been minimized.

Copy link

@sidntrivedi012 sidntrivedi012 commented Sep 6, 2019

For @sidntrivedi012 @lucacasonato and other new contributors, also notice that we have https://github.com/denoland/deno_std that needs quite a bit help (it is the standard modules of Deno).

Sure, since I am currently learning Javascript and planning to learn typescript as soon as possible. Thus, will jump in soon. Thanks :)

@lucacasonato

This comment has been minimized.

Copy link
Contributor

@lucacasonato lucacasonato commented Sep 10, 2019

So should

  1. Listener have an rid
  2. ListenerImpl implement a new class NetListener which extends Listener and has an rid and listen returns NetListener
  3. listen return ListenerImpl rather than Listener?
  4. something else - please specify

Once I know what should happen I can implement it.

@ry @piscisaureus @kevinkassimo @bartlomieju

@bartlomieju

This comment has been minimized.

Copy link
Contributor

@bartlomieju bartlomieju commented Sep 10, 2019

IMHO Listener have an rid. I can imagine someone doing:

const listener = Deno.listen(...);
...
close(listener.rid);

instead of :

const listener = Deno.listen(...);
...
listener.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
6 participants
You can’t perform that action at this time.