Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Redis

สร้าง Scalable Distributed Business Rules Engine ด้วย Redis – คู่มือ Step-by-Step

Speed และ Efficiency เป็น Hallmarks of Excellence ใน Business Environment ที่ Fast-paced วันนี้

Organizations ที่ Entangled ใน Manual, Rigid Processes Bear the Weight of a Cumbersome Architecture และจะ Flat-footed ตลอดกาลเมื่อ Business Opportunities Pass Them By

แตผู้ที่มี Processes Automated จะ More Productive, More Agile และ Far More Likely to Experience Growth และนั่นคือเหตุผลที่ Organizations ต้องการ Distributed Business Rules Management System (DBRMS)

Looking to Make an Impact on the Business Community Vishrut Kohli Built His Very Own DBRMS, Bonsai โดยใช้ Redis Bonsai Guarantees Users an Application that Can Automate Processes in Real-time Maximizing Productivity Levels by Reducing the Likelihood of Lags from Occurring

Let's Take a Look at How This Application Was Made แต่ก่อนจะไปต่อ เราอยาก Point Out ที่เรายังมี Exciting Range of Innovative Apps สำหรับคุณ Check Out บน Redis Launchpad

So if You Enjoy This Post Make Sure to Have a Browse After!

How to Build a Distributed Business Rules Management System Using Redis

  1. What will you build?
  2. What will you need?
  3. Architecture
  4. Getting started
  5. Setting up the backend
  6. Setting up the frontend
  7. How it works
  8. How to carry out the different features

1. What will you build?

คุณจะสร้าง Distributed Business Rule Management Platform ที่จะช่วย Businesses Create, Manage และ Implement Scalable Business Rules Across the Enterprise Many Business Tasks Can Be Automated and Free Up Additional Resources that Could Be Invested Elsewhere in the Business

Application นี้จะ Enable Organizations to Specify, Deploy และ Manage Business Decision Rules และ Decision Logic So that Apps Can Consistently Make Intelligent Decisions with Speed และ Without Human Intervention

ด้านล่างเราจะ Highlight Components ที่คุณจะ Need to Bring This Application to Life as Well as Walk You Through Each Step of the Implementation Process

Ready to Get Started?

OK, Let's Get Straight Into It

2. What will you need?

  • Python: ใช้เป็น High-purpose Powerful Programming Language
  • Redis: In-memory Data Store to Ingest, Process, and Analyze Real-time Data with Sub-millisecond Latency
  • RedisJSON: ใช้เป็น Module that Provides JSON Support in Redis
  • RedisTimeSeries: ใช้เป็น Module that Adds Time Series Data Structure to Redis

3. Architecture

4. Getting Started

Ensure that You Have Redis Stack Database Up and Running:

5. Setting Up The Front End

Getting Started with Create React App

This Project Was Bootstrapped with Create React App

Step 1: Clone the frontend repository

Step 2: Install the dependencies

yarn install

Step 3: Use available scripts

In the Project Directory You Can Run the Following Scripts:

yarn start

Runs the App in the Development Mode

Open https://localhost:3000 to View it in the Browser

The Page Will Reload if You Make Edits

You'll Also See Any Lint Errors in the Console

yarn test

Launches the Test Runner in the Interactive Watch Mode

See the Section about Running Tests for More Information

yarn build

Builds the App for Production to the Build Folder

It Correctly Bundles React in Production Mode and Optimizes the Build for the Best Performance

The Build Is Minified and the Filenames Include the Hashes

Your App Will Now Be Ready to Be Deployed

yarn eject

Note: This Is a One-way Operation Once You Eject You Can't Go Back!

If You Aren't Satisfied with the Build Tool and Configuration Choices You Can Eject at Any Time This Command Will Remove the Single Build Dependency from Your Project

Instead It Will Copy All of the Configuration Files and the Transitive Dependencies (webpack, Babel, ESLint, etc) Right into Your Project So You Have Full Control Over Them All of the Commands Except Eject Will Still Work but They Will Point to the Copied Scripts So You Can Tweak Them At This Point You're on Your Own

You Don't Have to Ever Use Eject The Curated Feature Set Is Suitable for Small and Middle Deployments and You Shouldn't Feel Obligated to Use This Feature However We Understand that This Tool Wouldn't Be Useful if You Couldn't Customize It When You Are Ready for It

Step 4. Clone the Bonsai Rule Engine

git clone: ​​https://github.com/redis-developer/bonsai

