Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
be0d2482
Commit
be0d2482
authored
Jun 05, 2015
by
CJ Cullen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a RateLimiter for the gce altTokenSource.
parent
66d2e1cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
token_source.go
pkg/cloudprovider/gce/token_source.go
+12
-0
No files found.
pkg/cloudprovider/gce/token_source.go
View file @
be0d2482
...
...
@@ -21,17 +21,28 @@ import (
"net/http"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"code.google.com/p/google-api-go-client/googleapi"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
)
const
(
// Max QPS to allow through to the token URL.
tokenURLQPS
=
1
// Maximum burst of requests to token URL before limiting.
tokenURLBurst
=
3
)
type
altTokenSource
struct
{
oauthClient
*
http
.
Client
tokenURL
string
throttle
util
.
RateLimiter
}
func
(
a
*
altTokenSource
)
Token
()
(
*
oauth2
.
Token
,
error
)
{
a
.
throttle
.
Accept
()
req
,
err
:=
http
.
NewRequest
(
"GET"
,
a
.
tokenURL
,
nil
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -62,6 +73,7 @@ func newAltTokenSource(tokenURL string) oauth2.TokenSource {
a
:=
&
altTokenSource
{
oauthClient
:
client
,
tokenURL
:
tokenURL
,
throttle
:
util
.
NewTokenBucketRateLimiter
(
tokenURLQPS
,
tokenURLBurst
),
}
return
oauth2
.
ReuseTokenSource
(
nil
,
a
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment