-
Notifications
You must be signed in to change notification settings - Fork 399
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
Change to Storage interface to accept context interface #82
Comments
at first glance, I'm not a fan of this. Are there other ways to accomplish what you need the context for? |
Not really. As go doesn't have a way of getting a goroutine id it's not possible have something on one side of the library and get it the other side of the library. The lack of go routine id means the go answer to this is the context package. I made the context to be interface{} so that can be upto the developer what that context would be. Any alternatives without making breaking changes would be very welcome. |
I'm curious what information you would need to plumb through in a context... shouldn't the client id, token id, etc, be sufficient? |
The target is for contextual logging where we have 100s of calls per second, which means it's important to track errors with a request id and potentially other contextual information. It is not desired to have access tokens/refresh tokens in clear text in the logs. Potentially too, it could be that the storage understands the context and behaves differently dependant on that context. |
In general, I think plumbing a slush bucket context through interfaces isn't a great approach. Where does the line get drawn? Which interfaces should include a context and which shouldn't? Why do none of the golang interfaces include a context, if this is the recommended design pattern? |
Well, you might not see it as a great approach. It is though a common pattern in web stuff. See grpc example: Also As discussed before how google requires it's calls to be made: |
Another way that you could look to do this is, Response has a Storage field, that you could possibly modify a property or put another Storage entirely, maybe with your context in it. All HandleXXX functions always use the storage on the Response struct, never directly on Server. |
This would support stores to abort a request (e.g. RESTful request) if the token request was aborted due to an error or similar. The Go Team wanted to add a context param to all the SQL query commands in Go 1.5, but it seems like they didn't finish it in time. So even if this isn't relevant for SQL queries right now, it will be in the future. I myself am not a huge fan of context variables because the scope is kinda blurry and requires a lot of boilerplate code. But it's coming and nobody can stop it, so better go with it. |
@RangelReale while it would be possible, it's not a very attractive solution to recreate the storage each time with a new context. Hmmm. |
If you do plan to implement this, I would recommend that you use context.Context rather than Also, with the changes coming to database/sql to support Context timeouts it makes even more sense. |
Hi, I want to use this library on GoogleAppEngine & Datastore. |
Issues go stale after 90d of inactivity. Mark the issue as fresh by commenting If this issue is safe to close now please do so with /lifecycle stale |
/remove-lifecycle stale But really, it seems this whole project is stale. Is it no longer maintained? |
Issues go stale after 90d of inactivity. Mark the issue as fresh by commenting If this issue is safe to close now please do so with /lifecycle stale |
/remove-lifecycle stale |
/lifecycle frozen |
I would like to modify the storage interface to accept an interface for context information.
i.e.
It would also require changes to the response to accept a Context to be included in the response that could be passed into the storage calls.
This would be a breaking change. Would this be considered for a merge?
The text was updated successfully, but these errors were encountered: