// SetHardRateLimit sets the hard rate limit.
//
// Puts are delayed 1ms at a time when any level has a compaction score that
// exceeds hard_rate_limit. This is ignored when <= 1.0.
// Default: 0.0 (disabled)
505600
func (opts *Options) SetHardRateLimit(value float64) {
	C.rocksdb_options_set_hard_rate_limit(opts.c, C.double(value))
}
418738
func (s *Reader) SetRateLimit(bytesPerSec float64) {
	s.limiter = rate.NewLimiter(rate.Limit(bytesPerSec), burstLimit)
	s.limiter.AllowN(time.Now(), burstLimit) // spend initial burst
}
979795
func (s *DimensionGroup) SetLimit(v int64) *DimensionGroup {
	s.Limit = &v
	return s
}
707164
func (s *GetAuthorizersInput) SetLimit(v int64) *GetAuthorizersInput {
	s.Limit = &v
	return s
}
1358802
func (s *DescribeResourcePermissionsInput) SetLimit(v int64) *DescribeResourcePermissionsInput {
	s.Limit = &v
	return s
}
4763
func (s *ListApplicationsInput) SetLimit(v int64) *ListApplicationsInput {
	s.Limit = &v
	return s
}
689936
func (s *DescribeDirectoriesInput) SetLimit(v int64) *DescribeDirectoriesInput {
	s.Limit = &v
	return s
}
976656
func (s *DescribeInstancesInput) SetLimit(v int64) *DescribeInstancesInput {
	s.Limit = &v
	return s
}
1104912
func (s *GetModelsInput) SetLimit(v int64) *GetModelsInput {
	s.Limit = &v
	return s
}
1269702
func (s *GetUsageInput) SetLimit(v int64) *GetUsageInput {
	s.Limit = &v
	return s
}
186752
func (s *RateBasedRule) SetRateLimit(v int64) *RateBasedRule {
	s.RateLimit = &v
	return s
}
921275
func (s *ListWebACLsInput) SetLimit(v int64) *ListWebACLsInput {
	s.Limit = &v
	return s
}
1104017
func (h *Holder) setFileLimit() {
	oldLimit := &syscall.Rlimit{}
	newLimit := &syscall.Rlimit{}

	if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, oldLimit); err != nil {
		h.Logger.Printf("ERROR checking open file limit: %s", err)
		return
	}
	// If the soft limit is lower than the FileLimit constant, we will try to change it.
	if oldLimit.Cur < fileLimit {
		newLimit.Cur = fileLimit
		// If the hard limit is not high enough, we will try to change it too.
		if oldLimit.Max < fileLimit {
			newLimit.Max = fileLimit
		} else {
			newLimit.Max = oldLimit.Max
		}

		// Try to set the limit
		if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, newLimit); err != nil {
			// If we just tried to change the hard limit and failed, we probably don't have permission. Let's try again without setting the hard limit.
			if newLimit.Max > oldLimit.Max {
				newLimit.Max = oldLimit.Max
				// Obviously the hard limit cannot be higher than the soft limit.
				if newLimit.Cur >= newLimit.Max {
					newLimit.Cur = newLimit.Max
				}
				// Try setting again with lowered Max (hard limit)
				if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, newLimit); err != nil {
					h.Logger.Printf("ERROR setting open file limit: %s", err)
				}
				// If we weren't trying to change the hard limit, let the user know something is wrong.
			} else {
				h.Logger.Printf("ERROR setting open file limit: %s", err)
			}
		}

		// Check the limit after setting it. OS may not obey Setrlimit call.
		if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, oldLimit); err != nil {
			h.Logger.Printf("ERROR checking open file limit: %s", err)
		} else {
			if oldLimit.Cur < fileLimit {
				h.Logger.Printf("WARNING: Tried to set open file limit to %d, but it is %d. You may consider running \"sudo ulimit -n %d\" before starting Pilosa to avoid \"too many open files\" error. See https://www.pilosa.com/docs/latest/administration/#open-file-limits for more information.", fileLimit, oldLimit.Cur, fileLimit)
			}
		}
	}
}
881976
func (s *ListSizeConstraintSetsInput) SetLimit(v int64) *ListSizeConstraintSetsInput {
	s.Limit = &v
	return s
}
590944
func (opts *Options) SetSoftPendingCompactionBytesLimit(value uint64) {
	C.rocksdb_options_set_soft_pending_compaction_bytes_limit(opts.c, C.size_t(value))
}
155715
func (s *GetResourcesInput) SetLimit(v int64) *GetResourcesInput {
	s.Limit = &v
	return s
}
14617
func RateLimit(q Quota, vary *VaryBy, store GCRAStore) *Throttler {
	count, period := q.Quota()

	if count < 1 {
		count = 1
	}
	if period <= 0 {
		period = time.Second
	}

	rate := Rate{period: period / time.Duration(count)}
	limiter, err := NewGCRARateLimiter(store, RateQuota{rate, count - 1})

	// This panic in unavoidable because the original interface does
	// not support returning an error.
	if err != nil {
		panic(err)
	}

	return &Throttler{
		HTTPRateLimiter{
			RateLimiter: limiter,
			VaryBy:      vary,
		},
	}
}