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

contexts #29

Merged
merged 4 commits into from Mar 14, 2017
Merged

contexts #29

merged 4 commits into from Mar 14, 2017

Conversation

progrium
Copy link
Contributor

Implements a special ssh.Context that captures gossh.ConnMetadata and context.Context made for better callbacks and session setup, then exposed as regular context.Context on ssh.Session

Standardizes callbacks more while giving them access to more information and letting them contribute to state that would be made available to Session handler. Removes the need for PermissionsCallback as Permissions are exposed on ssh.Context. Generally simplifies code overall, while increasing capabilities, and remaining fairly Go idiomatic.

Todo: godocs, more tests

… to go with it

Signed-off-by: Jeff Lindsay <progrium@gmail.com>
@progrium
Copy link
Contributor Author

cc @belak

context.go Outdated
}
// for most of these, instead of converting to strings now, storing the byte
// slices means allocations only happen when accessing, not when contexts
// are being copied around
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Though after I saw how context.WithValue is implemented this might not be an issue.

session.go Outdated
@@ -43,6 +44,10 @@ type Session interface {
// used it will return nil.
PublicKey() PublicKey

Context() context.Context
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be worthwhile ensuring there are methods for everything exported by the ssh.Context? Especially if we're returning this as a context.Context here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sigh. The problem is the Session interface is already sooooo huuuuuge and it's only going to get bigger with signals and I also added Permissions. Interfaces should be small. A lot of the rest of what's in ssh.Context does qualify as "to inform, not to control" and is more for maintainers than users (at least how I interpret it). So it might feel inconsistent, but at the moment I'm ok with the tradeoff.

Signed-off-by: Jeff Lindsay <progrium@gmail.com>
Signed-off-by: Jeff Lindsay <progrium@gmail.com>
Signed-off-by: Jeff Lindsay <progrium@gmail.com>
@progrium progrium changed the title [WIP] contexts contexts Feb 22, 2017
@progrium
Copy link
Contributor Author

Actually I think it's pretty much done with godocs and enough testing for now. Would like some more reviews first though.

Copy link
Member

@shazow shazow left a comment

Choose a reason for hiding this comment

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

Took a quick skim right before a flight, looks good, no red flags. :shipit:

@progrium
Copy link
Contributor Author

@shazow thanks!

@hloeffler
Copy link
Contributor

LGTM

@progrium progrium merged commit 9b56478 into master Mar 14, 2017
@progrium
Copy link
Contributor Author

Merged after running in (alpha) production in Cmd.io for 20 days.

@josegonzalez josegonzalez deleted the context branch April 27, 2017 00:18
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.

None yet

4 participants