Ejemplo n.º 1
0
// Parse returns the namespace, datatore.Key, sequence and queue name from a task request
func (l *Locker) Parse(c context.Context, r *http.Request) (*datastore.Key, int, error) {
	key := new(datastore.Key)
	if err := key.UnmarshalJSON([]byte(r.Header.Get("X-Lock-Key"))); err != nil {
		return nil, 0, err
	}
	seq, err := strconv.Atoi(r.Header.Get("X-Lock-Seq"))
	if err != nil {
		return nil, 0, err
	}
	return key, seq, nil
}