// Handle handles the provided query.
Handle handles the provided query.
// Handle handles the provided query .
func (h *Handler) Handle(query *model.Command) {
	var (
		queryErr    *model.Error
		queryResult []byte
	)
	switch query.Action {
	case "Latest":
		queryResult, queryErr = latest(h.Coll, query)
	case "Timestamp":
		queryResult, queryErr = timestamp(h.Coll, query)
	case "Items":
		queryResult, queryErr = items(h.Coll, query)
	case "OrQuery":
		queryResult, queryErr = orQuery(h.Coll, query)
	default:
		log.Printf("Unregistered Action found: %s", query.Action)
	}
	var (
		errCode int16
		errMsg  string
	)
	if queryErr != nil {
		errCode = queryErr.Code
		errMsg = queryErr.Message
	}
	uuid, err := uuuid.NewV4()
	if err != nil {
		err = errors.Wrap(err, "Error generating UUID for response")
		log.Println(err)
	}
	h.ResultProd <- &model.Document{
		CorrelationID: query.UUID,
		Data:          queryResult,
		Error:         errMsg,
		ErrorCode:     errCode,
		Source:        h.ServiceName,
		Topic:         query.ResponseTopic,
		UUID:          uuid,
	}
}
func ( h * Handler ) Handle ( query * model . Command ) { var ( queryErr * model . Error queryResult [ ] byte ) switch query . Action { case " " : queryResult , queryErr = latest ( h . Coll , query ) case " " : queryResult , queryErr = timestamp ( h . Coll , query ) case " " : queryResult , queryErr = items ( h . Coll , query ) case " " : queryResult , queryErr = orQuery ( h . Coll , query ) default : log . Printf ( " " , query . Action ) } var ( errCode int16 errMsg string ) if queryErr != nil { errCode = queryErr . Code errMsg = queryErr . Message } uuid , err := uuuid . NewV4 ( ) if err != nil { err = errors . Wrap ( err , " " ) log . Println ( err ) } h . ResultProd <- & model . Document { CorrelationID : query . UUID , Data : queryResult , Error : errMsg , ErrorCode : errCode , Source : h . ServiceName , Topic : query . ResponseTopic , UUID : uuid , } }
Handle handles the provided query.
Handle handles the provided query .