Make priority queue lambda function return error over a channel

master
Harshavardhana 10 years ago
parent 38a6ce36e5
commit 0533abf6a8
  1. 0
      pkg/server/api/bucket-handlers.go
  2. 0
      pkg/server/api/definitions.go
  3. 0
      pkg/server/api/generic-handlers.go
  4. 0
      pkg/server/api/logging-handlers.go
  5. 0
      pkg/server/api/object-handlers.go
  6. 0
      pkg/server/api/ratelimit-handlers.go
  7. 0
      pkg/server/api/response.go
  8. 44
      pkg/storage/pq/pq_test.go
  9. 4
      pkg/storage/pq/task.go

@ -30,24 +30,44 @@ type MySuite struct{}
var _ = Suite(&MySuite{})
func helloTask1() error {
fmt.Println("Hello task1")
return nil
func helloTask1() <-chan error {
errCh := make(chan error)
go func() {
defer close(errCh)
println("Hello task1")
errCh <- nil
}()
return errCh
}
func helloTask2() error {
fmt.Println("Hello task2")
return nil
func helloTask2() <-chan error {
errCh := make(chan error)
go func() {
defer close(errCh)
println("Hello task2")
errCh <- nil
}()
return errCh
}
func newJob1() error {
fmt.Println("New Job1")
return nil
func newJob1() <-chan error {
errCh := make(chan error)
go func() {
defer close(errCh)
println("New Job1")
errCh <- nil
}()
return errCh
}
func newJob2() error {
fmt.Println("New Job2")
return nil
func newJob2() <-chan error {
errCh := make(chan error)
go func() {
defer close(errCh)
println("New Job2")
errCh <- nil
}()
return errCh
}
func (s *MySuite) TestPQ(c *C) {

@ -18,7 +18,7 @@ package pq
// Task container for any generic tasks
type Task struct {
job func() error
job func() <-chan error
priority int
}
@ -34,5 +34,5 @@ func (t Task) UpdatePriority(p int) {
// Execute execute current task
func (t Task) Execute() error {
return t.job()
return <-t.job()
}

Loading…
Cancel
Save