Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

NoDial context option #42

Merged
merged 3 commits into from
Apr 10, 2019
Merged

NoDial context option #42

merged 3 commits into from
Apr 10, 2019

Conversation

vyzo
Copy link
Contributor

@vyzo vyzo commented Apr 10, 2019

This is an option to instruct the swarm not to dial when opening a new stream.
Essential for (non-active) relays that should never attempt any dials in hop streams.

@vyzo vyzo requested a review from Stebalien April 10, 2019 17:56
@ghost ghost assigned vyzo Apr 10, 2019
@ghost ghost added the in progress label Apr 10, 2019
This is an option to instruct the swarm not to dial when opening a new stream.
Essential for (non-active) relays that should never attempt any dials in hop streams.

func WithNoDial(ctx context.Context, src string) {
context.WithValue(ctx, NoDial, src)
}
Copy link
Member

Choose a reason for hiding this comment

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

So, personally, I'd not expose the NoDial var but instead expose a GetNoDial(ctx) (nodial bool, why string) function. That way, we can change how we implement all this internally.

For example, we may want to "lift" all of our options into an option struct if we end up chaining contexts too much (searching for a value in a context is O(n)).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, will do.

Copy link
Member

Choose a reason for hiding this comment

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

(I mean, this just comes down to "patterns" but I believe this is the more common pattern.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

image

(ok, a bit big)

@vyzo vyzo merged commit 673b626 into master Apr 10, 2019
@ghost ghost removed the in progress label Apr 10, 2019
@vyzo vyzo deleted the feat/no-dial-option branch April 10, 2019 18:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants