-
Notifications
You must be signed in to change notification settings - Fork 880
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Cosmos] Adds global endpoint manager policy and links GEM to client (#…
…22223) * added policy and linked gem to client * refactor go routine for CI pipeline lint * remove debugging print statement * changed to internal pipeline, updated tests * removed unneeded code * saved apiVersion into constant, changed all explicit uses to constant * add gem policy emulator test * small changes to the test * clean up test * pass preferred regions * removed excess comments * add nil check to client options for preferred regions
- Loading branch information
Showing
7 changed files
with
145 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
sdk/data/azcosmos/cosmos_global_endpoint_manager_policy.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package azcosmos | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
|
||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" | ||
) | ||
|
||
type globalEndpointManagerPolicy struct { | ||
gem *globalEndpointManager | ||
} | ||
|
||
func (p *globalEndpointManagerPolicy) Do(req *policy.Request) (*http.Response, error) { | ||
shouldRefresh := p.gem.ShouldRefresh() | ||
if shouldRefresh { | ||
go func() { | ||
_ = p.gem.Update(context.Background()) | ||
}() | ||
} | ||
return req.Next() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.