[Groonga-commit] groonga/grnci at eaa197c [master] Simplify DB.LogicalShardList.

Back to archive index

Susumu Yata null+****@clear*****
Tue Sep 12 16:05:13 JST 2017


Susumu Yata	2017-09-12 16:05:13 +0900 (Tue, 12 Sep 2017)

  New Revision: eaa197ca1a8cee0bfaabd7ccfe1e49f799f5528c
  https://github.com/groonga/grnci/commit/eaa197ca1a8cee0bfaabd7ccfe1e49f799f5528c

  Message:
    Simplify DB.LogicalShardList.
    
    Ref: #42

  Modified files:
    v2/db.go

  Modified: v2/db.go (+9 -10)
===================================================================
--- v2/db.go    2017-09-12 16:03:25 +0900 (9c09415)
+++ v2/db.go    2017-09-12 16:05:13 +0900 (9106f3e)
@@ -890,28 +890,27 @@ type DBLogicalShard struct {
 }
 
 // LogicalShardList executes logical_shard_list.
-func (db *DB) LogicalShardList(logicalTable string) ([]DBLogicalShard, Response, error) {
+func (db *DB) LogicalShardList(logicalTable string) ([]DBLogicalShard, error) {
 	resp, err := db.Invoke("logical_shard_list", map[string]interface{}{
 		"logical_table": logicalTable,
 	}, nil)
 	if err != nil {
-		return nil, nil, err
+		return nil, err
 	}
 	defer resp.Close()
 	jsonData, err := ioutil.ReadAll(resp)
 	if err != nil {
-		return nil, resp, err
+		return nil, err
 	}
 	var result []DBLogicalShard
-	if err := json.Unmarshal(jsonData, &result); err != nil {
-		if resp.Err() != nil {
-			return nil, resp, nil
+	if len(jsonData) != 0 {
+		if err := json.Unmarshal(jsonData, &result); err != nil {
+			return nil, NewError(ResponseError, "json.Unmarshal failed.", map[string]interface{}{
+				"error": err.Error(),
+			})
 		}
-		return nil, resp, NewError(ResponseError, "json.Unmarshal failed.", map[string]interface{}{
-			"error": err.Error(),
-		})
 	}
-	return result, resp, nil
+	return result, resp.Err()
 }
 
 // DBLogicalTableRemoveOptions stores options for DB.LogicalTableRemove.
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20170912/2ddb3be7/attachment.htm 



More information about the Groonga-commit mailing list
Back to archive index