Documentation
¶
Index ¶
- type EndpointType
- type Limiter
- type RateLimitError
- type Reservation
- type ServiceNowLimiter
- func (s *ServiceNowLimiter) Allow(endpointType EndpointType) bool
- func (s *ServiceNowLimiter) Reserve(endpointType EndpointType) Reservation
- func (s *ServiceNowLimiter) UpdateConfig(config ServiceNowLimiterConfig)
- func (s *ServiceNowLimiter) Wait(ctx context.Context, endpointType EndpointType) error
- type ServiceNowLimiterConfig
- type TokenBucketLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EndpointType ¶
type EndpointType string
EndpointType represents different ServiceNow endpoint types
const ( EndpointTypeTable EndpointType = "table" EndpointTypeAttachment EndpointType = "attachment" EndpointTypeImport EndpointType = "import" EndpointTypeDefault EndpointType = "default" )
func DetectEndpointType ¶
func DetectEndpointType(path string) EndpointType
DetectEndpointType attempts to determine the endpoint type from a URL path
type Limiter ¶
type Limiter interface {
Wait(ctx context.Context) error
Allow() bool
Reserve() Reservation
}
Limiter represents a rate limiter interface
type RateLimitError ¶
RateLimitError represents a rate limit exceeded error
func NewRateLimitError ¶
func NewRateLimitError(message string, retryAfter time.Duration) *RateLimitError
NewRateLimitError creates a new rate limit error
func (*RateLimitError) Error ¶
func (e *RateLimitError) Error() string
type Reservation ¶
Reservation represents a rate limit reservation
type ServiceNowLimiter ¶
type ServiceNowLimiter struct {
// contains filtered or unexported fields
}
ServiceNowLimiter provides rate limiting specifically for ServiceNow API
func NewServiceNowLimiter ¶
func NewServiceNowLimiter(config ServiceNowLimiterConfig) *ServiceNowLimiter
NewServiceNowLimiter creates a new ServiceNow-specific rate limiter
func (*ServiceNowLimiter) Allow ¶
func (s *ServiceNowLimiter) Allow(endpointType EndpointType) bool
Allow checks if a request can be made immediately to the specified endpoint type
func (*ServiceNowLimiter) Reserve ¶
func (s *ServiceNowLimiter) Reserve(endpointType EndpointType) Reservation
Reserve reserves permission for a future request to the specified endpoint type
func (*ServiceNowLimiter) UpdateConfig ¶
func (s *ServiceNowLimiter) UpdateConfig(config ServiceNowLimiterConfig)
UpdateConfig updates the rate limiting configuration
func (*ServiceNowLimiter) Wait ¶
func (s *ServiceNowLimiter) Wait(ctx context.Context, endpointType EndpointType) error
Wait waits for permission to make a request to the specified endpoint type
type ServiceNowLimiterConfig ¶
type ServiceNowLimiterConfig struct {
// Requests per second for different endpoint types
TableRequestsPerSecond float64
AttachmentRequestsPerSecond float64
ImportRequestsPerSecond float64
DefaultRequestsPerSecond float64
// Burst allowances
TableBurst int
AttachmentBurst int
ImportBurst int
DefaultBurst int
}
ServiceNowLimiterConfig holds configuration for ServiceNow rate limiting
func DefaultServiceNowConfig ¶
func DefaultServiceNowConfig() ServiceNowLimiterConfig
DefaultServiceNowConfig returns default rate limiting configuration for ServiceNow Based on ServiceNow's documented rate limits
type TokenBucketLimiter ¶
type TokenBucketLimiter struct {
// contains filtered or unexported fields
}
TokenBucketLimiter implements a token bucket rate limiter
func NewTokenBucketLimiter ¶
func NewTokenBucketLimiter(requestsPerSecond float64, burst int) *TokenBucketLimiter
NewTokenBucketLimiter creates a new token bucket rate limiter
func (*TokenBucketLimiter) Allow ¶
func (t *TokenBucketLimiter) Allow() bool
Allow returns whether a request can be made immediately
func (*TokenBucketLimiter) Reserve ¶
func (t *TokenBucketLimiter) Reserve() Reservation
Reserve reserves a token for a future request