CN114647416A - Method and device for realizing service flow based on annotation, storage medium and electronic equipment - Google Patents

Method and device for realizing service flow based on annotation, storage medium and electronic equipment Download PDF

Info

Publication number
CN114647416A
CN114647416A CN202210314057.3A CN202210314057A CN114647416A CN 114647416 A CN114647416 A CN 114647416A CN 202210314057 A CN202210314057 A CN 202210314057A CN 114647416 A CN114647416 A CN 114647416A
Authority
CN
China
Prior art keywords
service
target
code segment
annotation
code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210314057.3A
Other languages
Chinese (zh)
Inventor
汪忠祥
刘强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Bodun Xiyan Technology Co ltd
Original Assignee
Hangzhou Bodun Xiyan Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Bodun Xiyan Technology Co ltd filed Critical Hangzhou Bodun Xiyan Technology Co ltd
Priority to CN202210314057.3A priority Critical patent/CN114647416A/en
Publication of CN114647416A publication Critical patent/CN114647416A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/43Checking; Contextual analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/45Exploiting coarse grain parallelism in compilation, i.e. parallelism between groups of instructions
    • G06F8/451Code distribution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The present disclosure relates to the technical field of computers, and provides an annotation-based service flow implementation method, an annotation-based service flow implementation apparatus, a computer storage medium, and an electronic device, wherein the annotation-based service flow implementation method includes: after a business flow framework is started, loading a plurality of code segments for realizing a target business flow and annotation information associated with each code segment; the target service flow comprises a plurality of service nodes, and a preset incidence relation exists between the plurality of code segments and the plurality of service nodes; the annotation information is at least used for marking the execution sequence of each code segment; and executing the code segments according to the annotation information to realize the target business flow. The method in the disclosure can reduce the expansion difficulty and the expansion cost of the service and improve the service development efficiency.

Description

