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

Requestor #4

Open
Wondertan opened this issue Oct 2, 2021 · 0 comments
Open

Requestor #4

Wondertan opened this issue Oct 2, 2021 · 0 comments

Comments

@Wondertan
Copy link
Member

Wondertan commented Oct 2, 2021

Context

As explained in README, the most popular libp2p pattern is request/response and the goal here is to provide utility for it.

Design

type Requestor struct { 
// some private fields 
}
// NewRequestor instantiates new Requestor for a given protocol ID with specified request and response
// message types.
NewRequestor(protocol.Id, serde.Message, serde.Message) *Requestor

// Request sends the request as given message, blocks until a message is written, and returns a       
// channel awaiting for a response. 
// NOTE: This can also be done in fully non-blocking fashion if needed.
func (r *Requestor) Request(peer.ID, serde.Message) <-chan serde.Message, error
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

No branches or pull requests

1 participant