forked from kubeflow/model-registry
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from kubeflow/main
[pull] main from kubeflow:main
- Loading branch information
Showing
9 changed files
with
702 additions
and
51 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Package proxy provides dynamic routing capabilities for HTTP servers. | ||
// | ||
// This file contains the implementation of a dynamic router that allows | ||
// changing the HTTP handler at runtime in a thread-safe manner. It is | ||
// particularly useful for proxy servers that need to update their routing | ||
// logic wihtout restarting the server. | ||
package proxy | ||
|
||
import ( | ||
"net/http" | ||
"sync" | ||
) | ||
|
||
type dynamicRouter struct { | ||
mu sync.RWMutex | ||
router http.Handler | ||
} | ||
|
||
func NewDynamicRouter() *dynamicRouter { | ||
return &dynamicRouter{} | ||
} | ||
|
||
func (d *dynamicRouter) ServeHTTP(w http.ResponseWriter, r *http.Request) { | ||
d.mu.RLock() | ||
|
||
router := d.router | ||
|
||
d.mu.RUnlock() | ||
|
||
router.ServeHTTP(w, r) | ||
} | ||
|
||
func (d *dynamicRouter) SetRouter(router http.Handler) { | ||
d.mu.Lock() | ||
|
||
d.router = router | ||
|
||
d.mu.Unlock() | ||
} |
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.