Method and device for realizing service flow based on annotation, storage medium and electronic equipment
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to an annotation-based service flow implementation method, an annotation-based service flow implementation apparatus, a computer storage medium, and an electronic device.
Background
With the development of computer processing technology, a technology for realizing a service based on computer code has emerged. After the computer code is set, the computer device executes the set computer code, and the corresponding service can be realized.
At present, a service flow is generally arranged by adopting a responsibility chain mode, and the service flow is executed by adopting a mode of a strategy mode and a thread pool, but when a new task unit needs to be added, besides the development of the new task unit, extra codes for modifying the responsibility chain or codes related to the thread pool are needed, and the service expansion cost is high.
In view of this, there is a need in the art to develop a new method and apparatus for implementing a service flow.
It is to be noted that the information disclosed in the background section above is only used to enhance understanding of the background of the present disclosure.
Disclosure of Invention
The present disclosure aims to provide an annotation-based service flow implementation method, an annotation-based service flow implementation apparatus, a computer storage medium, and an electronic device, thereby overcoming, at least to some extent, the defect of high service expansion cost in the related art.
Additional features and advantages of the disclosure will be set forth in the detailed description which follows, or in part will be obvious from the description, or may be learned by practice of the disclosure.
According to a first aspect of the present disclosure, there is provided an annotation-based service flow implementation method, including: after a business flow framework is started, loading a plurality of code segments for realizing a target business flow and annotation information associated with each code segment; the target service flow comprises a plurality of service nodes, and a preset incidence relation exists between the plurality of code segments and the plurality of service nodes; the annotation information is at least used for marking the execution sequence of each code segment; and executing the code segments according to the annotation information to realize the target business flow.
In an exemplary embodiment of the present disclosure, the service node includes at least a primary node and a secondary node, and the primary node corresponds to a processing stage included in the target service flow; the secondary node corresponds to the processing steps included in each of the processing stages.
In an exemplary embodiment of the present disclosure, the plurality of code segments includes a specific code segment corresponding to each of the primary nodes, and one or more candidate code segments corresponding to each of the secondary nodes; when any of the secondary nodes corresponds to a plurality of candidate code segments, executing the plurality of code segments according to the annotation information to realize the target business flow, comprising: acquiring a current application scene of the target service flow; the current application scenario depends on one or more of the following parameters: service deployment information, partner information, and service type; determining a target code segment corresponding to the current application scene from the candidate code segments according to a pre-stored corresponding relation table between different application scenes and different target code segments; executing the specific code segment according to the annotation information associated with the specific code segment, and executing the target code segment according to the annotation information associated with the target code segment to implement the target business flow.
In an exemplary embodiment of the present disclosure, the determining, according to a pre-stored correspondence between different application scenarios and different target code segments, a target code segment corresponding to the current application scenario from among the multiple candidate code segments includes: and determining a target code segment meeting the first query condition from the candidate code segments according to the corresponding relation table by taking the service deployment information, the partner information and the service type as the first query condition.
In an exemplary embodiment of the present disclosure, the method further comprises: if the target code segment meeting the first query condition is not queried, taking the service deployment information and the partner information as a second query condition; and determining a target code segment meeting the second query condition from the candidate code segments according to the corresponding relation table.
In an exemplary embodiment of the present disclosure, the method further comprises: if the target code segment meeting the second query condition is not queried, taking the service deployment information as a third query condition; and determining a target code segment meeting the third query condition from the candidate code segments according to the corresponding relation table.
In an exemplary embodiment of the present disclosure, the method further comprises: and if the target code segment meeting the third query condition is not queried, determining a pre-specified candidate code segment as the target code segment.
In an exemplary embodiment of the present disclosure, loading annotation information associated with each of the code segments comprises: scanning a preset storage path based on a java reflection mechanism to obtain the annotation information associated with each code segment; the preset storage path is used for storing the annotation information; and loading the annotation information obtained by scanning into a memory.
According to a second aspect of the present disclosure, an annotation-based service flow implementation apparatus is provided, which includes: the information loading module is used for loading a plurality of code segments for realizing the target business flow and annotation information associated with each code segment after the business flow framework is started; the target service flow comprises a plurality of service nodes, and a preset incidence relation exists between the plurality of code segments and the plurality of service nodes; the annotation information is at least used for marking the execution sequence of each code segment; and the code execution module is used for executing the code segments according to the annotation information so as to realize the target business flow.
According to a third aspect of the present disclosure, there is provided a computer storage medium having stored thereon a computer program which, when executed by a processor, implements the annotation based traffic flow implementation method of the first aspect described above.
According to a fourth aspect of the present disclosure, there is provided an electronic device comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the method for implementing an annotation based service flow according to the first aspect via executing the executable instructions.
As can be seen from the foregoing technical solutions, the method for implementing a service flow based on an annotation, the apparatus for implementing a service flow based on an annotation, the computer storage medium, and the electronic device in the exemplary embodiments of the present disclosure have at least the following advantages and positive effects:
in the technical solutions provided in some embodiments of the present disclosure, on one hand, by splitting a target service flow into a plurality of service nodes, each service node corresponds to an independent code segment, decoupling between codes can be achieved, and the difficulty in maintaining the codes is reduced. On the other hand, the execution sequence of each code segment is marked through the annotation information, and the annotation information is utilized to realize the mode of the target service flow, so that a developer can conveniently expand the original service, the developer does not need to consider the coupling relation between the newly added code segment and the original code when the service is expanded, the technical problems of large invasion to the original code and high service expansion cost caused by large modification on the original code are avoided, the service expansion cost is reduced, and the service development speed is increased.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure. It is to be understood that the drawings in the following description are merely exemplary of the disclosure, and that other drawings may be derived from those drawings by one of ordinary skill in the art without the exercise of inventive faculty.
FIG. 1 is a flow chart diagram illustrating an annotation based service flow implementation method according to an embodiment of the disclosure;
fig. 2 shows a schematic diagram illustrating a traffic flow implemented by a responsibility chain arrangement pattern in the related art;
FIG. 3 shows a schematic diagram of the expansion of services in a responsibility chain orchestration mode;
FIG. 4 is a diagram illustrating a related art implementation of a service flow through a workflow framework;
fig. 5 shows a schematic diagram of Pipeline formed by orchestration in an embodiment of the disclosure;
FIG. 6 is a flow diagram illustrating the determination of a target code section from a plurality of candidate code sections in an embodiment of the present disclosure;
FIG. 7 is a block diagram illustrating an overall process for determining a target code segment from a plurality of candidate code segments in an embodiment of the disclosure;
FIG. 8 is a schematic diagram illustrating an architecture of an annotation based traffic flow implementing apparatus according to an exemplary embodiment of the present disclosure;
fig. 9 shows a schematic structural diagram of an electronic device in an exemplary embodiment of the present disclosure.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. Example embodiments may, however, be embodied in many different forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the subject matter of the present disclosure can be practiced without one or more of the specific details, or with other methods, components, devices, steps, and the like. In other instances, well-known technical solutions have not been shown or described in detail to avoid obscuring aspects of the present disclosure.
The terms "a," "an," "the," and "said" are used in this specification to denote the presence of one or more elements/components/parts/etc.; the terms "comprising" and "having" are intended to be inclusive and mean that there may be additional elements/components/etc. other than the listed elements/components/etc.; the terms "first" and "second", etc. are used merely as labels, and are not limiting on the number of their objects.
Furthermore, the drawings are merely schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus their repetitive description will be omitted. Some of the block diagrams shown in the figures are functional entities and do not necessarily correspond to physically or logically separate entities.
At present, the traffic flow is generally arranged in two ways:
the first method is based on a responsibility chain mode + a policy mode + a thread pool, and referring to fig. 2, fig. 2 shows a schematic diagram of implementing a service flow through a responsibility chain mode in the related art, specifically, a task is split into a plurality of subtasks (for example, split into 4 subtasks), then, whether the plurality of subtasks are executed serially or in parallel is determined, if the plurality of subtasks are executed serially, referring to fig. 2, the plurality of subtasks are directly registered in the responsibility chain, and are executed serially through the processor 1, the processor 2, the processor 3 and the processor 4, and if the plurality of subtasks are not executed serially, the plurality of subtasks are combined into a task unit, and after the task unit is registered in the responsibility chain, the task unit executes the subtasks in parallel through the thread pool. However, this method is less scalable and flexible, and when a task execution process needs to add a new task unit, in addition to developing the new task unit, it needs to modify code of the chain of responsibility or add code related to the thread pool, which is very intrusive to the original code.
In this arrangement, when a branch logic needs to be added or a site/scene needs to be added, if else judgment is generally added, and judgment is added in a hard-coding coupling manner to drive the service branch flow to execute. Referring to fig. 3, fig. 3 is a schematic diagram illustrating service expansion in a responsibility chain arrangement mode, as shown in fig. 3, in a case where a condition 3 needs to be newly added, if judgment about the condition 3 needs to be added on the basis of an original code, however, a large number of if else causes severe code coupling, a hard coding manner causes high distribution cost and transformation cost, a service logic is complex, understanding and maintenance are difficult, a development and test period is long, and a development cost is high.
The second is to introduce a workflow framework based on which business flows are orchestrated. Referring to fig. 4, fig. 4 is a schematic diagram illustrating that a service flow is implemented by a workflow framework in the related art, a task is first split into a plurality of subtasks (e.g., 4 subtasks), then, an execution code of each task is written, an execution flow of the task is defined in xml (Extensible Markup Language) or a database table, and then the workflow framework drives the task to execute. However, this solution requires the additional introduction of a workflow framework, and the workflow framework is more suitable for being used in a scenario involving different people to process different things or involving an automated process, and the introduction of this framework is not very suitable for the scenario on one hand, and on the other hand, defining a task execution process in xml or a database is complex for configuration implementation and testing, and the introduction of this complexity makes development cost and understanding cost high, and testing and maintenance cost high.
In this arrangement, when service expansion is required, a design pattern such as a policy pattern and multiple states of an object are generally used to solve the problem. When the new realization or the new dimension is expanded, an interface or a new realization class is added. However, the method can be well supported in scenes such as one-dimensional expansion and two-dimensional expansion, but when the method is used for multi-dimensional expansion such as three-dimensional expansion and four-dimensional expansion, especially in a Software-as-a-service (Software as a service) scene of multi-site and multi-tenant, a great number of sub-implementation classes are brought, and the maintenance is difficult.
In the embodiments of the present disclosure, firstly, an annotation-based service flow implementation method is provided, which overcomes, at least to some extent, the defect of high cost of service expansion in the related art.
Fig. 1 is a schematic flow chart illustrating an annotation-based service flow implementation method according to an embodiment of the present disclosure, where an execution subject of the annotation-based service flow implementation method may be a server that implements a service flow.
Referring to fig. 1, an annotation based traffic flow implementation method according to one embodiment of the present disclosure includes the steps of:
step S110, after the business flow framework is started, loading a plurality of code segments for realizing the target business flow and annotation information associated with each code segment; the target service flow comprises a plurality of service nodes, and a preset incidence relation exists between a plurality of code segments and the plurality of service nodes; the annotation information is at least used for marking the execution sequence of each code segment;
and step S120, executing a plurality of code segments according to the annotation information to realize the target business flow.
In the technical solution provided in the embodiment shown in fig. 1, on one hand, by splitting the target service flow into a plurality of service nodes, each service node corresponds to an independent code segment, decoupling between codes can be achieved, and the difficulty in maintaining the codes is reduced. On the other hand, the execution sequence of each code segment is marked through the annotation information, and the annotation information is utilized to realize the mode of the target service flow, so that a developer can conveniently expand the original service, the developer does not need to consider the coupling relation between the newly added code segment and the original code when the service is expanded, the technical problems of large invasion to the original code and high service expansion cost caused by large modification on the original code are avoided, the service expansion cost is reduced, and the service development speed is increased.
The following describes the specific implementation of each step in fig. 1 in detail:
the service flow in the present disclosure refers to a related flow established after reading and analyzing a certain service project requirement, and may include a plurality of service phases, and each service phase is driven by a flow condition.
Before step S110, the target service flow may be split into a plurality of service nodes according to the execution logic of each target service flow. For example, the execution logic of each target traffic flow may be regarded as a Pipeline (Pipeline), and then the target traffic flow is first split into a plurality of processing stages (Phase), each processing stage being a primary node, and further each processing stage is split into a plurality of processing steps (Step), each processing Step corresponding to a secondary node.
The specific splitting process can be executed by related service developers, or a machine learning model for splitting service logic can be trained in advance, and then the target service flow is analyzed, structurally split and logically abstracted through the machine learning model, so that the target service flow is split into three dimensions.
Illustratively, taking a target service flow as a deduction service as an example for explanation, the Pipeline of deduction may be split into 3 stages, where the first stage is a verification stage, the second stage is a deduction stage, and the third stage is a balance update stage, where the verification stage may include two steps of identity verification and mobile phone number verification, the deduction stage includes a deduction step, and the balance update stage includes a balance update step.
Furthermore, the business developer can take each step as a programming unit, write code segments for each step respectively, and add annotation information to each code segment. The annotation information may be java annotation, which provides a secure annotation-like mechanism for associating any information or metadata (metadata) with the program elements (class, method, member variable, etc.), and adding more intuitive and clear description to the program elements (class, method, member variable), wherein the description information is independent of the business logic of the program and is used by a specified tool or framework. Note that like a modifier, it applies to declarative statements for packages, types, construction methods, member variables, parameters, and local variables. Java annotations are some meta-information attached to the code for some tools to parse and use in compiling and running, and to serve as description and configuration functions. The annotations do not affect the actual logic of the code, and serve only an ancillary role.
Illustratively, annotation information in this disclosure may contain three classes, @ Pipeline, @ Phase, and @ Step.
The @ Pipeline is annotation information of the service dimension, and the @ Pipeline annotation contains information of name xxx and is used for identifying the target service flow corresponding to the Pipeline.
The @ Phase is annotation information of the Phase dimension, and the @ Phase annotation contains information of Pipeline xxx and is used for identifying the target business flow to which the Phase belongs. Also, the following properties may be defined in the @ Phase annotation: a parallel attribute for indicating whether the Step included in Phase is executed in parallel or in series; order attribute for indicating the execution order of steps included in Phase; the timeout attribute is used for indicating the execution timeout time of Phase; fourthly, the poolsize attribute is used for indicating the number of thread pools used in the Phase execution process; requirement attribute for indicating Phase needs to be executed.
@ Step is annotation information of Step dimension, and contains information such as Pipeline xxx and Phase xxx, indicating which Pipeline and Phase the Step belongs to.
It should be noted that the present disclosure also supports the use of @ Reference annotation to directly Reference a certain written annotation, and avoid the repeated definition of the same annotation, thereby improving annotation writing efficiency and business development efficiency.
After writing the code segments and marking the annotation information associated with the code segments, the code segments and the annotation information thereof may be stored in a preset storage path (for example, an engineering root directory, which may be set according to the actual situation, and this disclosure does not make any special limitation on this).
In step S110, after the service flow framework is started, a plurality of code segments for implementing the target service flow and annotation information associated with each code segment are loaded.
In this step, after the service flow framework is started, the pre-written code segments and the annotation information associated with each code segment may be loaded by using an initialization program. The service flow framework may be a tdframe framework.
For example, the above code segments may be traversed to find whether an identifier of "@" exists in the code segment, and if the identifier exists, it indicates that the code segment has corresponding annotation information, and further, the java reflection mechanism may be utilized to scan the preset storage path to obtain the annotation information associated with each code segment, and load the annotation information into the memory, and then jump to the next code segment, and repeatedly perform the steps of finding and scanning until the loading of the annotation information associated with each code segment is completed.
After the annotation information associated with each code segment is loaded, the service flow framework may compile a plurality of phases included in the target service flow and a plurality of steps included in each Phase according to an execution order (order attribute) included in the annotation information and a serial-parallel relationship (parallel attribute) between the steps, so as to form a Pipeline corresponding to the target service flow.
Illustratively, referring to fig. 5, fig. 5 shows a schematic diagram of Pipeline formed by programming in an embodiment of the present disclosure, as shown in fig. 5, the Pipeline includes 3 phases, Phase1, Phase2, and Phase3, wherein Phase1 includes 2 serial steps, respectively, Step1 and Step2, Phase2 includes 3 parallel steps, respectively, Step1, Step2, and Step3, and Phase3 includes 1 Step, i.e., Step 1.
Referring next to fig. 1, in step S120, a plurality of code segments are executed according to the annotation information to implement the target traffic flow.
In this step, it should be noted that each primary node corresponds to a specific code segment, and each secondary node may correspond to one or more candidate code segments.
In an optional implementation manner, in an initial stage of service development, since a service application scenario is relatively single, there may be a case where only one candidate code segment corresponds to a secondary node, in this case, it is not necessary to distinguish different service scenarios, and only the plurality of code segments need to be sequentially executed according to configuration information such as an execution sequence included in the annotation information, so that the target service flow can be realized.
In another optional implementation, as the service is continuously expanded, the service application scenarios are gradually enriched, and at this time, in order to adapt to different service application scenarios, a situation in which a plurality of candidate code segments exist under a certain secondary node may occur.
Different business application scenarios depend at least on one or more of the following parameters: the service deployment information, the partner information and the service type may also be other parameters hooked with the actual service, and may be set by itself according to the actual situation, which is not particularly limited by the present disclosure.
The service deployment information may include site information and service user information, where the site information may be a deployment location of the service, for example: different countries (e.g., nation A, nation B, and nation C) or different provinces and cities (e.g., province A, province B, and city C) of a certain country; the service user information may be the user name of the service, such as: prescription A, prescription B, prescription C, etc.
Partner information, i.e. objects for the service developers to cooperate together to complete the target service, for example: bank A, bank B, bank C, etc.
The type of service depends on the specific content of the service, for example: a service, B service, C service, etc.
For example, taking a secondary node as a verification step, the secondary node includes 10 candidate code segments, and service deployment information is site information for explanation, when the site information is country a, a partner is bank a, and a service type is service a, what may need to be executed in the verification step is candidate code segment 1; when the site information is country a, the partner is bank a, and the service type is service B, what may need to be performed in the verification step is candidate code segment 2. When the site information is country a and the partner is bank B, the verification step may need to be executed by the candidate code segment 3; when the site information is country a and the partner is bank C, the verification step may need to be performed on the candidate code segment 4. When the site information is country C, it may be necessary to perform the verification step on the candidate code segment 5.
Therefore, the method and the device for optimizing the service development efficiency pre-store the corresponding relation table between different application scenes (namely different combination results of three dimensional parameters of the service deployment information, the partner information and the service type) and the target code segment to be executed so as to adapt to the condition that the target code segment is rapidly adapted from a plurality of candidate code segments under the multi-dimensional application scene, and the service development efficiency is improved.
Therefore, in a specific service execution process, when any secondary node contains a plurality of candidate code segments, a current application scene of a target service flow can be obtained, further, a target code segment corresponding to the current application scene is determined from the plurality of candidate code segments according to the pre-stored correspondence table between different application scenes and different target code segments, further, the specific code segment is executed according to annotation information associated with the specific code segment, and the target code segment is executed according to the annotation information associated with the target code segment, so that the target service flow is realized.
Specifically, referring to fig. 6, fig. 6 is a schematic flowchart illustrating a process of determining a target code segment from a plurality of candidate code segments in the embodiment of the present disclosure, including steps S601-S604:
in step S601, the service deployment information, the partner information, and the service type are used as first query conditions, and a target code segment satisfying the first query conditions is determined from the plurality of candidate code segments according to the correspondence table.
In this step, the service deployment information, the partner information, and the service type may be first used as a first query condition, and the correspondence table is queried whether a query result (for example, an identifier of a target code segment that satisfies the first query condition) corresponding to the first query condition is stored in advance, and if the query result is obtained, the obtained query result is determined as the target code segment.
If the target code segment meeting the first query condition is not queried, step S602 is performed, where the service deployment information and the partner information are used as second query conditions, and the target code segment meeting the second query condition is determined from the plurality of candidate code segments according to the correspondence table.
In this step, the service deployment information and the partner information may be used as a second query condition, and the correspondence table is queried whether a query result (for example, an identifier of a target code segment that satisfies the second query condition) corresponding to the second query condition is stored in advance, and if the query result is found, the obtained query result is determined as the target code segment.
If the target code segment meeting the second query condition is not queried, step S603 is performed, and the target code segment meeting the third query condition is determined from the plurality of candidate code segments according to the correspondence table, with the service deployment information as the third query condition.
In this step, the service deployment information may be used as a third query condition, and the correspondence table is queried whether a query result (for example, an identifier of a target code segment that meets the third query condition) corresponding to the third query condition is stored in advance, and if the query result is obtained, the obtained query result is determined as the target code segment.
If the target code segment satisfying the third query condition is not queried, step S604 is performed to determine the pre-specified candidate code segment as the target code segment.
In this step, the pre-specified candidate code segment may be determined as the target code segment, so as to provide a bottom-of-pocket scheme, thereby avoiding the problem that the service cannot be realized.
After the target code segment is determined from the plurality of candidate code segments, the specific code segment can be executed according to the annotation information of the specific code segment according to the arranged Pipeline sequence, and the target code segment can be executed according to the annotation information of the target code segment, so as to realize the target business flow.
Exemplarily, referring to fig. 7, T in fig. 7 represents service deployment information, B represents partner information, and P represents a service type, fig. 7 shows an overall flowchart of determining a target code segment from a plurality of candidate code segments in the embodiment of the present disclosure, which includes steps S701 to S715:
in step S701, start;
in step S702, the target code segment is queried according to (service deployment information, partner information, and service type);
in step S703, is found?
If yes, the method goes to step S704 to determine the target code segment, and then goes to step S715 to end; if not, the step S705 is executed, and the target code segment is inquired according to the service deployment information and the partner information;
in step S706, if?
If yes, the process proceeds to step S707 to determine a target code segment, and further, the process proceeds to step S715 to end; if not, the step S708 is executed, and the target code segment is queried according to the (service deployment information);
in step S709, if?
If yes, the method proceeds to step S710, determines a target code segment, and further proceeds to step S715, and ends; if not, the process proceeds to step S711, and a default version is queried;
in step S712, whether?
If yes, the process goes to step S713, where the target code segment is determined, and then, the process goes to step S715, and the process ends; if not, the process proceeds to step S714, and returns not found.
It should be noted that, because the code segments of each service stage in the present disclosure are decoupled from each other, when a service extension needs to add an application scenario under a certain secondary node, a developer only needs to write an additional code segment for the new application scenario, and indicates a corresponding relationship between the additional code segment and the new application scenario in annotation information of the additional code segment, and further, in a subsequent service execution process, the service flow framework may directly update the corresponding relationship table according to the scanned annotation information, so that, when it is determined that the current application scenario is the new service scenario, the service flow framework may directly call the annotation information and execute the additional service code. Therefore, when the service is expanded, developers do not need to consider the coupling relation between the newly added code segments and the original codes, the technical problems that the original codes are greatly invaded and the service expansion cost is high due to the fact that a large amount of modifications are carried out on the original codes are solved, the service expansion cost is reduced, and the service development speed is increased.
Based on the technical scheme, the following technical effects can be realized by the method:
on one hand, according to the method, different stages and different tasks can be freely assembled on the Pipeline through the design of Pipeline, Phase and Step, so that the tasks can be split and arranged in a mode closer to business semantics under different business scenes, flexible expansion and reuse are facilitated, and understanding and development are facilitated.
Furthermore, Step is arranged in Phase based on an annotation mode, Phase is arranged in Pipeline, when function logic is added, the original logic is not invaded, and new task logic can be added at a required position through simple annotation arrangement. This greatly increases the speed of development, and the non-intrusive nature also makes regression testing less costly.
Further, in the pipeline, parallel or serial execution may be supported by annotation, the priority of Phase and Step may be specified, and the thread resource consumption threshold in each Phase may be specified. The flexible fine-grained expansion points are designed and embedded, so that developers can flexibly and freely arrange and design in the development process, and can conveniently expand and support different business scenes.
On the other hand, target code segments corresponding to different service scenes are stored in advance, so that the target code segments required by the specific execution of each Step can be flexibly loaded according to the service application scenes, and therefore the method and the system can be applied to complex saas scenes and support complex and variable services under the situations of different service deployment information, partner information, service types and the like.
The present disclosure also provides an annotation-based service flow implementation apparatus, and fig. 8 shows a schematic structural diagram of the annotation-based service flow implementation apparatus in the exemplary embodiment of the present disclosure; as shown in FIG. 8, annotation based traffic flow implementation apparatus 800 may include an information loading module 810 and a code execution module 820. Wherein:
an information loading module 810, configured to load, after a business flow framework is started, a plurality of code segments for implementing a target business flow and annotation information associated with each of the code segments; the target service flow comprises a plurality of service nodes, and a preset incidence relation exists between the plurality of code segments and the plurality of service nodes; the annotation information is at least used for marking the execution sequence of each code segment;
a code executing module 820, configured to execute the plurality of code segments according to the annotation information to implement the target service flow.
In an exemplary embodiment of the present disclosure, the service node includes at least a primary node and a secondary node, and the primary node corresponds to a processing stage included in the target service flow; the secondary node corresponds to the processing steps included in each of the processing stages.
In an exemplary embodiment of the present disclosure, the plurality of code segments includes a specific code segment corresponding to each of the primary nodes, and one or more candidate code segments corresponding to each of the secondary nodes; when any of the secondary nodes corresponds to multiple candidate code segments, code execution module 820 is configured to:
acquiring a current application scene of the target service flow; the current application scenario depends on one or more of the following parameters: service deployment information, partner information and service types; determining a target code segment corresponding to the current application scene from the candidate code segments according to a pre-stored corresponding relation table between different application scenes and different target code segments; executing the specific code segment according to the annotation information associated with the specific code segment, and executing the target code segment according to the annotation information associated with the target code segment to implement the target business flow.
In an exemplary embodiment of the disclosure, the code execution module 820 is configured to:
and determining a target code segment meeting the first query condition from the candidate code segments according to the corresponding relation table by taking the service deployment information, the partner information and the service type as the first query condition.
In an exemplary embodiment of the disclosure, the code execution module 820 is configured to:
if the target code segment meeting the first query condition is not queried, taking the service deployment information and the partner information as a second query condition; and determining a target code segment meeting the second query condition from the candidate code segments according to the corresponding relation table.
In an exemplary embodiment of the disclosure, the code execution module 820 is configured to:
if the target code segment meeting the second query condition is not queried, taking the service deployment information as a third query condition; and determining a target code segment meeting the third query condition from the candidate code segments according to the corresponding relation table.
In an exemplary embodiment of the disclosure, the code execution module 820 is configured to:
and if the target code segment meeting the third query condition is not queried, determining a pre-specified candidate code segment as the target code segment.
In an exemplary embodiment of the disclosure, the code execution module 820 is configured to:
scanning a preset storage path based on a java reflection mechanism to obtain the annotation information associated with each code segment; the preset storage path is used for storing the annotation information; and loading the annotation information obtained by scanning into a memory.
The specific details of each module in the above annotation-based service flow implementation apparatus have been described in detail in the corresponding annotation-based service flow implementation method, and therefore are not described herein again.
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit, according to embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
Moreover, although the steps of the methods of the present disclosure are depicted in the drawings in a particular order, this does not require or imply that the steps must be performed in this particular order, or that all of the depicted steps must be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step execution, and/or one step broken down into multiple step executions, etc.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which may be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
The present application also provides a computer-readable storage medium, which may be contained in the electronic device described in the above embodiments; or may exist separately without being assembled into the electronic device.
A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable storage medium may transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable storage medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The computer readable storage medium carries one or more programs which, when executed by an electronic device, cause the electronic device to implement the method as described in the above embodiments.
In addition, the embodiment of the disclosure also provides electronic equipment capable of realizing the method.
As will be appreciated by one skilled in the art, aspects of the present disclosure may be embodied as a system, method or program product. Accordingly, various aspects of the present disclosure may be embodied in the form of: an entirely hardware embodiment, an entirely software embodiment (including firmware, microcode, etc.) or an embodiment combining hardware and software aspects that may all generally be referred to herein as a "circuit," module "or" system.
An electronic device 900 according to this embodiment of the disclosure is described below with reference to fig. 9. The electronic device 900 shown in fig. 9 is only an example and should not bring any limitations to the functionality or scope of use of the embodiments of the present disclosure.
As shown in fig. 9, the electronic device 900 is embodied in the form of a general purpose computing device. Components of electronic device 900 may include, but are not limited to: the at least one processing unit 910, the at least one storage unit 920, a bus 930 connecting different system components (including the storage unit 920 and the processing unit 910), and a display unit 940.
Wherein the storage unit stores program code that is executable by the processing unit 910 to cause the processing unit 910 to perform steps according to various exemplary embodiments of the present disclosure described in the above section "exemplary method" of the present specification. For example, the processing unit 910 may perform the following as shown in fig. 1: step S110, after the business flow framework is started, loading a plurality of code segments for realizing the target business flow and annotation information associated with each code segment; the target service flow comprises a plurality of service nodes, and a preset incidence relation exists between the plurality of code segments and the plurality of service nodes; the annotation information is at least used for marking the execution sequence of each code segment; step S120, executing the plurality of code segments according to the annotation information to implement the target service flow.
The storage unit 920 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM)9201 and/or a cache memory unit 9202, and may further include a read only memory unit (ROM) 9203.
Storage unit 920 may also include a program/utility 9204 having a set (at least one) of program modules 9205, such program modules 9205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may comprise an implementation of a network environment.
Bus 930 can be any of several types of bus structures including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
The electronic device 900 may also communicate with one or more external devices 1000 (e.g., keyboard, pointing device, bluetooth device, etc.), with one or more devices that enable a user to interact with the electronic device 900, and/or with any devices (e.g., router, modem, etc.) that enable the electronic device 900 to communicate with one or more other computing devices. Such communication may occur via input/output (I/O) interface 950. Also, the electronic device 900 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet) via the network adapter 960. As shown, the network adapter 960 communicates with the other modules of the electronic device 900 via the bus 930. It should be appreciated that although not shown, other hardware and/or software modules may be used in conjunction with the electronic device 900, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.

