projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
5824: Move HTTP server code to SDK.
[arvados.git]
/
sdk
/
go
/
keepclient
/
keepclient.go
diff --git
a/sdk/go/keepclient/keepclient.go
b/sdk/go/keepclient/keepclient.go
index 31cfb572e48729902da95ca7d5c2616f5911d0dd..f82e5c7c594062f23da7ab42db3c4971738d5597 100644
(file)
--- a/
sdk/go/keepclient/keepclient.go
+++ b/
sdk/go/keepclient/keepclient.go
@@
-38,6
+38,7
@@
type KeepClient struct {
Want_replicas int
Using_proxy bool
localRoots *map[string]string
Want_replicas int
Using_proxy bool
localRoots *map[string]string
+ writableLocalRoots *map[string]string
gatewayRoots *map[string]string
lock sync.RWMutex
Client *http.Client
gatewayRoots *map[string]string
lock sync.RWMutex
Client *http.Client
@@
-194,6
+195,14
@@
func (kc *KeepClient) GatewayRoots() map[string]string {
return *kc.gatewayRoots
}
return *kc.gatewayRoots
}
+// WritableLocalRoots() returns the map of writable local Keep services:
+// uuid -> baseURI.
+func (kc *KeepClient) WritableLocalRoots() map[string]string {
+ kc.lock.RLock()
+ defer kc.lock.RUnlock()
+ return *kc.writableLocalRoots
+}
+
// SetServiceRoots updates the localRoots and gatewayRoots maps,
// without risk of disrupting operations that are already in progress.
//
// SetServiceRoots updates the localRoots and gatewayRoots maps,
// without risk of disrupting operations that are already in progress.
//
@@
-201,18
+210,26
@@
func (kc *KeepClient) GatewayRoots() map[string]string {
// caller can reuse/modify them after SetServiceRoots returns, but
// they should not be modified by any other goroutine while
// SetServiceRoots is running.
// caller can reuse/modify them after SetServiceRoots returns, but
// they should not be modified by any other goroutine while
// SetServiceRoots is running.
-func (kc *KeepClient) SetServiceRoots(newLocals, newGateways map[string]string) {
+func (kc *KeepClient) SetServiceRoots(newLocals, new
WritableLocals map[string]string, new
Gateways map[string]string) {
locals := make(map[string]string)
for uuid, root := range newLocals {
locals[uuid] = root
}
locals := make(map[string]string)
for uuid, root := range newLocals {
locals[uuid] = root
}
+
+ writables := make(map[string]string)
+ for uuid, root := range newWritableLocals {
+ writables[uuid] = root
+ }
+
gateways := make(map[string]string)
for uuid, root := range newGateways {
gateways[uuid] = root
}
gateways := make(map[string]string)
for uuid, root := range newGateways {
gateways[uuid] = root
}
+
kc.lock.Lock()
defer kc.lock.Unlock()
kc.localRoots = &locals
kc.lock.Lock()
defer kc.lock.Unlock()
kc.localRoots = &locals
+ kc.writableLocalRoots = &writables
kc.gatewayRoots = &gateways
}
kc.gatewayRoots = &gateways
}