lease/lessor.go
func (le *lessor) Attach(id LeaseID, items []LeaseItem) error {
	le.mu.Lock()
	defer le.mu.Unlock()

	l := le.leaseMap[id]
	if l == nil {
		return ErrLeaseNotFound
	}

	l.mu.Lock()
	for _, it := range items {
		l.itemSet[it] = struct{}{}
		le.itemMap[it] = id
	}
	l.mu.Unlock()
	return nil
}
func (le *lessor) Attach(id LeaseID, items []LeaseItem) error {
	le.mu.Lock()
	defer le.mu.Unlock()

	l := le.leaseMap[id]
	if l == nil {
		return ErrLeaseNotFound
	}

	l.mu.Lock()
	for _, it := range items {
		l.itemSet[it] = struct{}{}
		le.itemMap[it] = id
	}
	l.mu.Unlock()
	return nil
}
func ( le * lessor ) Attach ( id LeaseID , items [ ] LeaseItem ) error { le . mu . Lock ( ) defer le . mu . Unlock ( ) l := le . leaseMap [ id ] if l == nil { return ErrLeaseNotFound } l . mu . Lock ( ) for _ , it := range items { l . itemSet [ it ] = struct { } { } le . itemMap [ it ] = id } l . mu . Unlock ( ) return nil }
// Attach attaches items to the lease with given ID. When the lease
// expires, the attached items will be automatically removed.
// If the given lease does not exist, an error will be returned.
Attach attaches items to the lease with given ID . When the lease expires the attached items will be automatically removed . If the given lease does not exist an error will be returned .