Claims (11)

1. An annotation-based service flow implementation method is characterized by comprising the following steps:
after a business flow framework is started, loading a plurality of code segments for realizing a target business flow and annotation information associated with each code segment; the target service flow comprises a plurality of service nodes, and a preset incidence relation exists between the plurality of code segments and the plurality of service nodes; the annotation information is at least used for marking the execution sequence of each code segment;
and executing the code segments according to the annotation information to realize the target business flow.
2. The method according to claim 1, wherein the service nodes include at least a primary node and a secondary node, and the primary node corresponds to a processing stage included in the target service flow; the secondary node corresponds to the processing steps included in each of the processing stages.
3. The method of claim 2, wherein the plurality of code sections comprises a specific code section corresponding to each of the primary nodes and one or more candidate code sections corresponding to each of the secondary nodes;
when any of the secondary nodes corresponds to a plurality of candidate code segments, executing the plurality of code segments according to the annotation information to realize the target business flow, comprising:
acquiring a current application scene of the target service flow; the current application scenario depends on one or more of the following parameters: service deployment information, partner information, and service type;
determining a target code segment corresponding to the current application scene from the candidate code segments according to a pre-stored corresponding relation table between different application scenes and different target code segments;
executing the specific code segment according to the annotation information associated with the specific code segment, and executing the target code segment according to the annotation information associated with the target code segment to implement the target business flow.
4. The method according to claim 3, wherein the determining a target code segment corresponding to the current application scenario from the plurality of candidate code segments according to a pre-stored correspondence between different application scenarios and different target code segments comprises:
and determining a target code segment meeting the first query condition from the candidate code segments according to the corresponding relation table by taking the service deployment information, the partner information and the service type as the first query condition.
5. The method of claim 4, further comprising:
if the target code segment meeting the first query condition is not queried, taking the service deployment information and the partner information as a second query condition;
and determining a target code segment meeting the second query condition from the candidate code segments according to the corresponding relation table.
6. The method of claim 5, further comprising:
if the target code segment meeting the second query condition is not queried, taking the service deployment information as a third query condition;
and determining a target code segment meeting the third query condition from the candidate code segments according to the corresponding relation table.
7. The method of claim 6, further comprising:
and if the target code segment meeting the third query condition is not queried, determining a pre-specified candidate code segment as the target code segment.
8. The method of any of claims 1 to 7, wherein loading annotation information associated with each of the code segments comprises:
scanning a preset storage path based on a java reflection mechanism to obtain the annotation information associated with each code segment; the preset storage path is used for storing the annotation information;
and loading the annotation information obtained by scanning into a memory.
9. An annotation-based traffic flow implementation apparatus, comprising:
the information loading module is used for loading a plurality of code segments for realizing the target business flow and annotation information associated with each code segment after the business flow framework is started; the target service flow comprises a plurality of service nodes, and a preset incidence relation exists between the plurality of code segments and the plurality of service nodes; the annotation information is at least used for marking the execution sequence of each code segment;
and the code execution module is used for executing the code segments according to the annotation information so as to realize the target business flow.
10. A computer storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method of any of claims 1-8.
11. An electronic device, comprising:
a processor; and
a memory for storing executable instructions of the processor;
wherein the processor is configured to execute the method for implementing the annotation based service flow according to any one of claims 1 to 8 by executing the executable instruction.
CN202210314057.3A 2022-03-28 2022-03-28 Method and device for realizing service flow based on annotation, storage medium and electronic equipment Pending CN114647416A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210314057.3A CN114647416A (en) 2022-03-28 2022-03-28 Method and device for realizing service flow based on annotation, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210314057.3A CN114647416A (en) 2022-03-28 2022-03-28 Method and device for realizing service flow based on annotation, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN114647416A true CN114647416A (en) 2022-06-21

