Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
206739d1
Commit
206739d1
authored
9 years ago
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow channel marshaler to return errors from cmds.Response
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
93e9f841
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
0 deletions
+15
-0
commands/channelmarshaler.go
commands/channelmarshaler.go
+5
-0
commands/response.go
commands/response.go
+1
-0
core/commands/dht.go
core/commands/dht.go
+5
-0
core/commands/ping.go
core/commands/ping.go
+1
-0
core/commands/refs.go
core/commands/refs.go
+1
-0
core/commands/repo.go
core/commands/repo.go
+1
-0
core/commands/stat.go
core/commands/stat.go
+1
-0
No files found.
commands/channelmarshaler.go
View file @
206739d1
...
...
@@ -5,6 +5,7 @@ import "io"
type
ChannelMarshaler
struct
{
Channel
<-
chan
interface
{}
Marshaler
func
(
interface
{})
(
io
.
Reader
,
error
)
Res
Response
reader
io
.
Reader
}
...
...
@@ -13,6 +14,10 @@ func (cr *ChannelMarshaler) Read(p []byte) (int, error) {
if
cr
.
reader
==
nil
{
val
,
more
:=
<-
cr
.
Channel
if
!
more
{
//check error in response
if
cr
.
Res
.
Error
()
!=
nil
{
return
0
,
cr
.
Res
.
Error
()
}
return
0
,
io
.
EOF
}
...
...
This diff is collapsed.
Click to expand it.
commands/response.go
View file @
206739d1
...
...
@@ -57,6 +57,7 @@ var marshallers = map[EncodingType]Marshaler{
return
&
ChannelMarshaler
{
Channel
:
ch
,
Marshaler
:
marshalJson
,
Res
:
res
,
},
nil
}
...
...
This diff is collapsed.
Click to expand it.
core/commands/dht.go
View file @
206739d1
...
...
@@ -131,6 +131,7 @@ var queryDhtCmd = &cmds.Command{
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
@@ -249,6 +250,7 @@ FindProviders will return a list of peers who are able to provide the value requ
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
@@ -354,6 +356,7 @@ var findPeerDhtCmd = &cmds.Command{
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
@@ -461,6 +464,7 @@ GetValue will return the value stored in the dht at the given key.
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
@@ -571,6 +575,7 @@ PutValue will store the given key value pair in the dht.
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
This diff is collapsed.
Click to expand it.
core/commands/ping.go
View file @
206739d1
...
...
@@ -71,6 +71,7 @@ trip latency information.
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
This diff is collapsed.
Click to expand it.
core/commands/refs.go
View file @
206739d1
...
...
@@ -141,6 +141,7 @@ Note: list all refs recursively with -r.
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
This diff is collapsed.
Click to expand it.
core/commands/repo.go
View file @
206739d1
...
...
@@ -90,6 +90,7 @@ order to reclaim hard disk space.
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outChan
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
This diff is collapsed.
Click to expand it.
core/commands/stat.go
View file @
206739d1
...
...
@@ -167,6 +167,7 @@ var statBwCmd = &cmds.Command{
return
&
cmds
.
ChannelMarshaler
{
Channel
:
outCh
,
Marshaler
:
marshal
,
Res
:
res
,
},
nil
},
},
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment