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-provider
Commits
c835ad80
Commit
c835ad80
authored
Mar 11, 2020
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: return errors from enqueue
parent
de3bf42b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
queue/queue.go
queue/queue.go
+8
-1
No files found.
queue/queue.go
View file @
c835ad80
...
...
@@ -56,10 +56,12 @@ func (q *Queue) Close() error {
}
// Enqueue puts a cid in the queue
func
(
q
*
Queue
)
Enqueue
(
cid
cid
.
Cid
)
{
func
(
q
*
Queue
)
Enqueue
(
cid
cid
.
Cid
)
error
{
select
{
case
q
.
enqueue
<-
cid
:
return
nil
case
<-
q
.
ctx
.
Done
()
:
return
fmt
.
Errorf
(
"failed to enqueue CID: shutting down"
)
}
}
...
...
@@ -75,6 +77,11 @@ func (q *Queue) work() {
var
c
cid
.
Cid
=
cid
.
Undef
defer
func
()
{
// also cancels any in-progess enqueue tasks.
q
.
close
()
// unblocks anyone waiting
close
(
q
.
dequeue
)
// unblocks the close call
close
(
q
.
closed
)
}()
...
...
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