LogoLogo
HomePricingDocumentation
  • ๐Ÿ’ฟGetting Started
    • Installation and Project Setup
    • Hello Perigee!
    • Perigee Application Design
    • Hello Configuration
    • Hello Logs
    • Hello Integration
    • Troubleshooting
    • Case Studies
  • ๐Ÿ“ƒLicense + Notice
    • ๐Ÿ“‚Licensing
    • Notice of Third Party Agreements
  • ๐Ÿš€Perigee and Beyond
    • Extending - Threads
    • Extending - Loaders
    • โณAll about CRON
  • ๐Ÿ”ฎAPI Generation
    • What is API Generation?
    • API Builder
  • ๐Ÿ—บ๏ธArchitecting YOUR App
    • Design and Requirements
    • Define Sources
    • Requirements
  • ๐ŸงฉCore Modules
    • ๐ŸŒPerigeeApplication
    • ๐ŸชกThread Registry
    • Event Sources
      • Scheduled/Logic
        • CRON Thread
        • Scheduler
        • Sync Agent
      • Watchers
        • SalesForce
        • Sharepoint
        • Directory Watch
        • Directory Notifier
        • IMAP
    • Credential Management
      • Connection Strings
      • Custom Refresh Logic
      • RestSharp Authenticator
      • Credential Store SDK
      • โ‰๏ธTroubleshooting Credentials
    • Integration Utilities
      • HTTP(S) - RestSharp
      • Transaction Coordinator
      • Limiter
      • Watermarking
    • Alert Managers
      • SMS
      • Email
      • Discord
      • Teams
    • File Formats
      • Excel
      • CSV
    • ๐Ÿ“File System Storage
      • File Revision Store
      • Concurrent File Store
      • FileSync + Cache
    • Third Party
      • SmartSheets
      • Microsoft Graph
    • Perigee In Parallel
      • Parallel Processing Reference
      • Extensions
      • GroupProcessor
      • SingleProcessor
    • ๐ŸงฑUtility Classes
      • Metrics
      • F(x) Expressions
      • Multi-Threaded Processor (Scatter Gather)
      • OpenAI - GPT
      • XML Converter
      • Dynamic Data Table
      • Debounce
      • Thread Conditions
      • Perigee Utility Class
      • Network Utility
      • Lists
      • FileUtil
      • Inclusive2DRange
      • Strings, Numbers, Dates
      • Nested Sets
      • Behavior Trees
      • JsonCompress
      • Topological Sorting
      • DBDownloader
    • ๐ŸˆBit Serializer
  • ๐Ÿ“ฃExamples and Demos
    • API + Perigee
    • ๐Ÿ“ฐExcel Quick Load
    • SalesForce Watcher
    • Report Scheduler
    • Agent Data Synchronization
    • ๐Ÿ“ฉIMAP Echo bot
    • Watch and load CSVs
    • Graph Delegated Authorization + DataVerse
    • Coordinator Demo
    • Azure Service Bus
    • QuickBooks Online
  • ๐Ÿ“˜Blueprints
    • Perigee With .NET Hosting
    • Web Host Utilities
    • ๐Ÿ”ŒPlugin Load Context
  • ๐ŸŽž๏ธTransforms
    • ๐ŸŒŸWhat is Transforms?
    • ๐Ÿ“˜Terminology
    • ๐ŸฆพThe Mapping Document
    • ๐Ÿ‘พTransformation Process
    • ๐Ÿ˜ŽProfile
    • ๐ŸŽ’Automation
      • ๐Ÿ•“Package Options
      • ๐Ÿ”ณConfiguration
    • ๐Ÿ”งUtilities
      • ๐ŸงนClean
      • ๐Ÿ“‘Map File
      • ๐Ÿ”ŽFile Identification
      • ๐Ÿ—บ๏ธMap Generation
      • ๐Ÿช…Insert Statement Generation
  • ๐Ÿ—ƒ๏ธTransform SDK
    • ๐Ÿ‘‹Quick Start Guide
    • ๐ŸฅณMapTo
    • ๐Ÿ”ŒAuthoring Plugins
      • ๐Ÿ”˜File IO Process
      • ๐Ÿ“ขData Quality
      • ๐ŸŸขTransform Process
    • SDK Reference
      • ๐Ÿ”˜FileIOProcessData
      • ๐Ÿ“ขDataQualityContext
      • ๐ŸŽ›๏ธTransformDataContext
      • ๐Ÿ…TransformResult
Powered by GitBook
On this page
Export as PDF
  1. Core Modules
  2. Integration Utilities

Limiter

Another integration pattern is limiting the number of calls that can be made during a given period of time. This is important when rate limiting or billing may be an issue and is a perfect stop gap for a critical failure causing an erroneous number of API calls or running up an unwanted bill!

The Limiter auto resets it's count on the defined TimeSpan, and will not allow additional executions past the defined limit.

using Perigee;
using Perigee.Extensions;

PerigeeApplication.ApplicationNoInit("Limiter", (c) =>
{

    c.AddRecurring("Limiter", (ct, l) => {
    using var APILimit = new RateLimiter("RateLimiter.json", 2, TimeSpan.FromMinutes(1), ct);

    if (APILimit.CanExecute())
    {
        //Perform action
        l.LogInformation("Calling API {n}/{x} executions", APILimit.GetCount(), APILimit.GetLimit());
    }
    else
    {
        l.LogInformation("Out of executions...");
    }
});
});

/*
 [16:35:07 INF] Calling API 1/2 executions
 [16:35:13 INF] Calling API 2/2 executions
 [16:35:18 INF] Out of executions...
 */

PreviousTransaction CoordinatorNextWatermarking

Last updated 1 year ago

๐Ÿงฉ