Skip to content

Latest commit

 

History

History
49 lines (42 loc) · 2.25 KB

File metadata and controls

49 lines (42 loc) · 2.25 KB

##Caller and Worker

Next: Background Worker Pool

Below is a flow when you initiate a task and receive reports in Dingo.

Image Of Flow

The key to scaling dividing a big procedure into smaller ones, and making each one of them isolated from each other. For a function in #golang, we can devide it into three parts:

//         passing arguments      receiving return values
//                |                          |
//                v                          v
//       ---------------------   --------------------------
func Foo(count int, msg string) (composed string, err error) {  // |
    return fmt.Sprintf("%v:%v", msg, count), nil                // |<- execution
}                                                               // |

###Passing Arguments There are 3 roles related to this part:

  • Caller: the one who...
    • composes arguments into dingo.Task
    • marshall it into []byte
    • sends to brokers
  • Broker: the one who dispatching tasks
  • Worker: the one who
    • consumes []byte from brokers
    • unmarshall it into dingo.Task

###Execution Only Worker relates this part. Upon receiving tasks, Worker should find corresponding functions according to the names of tasks, and execute it.

###Receiving Return Values After execution:

  • Worker:
    • compose return values into dingo.Report
    • marshall it into []byte
    • send it to Store.
  • Caller:
    • poll from Store
    • unmarshall []byte to dingo.Report
    • dispatch it to the right channel.

###Example There are runnable examples on GoDoc(Caller and Worker) based on our AMQP adaptor.