You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: limiter.go
    path of file: ./repos/hubble-ui/backend/vendor/github.com/cilium/cilium/pkg/rate
    
    the code of the file until where you have to start completion: // SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium

package rate

import (
	"context"
	"fmt"
	"sync/atomic"
	"time"

	"golang.org/x/sync/semaphore"
)

// Limiter is used to limit the number of operations do
    
func (lim *Limiter) WaitN(ctx context.Context, n int64) error {
	lim.assertAlive()
	if n > lim.burst {
		return fmt.Errorf("rate: Wait(n=%d) exceeds limiter's burst %d", n, lim.burst)
	}
	err := lim.semaphore.Acquire(ctx, n)
	if err != nil {
		return err
	}
	lim.currWeights.Add(n)
	return nil
}