Example #1
0
func doTap(b Bucket, req *gomemcached.MCRequest, r io.Reader,
	chpkt chan<- transmissible, cherr <-chan error) *gomemcached.MCResponse {
	tc, err := req.ParseTapCommands()
	if err != nil {
		return &gomemcached.MCResponse{
			Status: gomemcached.EINVAL,
			Body:   []byte(fmt.Sprintf("ParseTapCommands err: %v", err)),
		}
	}

	// TODO: TAP of a vbucket list.

	res, yesDump := tapFlagBool(&tc, gomemcached.DUMP)
	if res != nil {
		return res
	}
	if yesDump || tapFlagExists(&tc, gomemcached.BACKFILL) {
		res := doTapBackFill(b, req, r, chpkt, cherr, tc)
		if res != nil {
			return res
		}
		if yesDump {
			close(chpkt)
			return &gomemcached.MCResponse{Fatal: true}
		}
	}

	// TODO: There's probably a mutation gap between backfill and tap-forward.

	return doTapForward(b, req, r, chpkt, cherr, tc)
}