Family

ID=81995016

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210314057.3A Pending CN114647416A (en) 2022-03-28 2022-03-28 Method and device for realizing service flow based on annotation, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN114647416A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115268854A (en) * 2022-09-28 2022-11-01 深圳市明源云科技有限公司 Service expansion implementation method, system, electronic equipment and readable storage medium
CN115658018A (en) * 2022-10-20 2023-01-31 广东云徙智能科技有限公司 Method, system, device and medium for expanding middle station logic

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115268854A (en) * 2022-09-28 2022-11-01 深圳市明源云科技有限公司 Service expansion implementation method, system, electronic equipment and readable storage medium
CN115658018A (en) * 2022-10-20 2023-01-31 广东云徙智能科技有限公司 Method, system, device and medium for expanding middle station logic
CN115658018B (en) * 2022-10-20 2023-08-08 广东云徙智能科技有限公司 Middle-stage logic expansion method, system, device and medium

Similar Documents

Publication Publication Date Title
US10353796B2 (en) System and method for using development objectives to guide implementation of source code
US11481200B1 (en) Checking source code validity at time of code update
CN111949170B (en) Method and device for configuring task flow and electronic equipment
CN114647416A (en) Method and device for realizing service flow based on annotation, storage medium and electronic equipment
US20130042221A1 (en) System and method for automatic impact variable analysis and field expansion in mainframe systems
US11861469B2 (en) Code generation for Auto-AI
CN110058861B (en) Source code processing method and device, storage medium and electronic equipment
CN111198868A (en) Intelligent sub-database real-time data migration method and device
CN111338925A (en) Applet test method, device and system, electronic equipment and storage medium
CN113296786A (en) Data processing method and device, electronic equipment and storage medium
US10268461B2 (en) Global data flow optimization for machine learning programs
CN113377342B (en) Project construction method and device, electronic equipment and storage medium
US11262986B2 (en) Automatic software generation for computer systems
US20150095094A1 (en) Node-pair process scope definition adaptation
CN104951290A (en) Method and equipment for optimizing software
US20090064092A1 (en) Visual programming language optimization
US11182272B2 (en) Application state monitoring
US20230113783A1 (en) Cross-platform code conversion method and device
US11947966B2 (en) Identifying computer instructions enclosed by macros and conflicting macros at build time
CN114174983B (en) Method and system for optimized automatic verification of advanced constructs
US20210247997A1 (en) Method for data center storage evaluation framework simulation
KR102046622B1 (en) Software service system based on workflow and computer program that performs each step of the system
Hao et al. Torchbench: Benchmarking pytorch with high api surface coverage
US20120330878A1 (en) Conventions for inferring data models
US11847118B1 (en) Query set optimization in a data analytics pipeline

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination