@bigbinary/neeto-rate-limit-frontend v2.1.3
neeto-rate-limit-nano
The neeto-rate-limit-nano can be used to rate-limit the execution of background jobs. (Non-sidekiq for now, ActiveJob, SolidQueue)
Setup
The following setup would be already present for existing apps, add it if your app is new.
Add the gem in
Gemfile.common.rbsource "NEETO_GEM_SERVER_URL" do # ..existing gems gem "neeto-rate-limit-engine" endInstall the gem
bundle installAdd required migrations in the
db/migratefolder. Run the following commands to copy the migrations from the engine to the host application. Ex: neetoDeskrails neeto_rate_limit_engine:install:migrations rails db:migrateInclude the concern in
Organizationmodelclass Organization < ApplicationRecord . . include NeetoRateLimitEngine::Helpers end
Rate limiting email deliveries for an organization:
The emails are rate-limited automatically for all products from neeto-commons-backend. If this is not working in some apps, please create an issue or make sure the app has following setup.
Follow the steps mentioned in Setup section
Make sure
ApplicationMaileruses the correct base class (Refer to neetoForm for SolidQueue adapter)class ApplicationMailer < NeetoCommonsBackend::ApplicationMailerMake sure that
organization_idis available in the params for all the mailersUserMailer .with(organization_id: @organization.id, user_id: @user.id) .welcome_email .deliver_later
Rate limiting job deliveries for an organization:
Rate limits don't work for Sidekiq jobs. This only works for ActiveJobs. SolidQueue adapter is supported too.
Follow the steps mentioned in Setup section
Include the concern in the job
class HardJob < ActiveJob::Base include NeetoRateLimitEngine::Throttler . . . endImplement a
organizationmethod in the worker. This would be called inbefore_performcallback, you can get the args usingargumentsattribute. Refer neetoForm's implementation.
Development with Host Application
Frontend package
Installation
Add the
neeto-rate-limit-frontendpackage to thepackage.jsonyarn add @bigbinary/neeto-rate-limit-frontend
Instructions for development
Check the Frontend package development guide for step-by-step instructions to develop the frontend package.
Usage
Import WelcomeScreen component from "@bigbinary/neeto-rate-limit-frontend"
import React from "react";
import { WelcomeScreen } from "@bigbinary/neeto-rate-limit-frontend";
const App = () => <WelcomeScreen />;
export default App;Instructions for Publishing
Consult the building and releasing packages guide for details on how to publish.