-
Notifications
You must be signed in to change notification settings - Fork 398
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
cache-server: provides client-related functionality for dealing with a shard on the HTTP level #1853
cache-server: provides client-related functionality for dealing with a shard on the HTTP level #1853
Conversation
/assign @stevekuznetsov @sttts |
c1a1ba6
to
9e12c04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question, otherwise LGTM
9e12c04
to
04676f9
Compare
@stevekuznetsov I slightly changed the PR, PTAL |
04676f9
to
5921e93
Compare
pkg/cache/client/context.go
Outdated
// ShardFromContext returns the value of the shard key on the ctx, | ||
// or an empty Name if there is no shard key. | ||
func ShardFromContext(ctx context.Context) shard.Name { | ||
val, ok := ctx.Value(shardContextKey).(shard.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can be a follow-up: can just return ctx.Value(shardContextKey).(shard.Name)
since
a) the shardContextKey
is private to this package, so the only case where !ok
is if someone were to write code in this package to add something invalid
b) the zero-value is already shard.New("")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I just don't like when the code panics but sure I can change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, one last question - feel free to cancel hold
/lgtm
/approve
/hold
pkg/cache/client/round_tripper.go
Outdated
return originalPath, nil | ||
} | ||
// if the originalPath already has a shard set just overwrite it to the given one | ||
if strings.Contains(originalPath, "/shards") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this specifically not doing a prefix check for some reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as of today, we could actually check for a prefix, maybe in the future, it will have to be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
… HTTP level WithDefaultShardRoundTripper for setting a default shard in the context. WithShardRoundTripper for changing the URL path to contain a shard name defined in the context. WithShardInContext and ShardFromContext for writting/reading a shard name to/from the context. A shard package for holding a shard name in the memory.
5921e93
to
43e9e48
Compare
@stevekuznetsov updated the PR, PTAL /hold cancel |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: stevekuznetsov The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Summary
WithDefaultShardRoundTripper
for setting a default shard in the context.WithShardRoundTripper
for changing the URL path to contain a shard name defined in the context.WithShardInContext
andShardFromContext
for writting/reading a shard name to/from the context.A shard package for holding a shard name in the memory.
Related issue(s)
Fixes #