func()

in datahub/requestmodel.go [138:170]


func (gcr *GetCursorRequest) requestBodyEncode() ([]byte, error) {

	type ReqMsg struct {
		Action string     `json:"Action"`
		Type   CursorType `json:"Type"`
	}
	reqMsg := ReqMsg{
		Action: gcr.Action,
		Type:   gcr.CursorType,
	}
	switch gcr.CursorType {
	case OLDEST, LATEST:
		return json.Marshal(reqMsg)
	case SYSTEM_TIME:
		return json.Marshal(struct {
			ReqMsg
			SystemTime int64 `json:"SystemTime"`
		}{
			ReqMsg:     reqMsg,
			SystemTime: gcr.SystemTime,
		})
	case SEQUENCE:
		return json.Marshal(struct {
			ReqMsg
			Sequence int64 `json:"Sequence"`
		}{
			ReqMsg:   reqMsg,
			Sequence: gcr.Sequence,
		})
	default:
		return nil, fmt.Errorf("cursor not support type %s", gcr.CursorType)
	}
}