예제 #1
0
func AddBucket(n *pb.NamespaceConfig, b *pb.BucketConfig) error {
	if b.Name == "" {
		return errors.New("Bucket name cannot be nil or empty.")
	}
	n.Buckets[b.Name] = b
	b.Namespace = n.Name
	return nil
}
예제 #2
0
func ApplyBucketDefaults(b *pb.BucketConfig) {
	if b.Size == 0 {
		b.Size = 100
	}

	if b.FillRate == 0 {
		b.FillRate = 50
	}

	if b.WaitTimeoutMillis == 0 {
		b.WaitTimeoutMillis = 1000
	}

	if b.MaxIdleMillis == 0 {
		b.MaxIdleMillis = -1
	}

	if b.MaxDebtMillis == 0 {
		b.MaxDebtMillis = 10000
	}

	if b.MaxTokensPerRequest == 0 {
		b.MaxTokensPerRequest = b.FillRate
	}
}
예제 #3
0
func SetDynamicBucketTemplate(n *pb.NamespaceConfig, b *pb.BucketConfig) {
	b.Name = DynamicBucketTemplateName
	b.Namespace = n.Name
	n.DynamicBucketTemplate = b
}