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

Expose some read-only methods on the underlying Stream interface #67

Merged
merged 3 commits into from
Aug 18, 2022

Conversation

dirkmc
Copy link
Contributor

@dirkmc dirkmc commented Mar 9, 2022

This is useful to clients of the library who want to cast the net.Conn instance into a gostream.Stream instance, so as to be able to read particulars of the underlying stream (eg the stream ID).

A concrete use case: a client of the library wants to listen to network events, and needs to be able to get the stream ID from the connection to identify which events pertain to the connection.

conn.go Outdated
@@ -11,12 +11,20 @@ import (
"github.com/libp2p/go-libp2p-core/protocol"
)

// Stream is a subset of the read-only methods on the network.Stream interface
type Stream interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't we use the network.Stream interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point - I changed the code to override network.Stream instead of re-implementing each of its methods to call the underlying implementation

@dirkmc
Copy link
Contributor Author

dirkmc commented Aug 16, 2022

@marten-seemann sorry for taking so long to follow up on this - could you please take another look when you get a chance 🙏

@dirkmc
Copy link
Contributor Author

dirkmc commented Aug 18, 2022

@marten-seemann could you please make a release of gostream that targets this commit 🙏
We would like to depend on it from boost.

@marten-seemann marten-seemann merged commit 3f2ab62 into master Aug 18, 2022
@marten-seemann
Copy link
Contributor

@dirkmc #71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants