code: func (l *leaseManager) GetLease(ctx context.Context, ttl int64) (clientv3.LeaseID, error) {
  	now := time.Now()
  	l.leaseMu.Lock()
  	defer l.leaseMu.Unlock()
  	// check if previous lease can be reused
  	reuseDurationSeconds := l.getReuseDurationSecondsLocked(ttl)
  	valid := now.Add(time.Duration(ttl) * time.Second).Before(l.prevLeaseExpirationTime)
  	sufficient := now.Add(time.Duration(ttl+reuseDurationSeconds) * time.Second).After(l.prevLeaseExpirationTime)
  	if valid && sufficient {
  		return l.prevLeaseID, nil
  	}
  	// request a lease with a little extra ttl from etcd
  	ttl += reuseDurationSeconds
  	lcr, err := l.client.Lease.Grant(ctx, ttl)
  	if err != nil {
  		return clientv3.LeaseID(0), err
  	}
  	// cache the new lease id
  	l.prevLeaseID = lcr.ID
  	l.prevLeaseExpirationTime = now.Add(time.Duration(ttl) * time.Second)
  	return lcr.ID, nil
  }
docs: // GetLease returns a lease based on requested ttl: if the cached previous
  // lease can be reused, reuse it; otherwise request a new one from etcd.