get rid of unserializable error type.
This commit is contained in:
parent
5f49101566
commit
edcd2f34d4
@ -355,12 +355,12 @@ type DealSchedule struct {
|
|||||||
type DagstoreShardInfo struct {
|
type DagstoreShardInfo struct {
|
||||||
Key string
|
Key string
|
||||||
State string
|
State string
|
||||||
Error error
|
Error string
|
||||||
}
|
}
|
||||||
|
|
||||||
// DagstoreGCResult is the serialized form of dagstore.GCResult that we expose
|
// DagstoreGCResult is the serialized form of dagstore.GCResult that we expose
|
||||||
// through JSON-RPC to avoid clients having to depend on the dagstore lib.
|
// through JSON-RPC to avoid clients having to depend on the dagstore lib.
|
||||||
type DagstoreGCResult struct {
|
type DagstoreGCResult struct {
|
||||||
Key string
|
Key string
|
||||||
Error error
|
Error string
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ func TestReturnTypes(t *testing.T) {
|
|||||||
seen[typ] = struct{}{}
|
seen[typ] = struct{}{}
|
||||||
|
|
||||||
if typ.Kind() == reflect.Interface && typ != bareIface && !typ.Implements(jmarsh) {
|
if typ.Kind() == reflect.Interface && typ != bareIface && !typ.Implements(jmarsh) {
|
||||||
t.Error("methods can't return interfaces", m.Name)
|
t.Error("methods can't return interfaces or struct types not implementing json.Marshaller", m.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch typ.Kind() {
|
switch typ.Kind() {
|
||||||
|
@ -278,12 +278,12 @@ func init() {
|
|||||||
})
|
})
|
||||||
addExample(api.DagstoreGCResult{
|
addExample(api.DagstoreGCResult{
|
||||||
Key: "baga6ea4seaqecmtz7iak33dsfshi627abz4i4665dfuzr3qfs4bmad6dx3iigdq",
|
Key: "baga6ea4seaqecmtz7iak33dsfshi627abz4i4665dfuzr3qfs4bmad6dx3iigdq",
|
||||||
Error: nil,
|
Error: "<error>",
|
||||||
})
|
})
|
||||||
addExample(api.DagstoreShardInfo{
|
addExample(api.DagstoreShardInfo{
|
||||||
Key: "baga6ea4seaqecmtz7iak33dsfshi627abz4i4665dfuzr3qfs4bmad6dx3iigdq",
|
Key: "baga6ea4seaqecmtz7iak33dsfshi627abz4i4665dfuzr3qfs4bmad6dx3iigdq",
|
||||||
State: "ShardStateAvailable",
|
State: "ShardStateAvailable",
|
||||||
Error: nil,
|
Error: "<error>",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
@ -118,7 +118,7 @@ var dagstoreGcCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, e := range collected {
|
for _, e := range collected {
|
||||||
if e.Error == nil {
|
if e.Error == "" {
|
||||||
_, _ = fmt.Fprintln(os.Stdout, e.Key, "success")
|
_, _ = fmt.Fprintln(os.Stdout, e.Key, "success")
|
||||||
} else {
|
} else {
|
||||||
_, _ = fmt.Fprintln(os.Stdout, e.Key, "failed:", e.Error)
|
_, _ = fmt.Fprintln(os.Stdout, e.Key, "failed:", e.Error)
|
||||||
|
@ -564,7 +564,12 @@ func (sm *StorageMinerAPI) DagstoreListShards(ctx context.Context) ([]api.Dagsto
|
|||||||
ret = append(ret, api.DagstoreShardInfo{
|
ret = append(ret, api.DagstoreShardInfo{
|
||||||
Key: k.String(),
|
Key: k.String(),
|
||||||
State: i.ShardState.String(),
|
State: i.ShardState.String(),
|
||||||
Error: i.Error,
|
Error: func() string {
|
||||||
|
if i.Error == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return i.Error.Error()
|
||||||
|
}(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return ret, nil
|
return ret, nil
|
||||||
@ -624,8 +629,13 @@ func (sm *StorageMinerAPI) DagstoreGC(ctx context.Context) ([]api.DagstoreGCResu
|
|||||||
ret := make([]api.DagstoreGCResult, 0, len(res.Shards))
|
ret := make([]api.DagstoreGCResult, 0, len(res.Shards))
|
||||||
for k, err := range res.Shards {
|
for k, err := range res.Shards {
|
||||||
ret = append(ret, api.DagstoreGCResult{
|
ret = append(ret, api.DagstoreGCResult{
|
||||||
Key: k.String(),
|
Key: k.String(),
|
||||||
Error: err,
|
Error: func() string {
|
||||||
|
if err == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return err.Error()
|
||||||
|
}(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user