@bigbinary/neeto-rate-limit-frontend
v2.1.1
Published
A repo acts as the source of truth for the new nano's structure, configs, data etc.
Downloads
8
Readme
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.rb
source "NEETO_GEM_SERVER_URL" do # ..existing gems gem "neeto-rate-limit-engine" end
Install the gem
bundle install
Add required migrations in the
db/migrate
folder. 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:migrate
Include the concern in
Organization
modelclass 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
ApplicationMailer
uses the correct base class (Refer to neetoForm for SolidQueue adapter)class ApplicationMailer < NeetoCommonsBackend::ApplicationMailer
Make sure that
organization_id
is 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 . . . end
Implement a
organization
method in the worker. This would be called inbefore_perform
callback, you can get the args usingarguments
attribute. Refer neetoForm's implementation.
Development with Host Application
Frontend package
Installation
Add the
neeto-rate-limit-frontend
package to thepackage.json
yarn 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.