Exemplo n.º 1
0
func (me *testMyMarshaller) EncodeTask(fn interface{}, task *dingo.Task) ([]byte, error) {
	// encode args
	bN, _ := json.Marshal(task.Args()[0])
	bName, _ := json.Marshal(task.Args()[1])
	// encode option
	bOpt, _ := json.Marshal(task.P.O)
	return dingo.ComposeBytes(task.H, [][]byte{bN, bName, bOpt})
}
Exemplo n.º 2
0
func (me *testMyMarshaller) EncodeReport(fn interface{}, report *dingo.Report) (b []byte, err error) {
	bs := [][]byte{}

	// encode returns
	if report.OK() {
		bMsg, _ := json.Marshal(report.Return()[0])
		bCount, _ := json.Marshal(report.Return()[1])
		bs = append(bs, bMsg, bCount)
	}

	// encode status
	bStatus, _ := json.Marshal(report.Status())
	// encode error
	bError, _ := json.Marshal(report.Error())
	// encode option
	bOpt, _ := json.Marshal(report.Option())
	bs = append(bs, bStatus, bError, bOpt)

	return dingo.ComposeBytes(report.H, bs)
}