const defaultLeaseReuseDurationSeconds … const defaultLeaseMaxObjectCount … type LeaseManagerConfig … // NewDefaultLeaseManagerConfig creates a LeaseManagerConfig with default values func NewDefaultLeaseManagerConfig() LeaseManagerConfig { … } type leaseManager … // newDefaultLeaseManager creates a new lease manager using default setting. func newDefaultLeaseManager(client *clientv3.Client, config LeaseManagerConfig) *leaseManager { … } // newLeaseManager creates a new lease manager with the number of buffered // leases, lease reuse duration in seconds and percentage. The percentage // value x means x*100%. func newLeaseManager(client *clientv3.Client, leaseReuseDurationSeconds int64, leaseReuseDurationPercent float64, maxObjectCount int64) *leaseManager { … } // 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. func (l *leaseManager) GetLease(ctx context.Context, ttl int64) (clientv3.LeaseID, error) { … } // getReuseDurationSecondsLocked returns the reusable duration in seconds // based on the configuration. Lock has to be acquired before calling this // function. func (l *leaseManager) getReuseDurationSecondsLocked(ttl int64) int64 { … }