5824: Move HTTP server code to SDK.
[arvados.git] / sdk / go / keepclient / keepclient.go
index 5ebdf0ad7a8d9e6ddff5800d36a90c1a39885227..f82e5c7c594062f23da7ab42db3c4971738d5597 100644 (file)
@@ -38,8 +38,8 @@ type KeepClient struct {
        Want_replicas int
        Using_proxy   bool
        localRoots    *map[string]string
+       writableLocalRoots *map[string]string
        gatewayRoots  *map[string]string
-       writableRoots *map[string]string
        lock          sync.RWMutex
        Client        *http.Client
 }
@@ -195,12 +195,12 @@ func (kc *KeepClient) GatewayRoots() map[string]string {
        return *kc.gatewayRoots
 }
 
-// WritableRoots() returns the map of writable Keep services:
+// WritableLocalRoots() returns the map of writable local Keep services:
 // uuid -> baseURI.
-func (kc *KeepClient) WritableRoots() map[string]string {
+func (kc *KeepClient) WritableLocalRoots() map[string]string {
        kc.lock.RLock()
        defer kc.lock.RUnlock()
-       return *kc.writableRoots
+       return *kc.writableLocalRoots
 }
 
 // SetServiceRoots updates the localRoots and gatewayRoots maps,
@@ -210,24 +210,27 @@ func (kc *KeepClient) WritableRoots() 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.
-func (kc *KeepClient) SetServiceRoots(newLocals, newGateways map[string]string, writableRoots map[string]string) {
+func (kc *KeepClient) SetServiceRoots(newLocals, newWritableLocals map[string]string, newGateways map[string]string) {
        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
        }
-       writables := make(map[string]string)
-       for uuid, root := range writableRoots {
-               writables[uuid] = root
-       }
+
        kc.lock.Lock()
        defer kc.lock.Unlock()
        kc.localRoots = &locals
+       kc.writableLocalRoots = &writables
        kc.gatewayRoots = &gateways
-       kc.writableRoots = &writables
 }
 
 // getSortedRoots returns a list of base URIs of Keep services, in the