This repository has been archived by the owner on Jun 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vasco-santos
suggested changes
Jul 16, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great!!
src/index.js
Outdated
@@ -166,15 +168,16 @@ class PubsubBaseProtocol extends EventEmitter { | |||
* @private | |||
* @param {Object} props | |||
* @param {string} props.protocol | |||
* @param {DuplexStream} props.strean | |||
* @param {Stream} props.stream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
* @param {Stream} props.stream | |
* @param {IterableStream} props.stream |
Per https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9, we should call this an IterableStream. This is not a node stream and might create confusion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I called it DuplexIterableStream
so its known to be a duplex object ({ sink, source }
)
vasco-santos
approved these changes
Jul 16, 2020
26 tasks
vasco-santos
pushed a commit
that referenced
this pull request
Aug 11, 2020
This was referenced Aug 28, 2020
Closed
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #54 and #56
Peer
has been renamed/replaced withPeerStreams
class that manages incoming and outgoing streams._addPeer
and_removePeer
have been slightly modified to suit - _removePeer closes a peer's streamsgetSubscribers
now usesthis.topics
rather thanpeer.topics
to determine the subscribers for a topicPeerStreams
manages:id
- thePeerId
of the peerprotocol
- the protocol negotiated with the peer (previously was an array of protocols, which is described in Outgoing peer connections - peer protocols #54 )_rawOutboundStream
(previously namedthis.conn
) - this is the stream returned fromconn.newStream
outboundStream
(previously namedthis.stream
) - this is the pushable stream to write outgoing messages to. Data pushed here is sent to _rawOutboundStream after first being transformed with a length-prefix encoding transform.It now manages an inbound stream as well
_rawInboundStream
- this is the stream returned in the callback attached toregistrar.handle
. Called when a peer dials us.inboundStream
- this is an abortable stream with first a length-prefix decoding tranform applied. This is the stream that should be read from to receive incoming rpc messages.async attachOutboundStream(stream)
- method to attach a new outgoing stream for management. If the stream is the first outgoing stream to be attached, this method triggers astream:outbound
event. If there is already an existing outgoing stream, the existing stream is gently shutdown (without triggering aclose
event) first, then the new stream is attached.attachInboundStream(stream)
- method to attach a new incoming stream for management. If the stream is the first incoming stream to be attached, this method triggers astream:inbound
event. If there is already an existing incoming stream, the existing stream is gently shutdown (without triggering aclose
event) first, then the new stream is attached.write(data)
- convenience method to push data to theoutboundStream
, if it exists. If it doesn't, this method throws an error.close()
- method to shutdown both incoming and outgoing streams, triggers aclose
event. In conjunction with the base Pubsub impl, theclose
event will_removePeer
.