Low-code platform to easily play business rules

Rules are the rules followed by operation and operation rules. Rules are everywhere, and the rules in social activities are usually formed by tradition and public knowledge, which are expressed as what to do or what not to do. In computer application systems, we often face such scenarios. When processing and executing an action, other conditions need to be established at the same time. The logic of this condition judgment is abstracted into rules and applied in large quantities. Through the management and use of rules, the system can be flexibly managed and applied flexibly in scenarios that have been abstracted into business rules. In particular, using the same rules in multiple scenarios can ensure cost reduction due to reuse and achieve business management consistency.

Business rule abstraction has become a good design pattern, especially in the implementation of many large-scale business systems. Inevitably, whether it is traditional high-code development or low-code implementation, application development will face the problem of rule development and use.

This article aims to discuss the processing of rules in development activities under the low-code mode. The actual supporting platform in this article is the Haojing Lingxi development platform.

business rule abstraction

In the experience of online shopping, I found that when buying a book, there are often no discounts. But when the total amount of the order meets certain conditions, you can get a discount, such as 50 off for orders over 300, or free shipping, gifts, etc. In fact, there are various discounts and benefits when purchasing not only books, but other items as well.

However, in the process of system implementation, if the promotion logic is developed separately for each product, it will be a huge workload for developers, because the types and quantities of products on the e-commerce platform are very large.

In fact, most merchants implement promotional activities through means such as the amount of orders, the quantity of products, or the attributes of special products. It can be abstracted into a general promotion rule: according to the ordered goods, the preferential conditions are judged, the preferential calculation is carried out, and the preferential results are finally output. Merchants only need to configure the discount strategy of the product, and the system can automatically calculate the logic to realize different promotion scenarios.

picture

In the system, the logic to implement the above rules is as follows:

First of all, the data that needs to be considered includes the product information ordered by the user and the product discount strategy information set by the merchant. These data will be used in the logical implementation of the rules.

Secondly, the logical judgment process includes the following steps:

  • Determine whether there is a preferential policy. Commodity information is used as the input parameter of the rule to determine whether the commodity has a preferential policy configured.

  • Determine whether the preferential conditions are established. According to the ordered product information and the discount strategy configured by the merchant, calculate whether the conditions for the discount are met.

  • Discount calculation. According to the discount method configured, discount calculation, gift calculation or free shipping calculation, etc. are performed.

  • Output the discount result. The preferential results calculated by the rules are output to the business system to complete the adjustment of commodity prices.

Next, we will introduce how to configure the above rules through low-code.

Business rule configuration

In low-code, the development of complex rule configuration mainly relies on an intuitive graphical configuration interface, in the way of "input parameter + component + output parameter", through simple drag and drop and configuration operations, to realize rule data configuration, logic configuration and result feedback.

picture

The first step  parameter configuration includes the following aspects:

Input parameter data: Through the visualization function, users can define the input parameter data of the rule.

It can be seen from the case that the input parameter of the rule is the list of ordered products, so parameter configuration is performed in the form of a form, and it supports display in the form of a structure tree, and supports different forms of parameter configuration such as attributes, objects, and arrays. A better practice.

Application data: The business data of the application may need to be used in the rules. Therefore, in the rule development process, it is necessary to support integrated SQL services, orchestration services, object operation services, etc. to obtain data, and to be able to combine these data with the logical components of the rules for application.

In the case, the commodity preferential policy information belongs to the data configured by the merchant in the system. In the Haojing Lingxi development platform, it is very simple to obtain internal data during rule logic arrangement, because it has a built-in object engine that encapsulates various object operation components, and only needs to select objects, actions, and conditions to easily Complete the data operation, as shown in the figure below:

picture

In addition to input data and application parameters, the implementation of many rules also involves external data and system variables.

  • External data: Refers to the data that is not in this application and needs to be obtained through the interface. This needs to support visual integration of external interfaces, access to data and operations.
  • System variables: System variables such as login information and environment information are also indispensable data in logical judgments. Therefore, it is also an essential function to support the operation of these variables in a visual way.

Step 2 : Logical Configuration

The way logic is implemented in low-code platforms is through a combination of data and actions. For various logic requirements, configurations of various logic components should be provided, including:

Comparison : During the rule logic configuration process, it supports the comparison of strings, data, attributes, objects and arrays to realize the definition of rule conditions. For example, to determine whether two strings are equal, to compare the size of data, to determine whether an attribute exists in an object, or to determine whether an array contains a certain element, etc.

Calculation : Provide configuration of various calculation functions, such as data calculation, character or array length calculation, etc.

Process control : The execution path of the program can be configured according to the judgment conditions, such as loop, jump out, branch, exit, etc.

Component Composition : Concatenation can be achieved by defining the order in which components are executed, thereby enabling component composition.

To obtain the preferential policy information configured by the merchant, determine whether there is a preferential policy for the product, and perform the discount calculation process, you only need to configure the "data component" in order to obtain product preferential policy information, the "comparison component" to determine whether there is a preferential policy, and the "calculation component" "By performing discount calculations, you can easily complete the arrangement of rule logic.

picture

Step Three : Results Feedback

In the configuration process, the return parameters of the rules are configured in an explicit way, which is easy to develop and understand the rules.

Step Four : Test Verification

During debugging, the executed nodes are highlighted to form an execution circuit diagram. The execution time, duration, input parameters, output parameters, and execution status of each node are displayed according to the execution order, which provides a very good means for troubleshooting during the rule execution process.