Step 5. Install the Python dependencies

Step 6. Execute the script

6. How it works

Keywords

  • Namespace
  • Rules
  • entity

Namespace

The Most Logical Separation of Rules Is on the Basis of Namespace Namespace Is One Set of Rules Which Are to Be Evaluated on a Set of Data For Example Later in This Post You'll Build a Namespace for a Loyalty Management System and All of the Rules Regarding That Will Be Saved Under That Namespace

  • The Structure for Saving Our Data Is

Here Namespace Is:

tax_system.

The Command Used to Create the Namespace Is:

Entity

An Entity Refers to the Input of a Namespace and Will in Turn Provide an Output After Evaluating the Rules Present in That Namespace

Rules

Sub keywords
  • Predicates: This Means the Input Conditions for Your Rules
  • Results: This Means the Output Conditions for Your Rules
  • Operators: We Have 7 Operators:
    – eq which means =
    – range which means the value should lie between the given range (upper limit not included)
    – contains which means that the string should contain the input value given
    – gt which means greater than or >
    – gte which means greater than or equal to >=
    – lt which means lesser than <
    – lte which means lesser than or equal to <=

Say for Example We Wanted to Create a Rule that Determines the Tax Value of a Citizen Who Lives in the Province of Ontario and in the City of Toronto In Addition This Person Pays 35% Income Tax So We Have Two Variables – Province and City but One Output tax_rate

So in This Case One Example Predicate (input) of a Province is Ontario Can Be a Predicate Consisting of 4 Parts:

Each Rule Is a Command Which Decides What Should Be the Output to Any Particular Input (entity) Every Rule Will Get Saved into a Namespace via the Following Format:

Ontario and the city is Toronto the tax rate will be 35.

This Is the Rule Object:

Here Namespace Is:

loyalty_system
and Rule_id Is:
123456.

Command Used to Update Rule in Namespace Is:

Command Used to Get All Rules in Namespace Is:

Command Used to Get One Rule in Namespace by Rule_id Is:

7. How to carry out the different features

How to create a rule

สร้าง Scalable Distributed Business Rules Engine ด้วย Redis – คู่มือ Step-by-Step

On the Home Screen Click 'Create'

Next, Fill in the Different Fields to Complete Creating the Rule

Rule Visualization

After Creating the Rules You'll Be Able to Easily Visualize Them in the Form of a Flowchart

Rule Evaluation

The Evaluation Flow Contains All of the Attributes that Have Been Used to Create the Rules The Application Has a Code that Uses Pattern Matching Algorithms to See Which Rule Best Fits the Entity as Well as Emitting the Order in Which Rules Are Executed

Rule Analysis

RedisTimeSeries Allows You to Visualize All of the Metrics and Help You to Make Data-driven Decisions Based on the Performance of All the Rules in Their Namespace

Command Used to Expose Time Series Data:

TS.ADD ruleId * 1

Conclusion: Using real-time data to create a DBRMS platform that boosts efficiency

DBRMS Platforms Can Liberate Employees and Businesses from Having to Carry Out Time-consuming, Tedious Tasks that Are Essential to the Organization Automating These Tasks via a DBRMS Platform Can Completely Revitalize an Organization by Directing Each of Its Employees' Attention Towards Less Menial Tasks

However for a DBRMS System to Be Effective It Needs to Be Powered by a Real-time Database to Consistently Guarantee an Elite Level of Performance A Mere Lag Can Stagnate Process Efficiency Thereby Negatively Impacting Productivity

Thanks to Redis All Business Rules Were Able to Be Managed, Updated, and Maintained in Real-time This Allows You to Gain Real-time Insights on Performance and Make Instant Data-led Decisions that Will Help You Capitalize on Business Opportunities

If You Want to Discover More about How Bonsai Was Created Then Make Sure to Watch Vishrut's YouTube Video Here But That's Not All… We Also Have a Whole Range of Innovative Applications for You to Check Out on the Redis Launchpad

Programmers from All Around the World Are Tapping into the Magic of Redis to Make an Impact on Everyday Lives

Head On Over Be Inspired And Have Fun with Redis

Who Built The App?

Vishrut Kohli

Vishrut Is a Full-stack Developer and Data Enthusiast Who's Proficient in Python, MATLAB/octave, and Machine Learning Algorithms If You Want to Keep Up to Date with All of His Projects Then Make Sure to Follow Him on GitHub