定制 alialican/hubspot-rate-limiter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alialican/hubspot-rate-limiter

最新稳定版本:v1.0.1-beta

Composer 安装命令:

composer require alialican/hubspot-rate-limiter

包简介

This package wraps default hubspot/api-client package with a rate limiter, so that you dont breach API limits

README 文档

README

This package provides a rate limiting wrapper for the HubSpot API client, allowing you to set per-second and daily rate limits for your HubSpot API calls. It leverages the Redis cache store for efficient rate limiting. If Redis is not available, it falls back to a generic cache implementation.

Installation

Install the package using Composer:

composer require alialican/hubspot-rate-limiter

Usage:

1.Import the package in your code:

use HubSpotRateLimiter\HubSpotClientWrapper;

2.Create an instance of the HubspotClientWrapper class and pass in the required dependencies:

use Illuminate\Support\Facades\Cache;
use HubSpot\Discovery\Discovery;

$hubspotClient = new Discovery();

$secondLimit = 100; // Replace with your desired per-second limit
$dailyLimit = 250000; // Replace with your desired daily limit

$hubspot = new HubspotClientWrapper($hubspotClient, $secondLimit, $dailyLimit);

Use the $hubspot instance as you would use the original HubSpot API client. The rate limiter will automatically enforce the specified rate limits on each API call.

$result = $hubspot->crm()->contacts()->getAll();

Important Points

This package uses Laravel's Cache facade for rate limiting. Make sure you have the proper cache driver set up in your Laravel configuration. When the cache driver is Redis, the rate limiter directly interacts with Redis for efficient rate limiting. Ensure that your Redis configuration is correctly set up. If your Redis setup is unusual or complex, the Redis-based rate limiting may not work as expected. The rate limiting mechanism used in the enforceRateLimitGeneric method is simplistic and may not handle high rates of concurrency as efficiently as the Redis-based solution. The package assumes that the Redis server supports the eval command, as it uses Lua scripts for rate limiting. If your Redis server does not support this command, the rate limiting may fail. Please test the package thoroughly in your specific environment to ensure it meets your requirements and works correctly with your Redis configuration.

License This package is open-source and licensed under the MIT License.

Feel free to customize and expand on the README to provide more information or clarify any additional details specific to your use case.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固