picture

The above is the process of rule configuration. Next, we will continue to introduce the use of rules.

business rule usage

In many scenarios, the business system needs to pass multiple rules to complete the complete business verification. Taking the commodity ordering scenario as an example, business verification is performed before the order is submitted, and there may be hundreds of verification rules. Therefore, in order to better realize the open call of rules, it is necessary to encapsulate the rules in the dimension of rule events, and at the same time support the integration of traditional applications and low-code applications.

picture

First of all, event configuration, event refers to the timing or action of the business system calling rules, which is used to explain and distinguish the buried points of the business system in different codes, and at the same time standardize the parameter requirements of the buried points. Event configuration mainly completes two operations:

  1. Parameter specification definition: According to the requirements of the business system, customize the parameter specification of the embedded point to adapt to each business system. All rules under the same event follow a unified parameter specification.
  2. Policy orchestration for rule execution: Supports the orchestration of the execution order and policies of rules in events, including different policies such as conditional, serial, and parallel.

Secondly, rule integration. According to different applications, there are two ways of rule integration:

  1. API method: For traditional applications, it is necessary to embed points in the system code to realize the call of rule events.
  2. Service node method: For low-code applications, business logic is mainly implemented through orchestration services. Therefore, in the orchestration service, it is necessary to support the binding of the event service through the "event" component, so as to realize the invocation of the rules.

picture

Business Rule Management

In addition to rule configuration development and open use, rule management also includes rule release and online, rule generation and failure management, and rule log analysis.

Release and launch : different low-code implementations have different ways of saving rules, and are generally saved in the form of compiled files, such as Java, PHP, or using Python and Groovy scripts. The Lingxi platform chooses to store data in the form of data. When publishing rules, you only need to export the rule data, and then import the data in the running environment to realize the release of the rules, without the need for complex operations such as environment deployment or code compilation and construction. This method simplifies the process of publishing rules and improves development efficiency.

Birth/failure management : In the rule design, you can set the effective time and expiration time of the rule, and the rule will only take effect within the specified time period. This feature is very useful for seasonal rules or limited-time promotion rules to avoid rules continuing to apply after expiration, thereby avoiding unnecessary conflicts and problems. At the same time, the management of rule generation/failure status is also very important. Through the control of the rule state, the adjustment and decision-making of the rules can be carried out in time according to the business requirements.

Rule logs : Logs have two important parts in rule management. First of all, the operation log records operations such as logical adjustments to rules and status changes, which facilitates the tracing of problems. Secondly, the operation log records the input parameters, output results, execution time, time-consuming and abnormal causes of the rule execution, which is helpful for quickly locating and solving problems.

In addition to supporting visual and graphical rule development, use, and management functions, we also need to focus on configuration efficiency and configuration flexibility:

0 1  configuration efficiency problem

In the process of configuring rules, parameter objects of different complexity will lead to lower configuration efficiency. When encountering multi-rule development scenarios, the efficiency problem becomes more prominent. Therefore, we need to enhance the tool's own capabilities to deal with efficiency issues through automatic generation, default default, one-click operation, batch processing, etc.:

Automatically generate parameters : On the event, add an entry for rule creation. When creating a rule, automatically generate the parameters of the rule through the parameter specification of the event, and allow the parameters to be tailored.

Automatic parameter assignment : realize the automatic parameter assignment function in the rule arrangement process. When adding an event node to service orchestration, or when adding a rule to an event, it can automatically match the context and assign values ​​according to the parameter name.

One-click message generation parameters : When configuring parameters for events and rules, it supports one-click message generation parameter configuration. In the traditional development process, the efficient ctrl+c and ctrl+v can be well applied.

Adding rules in batches : Add a batch rule component in the event arrangement, in which multiple rules can be selected in batches to add to the event. The policy of rule execution can be defined in the group, such as serial or parallel. This not only simplifies the event orchestration canvas, but also improves the efficiency of adding rules.

Increase the operation and maintenance view : Add the view of association rules in the event, and add the associated event view in the rule designer, so that you can clearly evaluate the scope of influence when adjusting the rules.

0 2  Configuration flexibility issues

Different from traditional rule engines, the rule execution strategy of the low-code platform is implemented through event orchestration. During the execution process, problems such as merging of all rule execution results and interdependence and sharing of parameters under the same event will be encountered. Therefore, it is technically necessary to support summary calculation of rule results, support event-level data bus, and realize data sharing and transmission.

picture

Add rule result calculation component . Every time a rule is added or deleted, the result and return parameters of the rule will be automatically recorded in the component. The component supports the strategy of setting the result return, for example: return success when all rules are verified successfully, or return success as long as one of them succeeds.

Introduce event-level dataBus data bus . The data bus is initialized in the event start link, and the data storage space is destroyed after the event ends. During this process, each rule can write data to and read data from the data summary.

For the development of complex business rules, the Haojing Lingxi development platform provides very convenient development tools, which are used in a large number of projects. Through the Haojing Lingxi development platform, developers can easily complete the configuration of rules, truly realize the visual management and graphical development of business rules, greatly improve the development efficiency, and achieve very flexible real-time release. In the future, it will continue to combine with large-scale model technology to achieve technological breakthroughs such as more intelligent business rule management and decision support, automated rule verification and correction, and the combination of business rule execution and monitoring. The future can be expected.

Guess you like

Origin blog.csdn.net/whalecloud/article/details/132289722