traeak commented on a change in pull request #2931: reuse single riak cluster 
connection, up riak heartbeat timeout
URL: https://github.com/apache/trafficcontrol/pull/2931#discussion_r230913083
 
 

 ##########
 File path: traffic_ops/traffic_ops_golang/riaksvc/riak_services.go
 ##########
 @@ -247,34 +256,79 @@ func RiakServersToCluster(servers []ServerAddr, 
authOptions *riak.AuthOptions) (
        if err != nil {
                return nil, errors.New("creating riak cluster: " + err.Error())
        }
+       return cluster, err
+}
+
+func RiakServersToCluster(servers []ServerAddr, authOptions *riak.AuthOptions) 
(StorageCluster, error) {
+       cluster, err := riakServersToClusterPriv(servers, authOptions)
+       if nil != err {
+               return nil, err
+       }
+       return RiakStorageCluster{Cluster: cluster}, nil
+}
+
+func GetPooledClusterTx(tx *sql.Tx, authOptions *riak.AuthOptions) 
(StorageCluster, error) {
+
+       var cluster *riak.Cluster
+       var err error
+
+       clusterMutex.Lock()
+
+       if nil == sharedCluster {
+               riakServers, err := GetRiakServers(tx)
+               if err != nil {
+                       clusterMutex.Unlock()
+                       return nil, errors.New("getting riak servers: " + 
err.Error())
+               }
+
+               cluster, err = riakServersToClusterPriv(riakServers, 
authOptions)
+               if nil != err {
+                       clusterMutex.Unlock()
+                       return nil, errors.New("creating riak cluster: " + 
err.Error())
+               }
+
+               if err = cluster.Start(); err != nil {
+                       clusterMutex.Unlock()
+                       return nil, errors.New("starting riak cluster: " + 
err.Error())
+               }
+
+               fmt.Println("Successfully created and started cluster")
+
+               sharedCluster = cluster
+       } else {
 
 Review comment:
   fairly minor.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to