Service end application system development framework and operation method thereof
Technical field
The application relates to internet application development technique field, more specifically, relates to a kind of service end application system development framework and operation method thereof.
Background technology
In current various http engines, nginx http engine, adopts asynchronous network model and multi-process framework, is applicable to the work such as http protocol conversion of stateless HTTP service, static content HTTP server, agency and reverse proxy, particular protocol.Nginx, because its asynchronous network model used and multi-process progress of work model, is applicable to client http access service in enormous quantities.The multi-process model of nginx, simply says, be by multiple homogeneity worker process service processing client-requested, each worker process IO Network Based event accepts the request of multiple client asynchronously.It is based on its functional unit of modular organisation, and service end developer can combinationally use the HTTP service that these modular functions build particular demands.Developer can based on the modular frame design of its software, and programming development expansion module, meets specific demand, forms specific HTTP service end.
Apache httpd then can adopt multi-process model, also can use multithreading model.Use block type network model: namely certain progress of work or thread are during serving certain client, can not serve other clients, must wait for that the service processing of active client completes the request just serving next client.It is also modular organization basic functional components, and service end developer these modules of flexible combination can complete some specific HTTP access demands.Developer equally also can carry out module expansion.
The maximum difference of these two kinds of http engines is the difference of process and the network model used, and cause its expansion module development mode to have a great difference, the scope of application is also not quite similar.
Http engine uses CGI (Common Gateway Interface) to obtain dynamic generating content from external program, also can form the particular service system of specific HTTP access with CGI.Such as, nginx coordinates php-fpm fastcgi service, by service logic trustship in php shell script.
But, also there is himself drawback in above-mentioned various technology, in the constraint of http engine modules extended method itself, it requires that service developer knows the modular method of the HTTP engine that he relies on, and has the cognition of comparatively system to the software architecture of these HTTP engines and operating mechanism.Such as nginx, software configuration, operating mechanism, the process model adopted, the network model of apache httpd etc., have bigger difference, these driving models of serving consequent software view limit the pattern of Development of Modular can only specific to affiliated engine.Meanwhile, the modularization extended mode that these HTTP serve has the flow process of comparatively machinery and comparatively fixing restriction.Developer can increase constraint further, make these flow processs and restriction can clearly, stablize, thus make these flow processs can automation, but, the ability of the strain variation of these automation processes own is very weak, comprise the ability of strain bottom HTTP engine change, and the ability of strain upper-layer service specific demand.In addition, the modular method of these HTTP engines, generally all needs specific compiling, deploying step, the tools chain that these steps rely on, and is generally all consistent with http engine, and developer needs the constraint accepting these tools chain passively.Further, specifically in each link, also can increase the constraint of some fixing details rules, developer can only learn these rules by heart to avert failure.The compiling building process of these module extended methods, or depend on the compiling building process of http engine, or some component software provided engine when compiling builds has strong dependence (when the apr that such as apache httpd provides runs tool storage room).
In the On The Standardization of http engine business development process, common HTTP engine solves the problem of HTTP request access, and the processing logic of request then gives developer completely.Usually, access third party's service (such as other operation systems) may be needed during request process, or access a certain class data engine (such as caching system, relational database, key-value data engine etc.), and access these remote systems, generally need to introduce third party's interface, or HTTP engine itself only provides the remote access means of less type.Because the introducing of these third party's interfaces, adds burden to software maintenance.But the driving model of HTTP engine, determines some third party's interface inapplicable.Such as, the driving model based on event of nginx, makes third party's interface of block type access remote system inapplicable, because obviously can reduce the throughput of single example nginx; Even there is the interface based on event style, is embedded in the circulation of nginx event-driven and also there is larger difficulty.In addition, the exploitation custom of developer, development mode are not quite similar.Due to the common superposition of as above factor, cause the specification that these achievements are ununified, the scope of application is little, and durability is poor, and maintenance cost is high, can only be used for building some simple network services.
And in efficiency, owing to being confined to operating mechanism and some Design and implementation details, there is certain obstacle in multipath concurrence accessing remote system on these HTTP engines.And the repeatedly remote system initiating not have in logic front and back dependence is serially mutual, the average response rate that the obvious reduction of meeting is served.In addition, the expansion module of CGI mode, can many data interactions between a http engine and cgi script.The cgi that great majority realize with explanation type dynamically typed language (such as perl/python/php etc.) performs entity, all has certain efficiency and loses.And because of these cgi programs be mostly multi-process block type service, concurrency and the throughput of service are limited to server resource.
In addition, for the public demands comprised in service logic, such as, the monitoring of business procession, automation daily record, some general checking class demand on business interface, these demands are general needs service developer to develop correlation function because of the existence of the demands such as the data analysis of the system-level monitoring of the overall situation, the system overall situation is excavated, the interface management of the overall situation.And these functions have certain versatility, need to encapsulate these general utility functionss, avoid repeated work, minimizing makes mistakes, and the unification keeping the entirety of the demand to export is controlled.
Therefore, need a kind of new service end application system development framework and operation method thereof to provide simpler module to expand, simplify the task of developer, specification development process promote whole efficiency.
Summary of the invention
In view of this, the application provides a kind of service end application system development framework and operation method thereof to solve the problem.
This application discloses a kind of service end application system development framework, it is characterized in that, comprise:
STUB module, corresponding request object is set up in the request according to client;
Middle layer frame, receives described request object, and each sequence of modules processes said request in the business module utilizing basic module chained list, described client in advance to expect and afterwards basic module chained list;
Basic module, comprise basic module and afterwards basic module in advance, wherein said basic module is in advance mainly used in the general procedure in advance to described request, and described basic module to be afterwards mainly used in described request processed and after generating process result, based on the general procedure afterwards of described result; And
Business module, for the described request of dispatch deal after the process of described basic module in advance according to described middle layer frame,
Wherein, described general procedure in advance comprises the access privilege control of described request, the parameter modification of described request and replaces described business module to process described request in advance; Described general procedure afterwards comprises general request statistics and the modification of result; And described STUB module more generates http response according to the described result of described request, and discharge described request object.
Preferably, wherein, described middle layer frame more comprises:
Module management, basic module chained list and the described chained list of basic module afterwards in advance described in holding, and each sequence of modules processes said request of execution cost.
Preferably, wherein, described module management more comprises:
Request process entrance, wherein said STUB module makes described request be performed by described request process entrance.
Preferably, wherein, son request can be created in certain module is to the processing procedure of described request, the remote service access of described son request general proxy, and after described son request all obtains process, described request can determine send other son requests or terminate the process in described module.
Preferably, wherein, described request object comprises the result of the required parameter of http session, the logic step of http Dialog processing and http session.
Preferably, wherein, described service end application system development framework is the http engine for nginx type, and supports the concurrence performance of multichannel request/son request.
Disclosed herein as well is a kind of operation method of service end application system development framework, it is characterized in that, comprise:
Utilize STUB module, corresponding request object is set up in the request according to client;
By request process entrance, described request object is transferred to middle layer frame;
The processes said request of basic module in advance in basic module chained list is in advance dispatched by the module management in described middle layer frame;
By the business module processes said request that described module management execution cost client is expected;
The processes said request of basic module afterwards in basic module chained list is afterwards dispatched by described administration module; And
Utilize described STUB module, the described result according to described request generates http response, and discharges described request object,
Wherein said basic module is in advance mainly used in the general procedure in advance to described request, and described general procedure in advance comprises the access privilege control of described request, the parameter modification of described request and replaces described business module to process described request in advance; After described basic module is afterwards mainly used in the processed also generating process result of described request, based on the general procedure afterwards of described result, described general procedure afterwards comprises general request statistics and the modification of result.
Preferably, wherein, son request can be created in certain module is to the processing procedure of described request, the remote service access of described son request general proxy, and after described son request all obtains process, described request can determine send other son requests or terminate the process in described module.
Preferably, wherein, described request object comprises the result of the required parameter of http session, the logic step of http Dialog processing and http session.
Preferably, wherein, described service end application system development framework is the http engine for nginx type, and supports the concurrence performance of multichannel request/son request.
Compared with prior art, the service end application system development framework described in the application and operation method thereof, reach following effect:
1) module expansion is more simple, and the very simple modularization constraint of a demand fulfillment middle layer frame gets final product expansion module.
2) by request object and the encapsulation of father and son's appealing structure of business procedure, specification development process.The process of business development is exactly the process creating these request objects.
3) dissimilar remote access demand is encapsulated as dissimilar request object, then that concrete remote access realizes details under encapsulation, be the part not needing service developer to be concerned about, developer only needs to pay close attention to these and encapsulates the unified interface provided, and simplifies the task of developer.
4) concurrence performance of sub-request object improves overall level of efficiency.
Certainly, the arbitrary product implementing the application might not need to reach above-described all technique effects simultaneously.
Accompanying drawing explanation
Accompanying drawing described herein is used to provide further understanding of the present application, and form a application's part, the schematic description and description of the application, for explaining the application, does not form the improper restriction to the application.In the accompanying drawings:
Fig. 1 is the block schematic diagram of the service end application system development framework according to the application one embodiment.
Fig. 2 is the schematic flow sheet of the operation method of the service end application system development framework of foundation the application one embodiment.
Fig. 3 is the schematic flow sheet of the process of basic module in advance according to the application one embodiment.
Fig. 4 is the schematic flow sheet of the business module process according to the application one embodiment.
Fig. 5 is the schematic flow sheet of the process of basic module afterwards according to the application one embodiment.
Embodiment
As employed some vocabulary to censure specific components in the middle of specification and claim.Those skilled in the art should understand, and hardware manufacturer may call same assembly with different noun.This specification and claims are not used as with the difference of title the mode distinguishing assembly, but are used as the criterion of differentiation with assembly difference functionally." comprising " as mentioned in the middle of specification and claim is in the whole text an open language, therefore should be construed to " comprise but be not limited to "." roughly " refer to that in receivable error range, those skilled in the art can solve the technical problem within the scope of certain error, reach described technique effect substantially.In addition, " couple " word and comprise directly any and indirectly electric property coupling means at this.Therefore, if describe a first device in literary composition to be coupled to one second device, then represent described first device and directly can be electrically coupled to described second device, or be indirectly electrically coupled to described second device by other devices or the means that couple.Specification subsequent descriptions is implement the better embodiment of the application, and right described description is for the purpose of the rule that the application is described, and is not used to the scope limiting the application.The protection range of the application is when being as the criterion depending on the claims person of defining.
Technical scheme in the embodiment of the present application has peeled off the details of http engine, comprises peeling off retraining in the details of http engine patrix blocking regarded as output controlling, also comprises and peels off http engine requests process type of drive details.This target is realized by the mode introducing middle layer frame.Service developer is not because directly in the face of the details of http engine, thus simple flow, make developer be absorbed in the realization of service logic.Carry out standardization in HTTP interface aspect, and adopt modular strategy management service logic.Service developer only needs the modularization constraint in the face of middle layer frame provides, and completes module regarded as output controlling compactly fast.In addition, middle layer frame provides the automatic administrative mechanism of dynamic business module during operation, reduces the difficulty that business module is disposed.The objectification of service logic process is encapsulated.The request of client, and in order to the subprocess (such as accessing third party's service or database) realizing this request is all with object encapsulation.Encapsulated by this objectification, specification also simplifies service logic development process.Middle layer frame is responsible for executable machine structure request object being converted to bottom http engine: the state and the State Transferring that 1, manage them; 2, the input of request and the conversion between result and bottom I/O data.Service developer only needs to create sub-request object, defines its input, the processing procedure of definition request response results, and at the end of the request all of definition, the processing procedure of father's request, and at the end of final whole service logic, the encapsulation of response message.Http engine is transformed, or develops additional modules for the concurrent mechanism of request actuator, support the concurrence performance of the sub-request object of multichannel.Modularized encapsulation is carried out to general administrative class demand.
Fig. 1 is the block schematic diagram of the service end application system development framework 100 according to the application one embodiment, and it comprises: http engine 101, STUB module 102, middle layer frame 103, basic module 104 and business module 105.Wherein, middle layer frame 103 comprises module management 1031 further, and module management 1031 has request process entrance 10311.Basic module 104 comprises basic module 1041 and afterwards basic module 1042 in advance.Introduce the effect of each several part shown in Fig. 1 below in detail:
In above-mentioned Development Framework 100, STUB module 102 and middle layer frame 103 form the main body of Development Framework jointly.Business module 105 and basic module 104 are modules of the modularization constraint expansion exploitation of based intermediate layer framework 103.Middle layer frame 103 manages upper-layer service module, holds request corresponding to operation flow and sub-request object example, and the state of maintenance request object, administer its state transition logic.Stub module 102 is expansion modules for bottom HTTP engine 101, the Flow driving source such as network I/O, timer of bottom engine is through STUB module 102, drive intermediate layer (middle layer frame 103) and operation layer logic (business module 105 and basic module 104), be also responsible for the conversion between request object in the intermediate layer actuator corresponding with HTTP engine 101.STUB module also expands the concurrence performance mechanism of sub-request object.And intermediate layer do not know the existence of bottom, intermediate layer provides driving interface, and STUB module 102 is called these and driven interface.This mode, makes intermediate layer thoroughly peel off and relies on the software of bottom engine.Basic module 104, also be the expansion module of intermediate layer management, but not serve a certain particular service, and be to provide basic general mechanism, statistic, response data modification etc. are called in such as, automation daily record after Business Processing completes, business interface, or user before Business Processing, Verification class, prevent the mechanism of malicious attack class, be encapsulated in basic module.That HTTP engine 101 adopts in the present embodiment is nginx.
In addition, module management 1031 is maincenters of middle layer frame 103, is module object manager, is also the scheduling maincenter of request process.Hold the example of each expansion module during operation, be responsible for their initialization and destruction.And make regular check on the configuration of module, if configuration changes, then reinitialize module newly to configure.Hold and realize module dynamic base handle, during startup, automatically load dynamic base.During operation, dynamic base reinitializes automatic loading not along with module.Reason: nginx adopts asynchronous network driving model, because the processing procedure function of request registration is present in module dynamic base, rashly reloads dynamic base, problem when can bring operation; And safe dynamic base heavy duty when running, will be accomplished, need to do dynamic base request reference count, before dynamic base heavy duty, the request newly entered all is hung up and is maintained one and hangs up chained list, be after 0 in module request reference count, reload dynamic base and perform the request hanging up chained list, this process sharply can increase the software complexity of framework.Module management 1031 holds a basic module chained list and one basic module chained list afterwards in advance, holds different business modules, is responsible for the sequential processes on business module, afterwards basic module chained list that dispatch request expects in module chain, client in advance.STUB module 102 makes to call request by the request process entrance 10311 of module management 1031 to be performed.
In the present embodiment, the concept of request object has been related to.In general, the http session that client is initiated and process thereof, comprise session results three part that required parameter that client provides, the logic step of Dialog processing and module provide, be encapsulated as object.The sub-step that request performs, usually, is some remote access sessions, is also encapsulated as request object.It comprises destination information, the session input parameter of the remote session that module provides, and the processing procedure after remote session response arrival.In addition, son request also can have son request.Main request by after multiple basic module process, by a business module process, then through the process of multiple basic module afterwards.Note that above-mentioned request type can be expanded.And STUB module 102 creates request actuator corresponding to bottom for request object, and be responsible for the concurrence performance mechanism of these actuators, also the state of actuator can be conducted to request object, and be the result data of request object the output data transformations of actuator.
Fig. 2 is the schematic flow sheet of the operation method 200 of the service end application system development framework of foundation the application one embodiment, and it can be applicable to the service end application system development framework 100 shown in Fig. 1.Described method 200 comprises:
Step S201: utilize STUB module 102, corresponding request object is set up in the request according to client;
Step S202: described request object is transferred to middle layer frame 103 by request process entrance;
Step S203: dispatch basic module in advance 1041 processes said request in basic module chained list in advance by the module management 1031 in described middle layer frame 103;
Step S204: business module process 105 described request expected by described module management 1031 execution cost client;
Step S205: dispatch basic module afterwards 1042 processes said request in basic module chained list afterwards by described administration module 1031;
Step S206: utilize described STUB module 102, the result according to described request generates http response, and discharges described request object.
Please refer to Fig. 3, Fig. 3 is the schematic flow sheet of the process of basic module in advance according to the application one embodiment.After client-requested arrives, STUB module sets up the request object of its correspondence, and gives intermediate layer (middle layer frame 103 such as, in Fig. 1) process.Intermediate layer processes each module that request order is given on basic module chained list in advance to request.Basic module is mainly used in the general procedure in advance to request in advance; the access privilege control of such as described request; or required parameter is modified; or replace business module to process etc. described request in advance; it is also applicable to the encapsulation of some general safety protecting mechanisms and other demands; such as, the service protection of IP-based blacklist/white list.With IP black and white lists filtering module (IP_Filter) as an example, the handling process of certain module to request is described:
In the request process entrance function of IP_Filter module, extract the original ip address of request, create the sub-request of access far-end IP filtering services, required parameter is this IP address, and arranges son request process call back function A.Arrange the call back function B of main request, the effect of call back function B is after sub-request terminates, to the judgement of asking to allow or refuse.Middle layer frame now holds main request, and the handle of the sub-request of IP_filter establishment; STUB module installs this son request (creating the actuator under corresponding HTTP engine); The IO process that HTTP engine is responsible for sending remote request, is received remote response; After response arrives, STUB module calls the process call back function A of son request, and this function is converted to the IP filter result of our needs original response data.
Intermediate layer is now known does not have other son requests, and call the call back function B of main request, call back function B checks IP filter result, if IP belongs to white list, or IP is not in blacklist, so allows request to continue to perform, if IP is in blacklist, then refuse the execution of asking.The control option of refusal is seen in intermediate layer, at once ending request, generates the response of client.
If request is not rejected, if also have other basic module existence in advance, give subsequent module for processing request, otherwise process asking to give real business module.Each basic module performs according to following steps herein:
1st step: ask by the process of module inlet function, wherein may set up son request;
2nd step: if there is son request, son request is mounted and performs;
3rd step: at the end of son request, call the readjustment of son request;
4th step: if all son requests all terminate, call the readjustment of father's request;
5th step: still likely increase new sub-request in son request, father's request callback, if having newly-increased, gets back to the 2nd step and continues to perform in order;
6th step: all terminate in all son requests, and the not newly-increased son request again of father's request callback, request processing flow terminates in this module, enters the process of next module.
Note that request processing procedure in, every other module, comprises business module and basic module, to request driving process and above-mentioned basic module in advance basically identical.
Please refer to Fig. 4, Fig. 4 is the schematic flow sheet of the business module process according to the application one embodiment.Contain business module label information in the URI of each client-requested, there is no unaccepted request through basic business module in advance, can give the business module of specifying process.Because the handling process of business module is with basic module handling process is similar in advance, is easy period, does not separately repeat herein.
Please refer to Fig. 5, Fig. 5 is the schematic flow sheet of the process of basic module afterwards according to the application one embodiment.Request, after business module is disposed, can be given business module chain afterwards and be processed.Described basic module is afterwards mainly used in after the processed also generating process result of described request, based on the general procedure afterwards of result, the such as modification etc. of some general request statistics, result, main effect is the automatic daily record meeting the request of injection, the demand that the state statistical information of request etc. are general.Because the handling process of basic module is afterwards with basic module handling process is similar in advance, is easy period, does not separately repeat herein.
Isolate the middle layer frame scheme of bottom HTTP engine implementation details in above-described embodiment of the application, comprise the design of software static structure, and the special consideration of type of drive: called by STUB module and drive intermediate layer, intermediate layer drives upper strata again.Make each layer all can keep, under the prerequisite that driving interface is constant, doing flexible adjustment.Its feature comprises middle layer frame module management framework; The encapsulation of business procedure objectification and request object State Transferring flow process; And the modularized encapsulation of basal needs and handle before happening and the process chain management that afterwards processes.
Compared with prior art, the technical scheme of the application has the following advantages:
1) module expansion is more simple, and the very simple modularization constraint of a demand fulfillment middle layer frame gets final product expansion module.
2) by request object and the encapsulation of father and son's appealing structure of business procedure, specification development process.The process of business development is exactly the process creating these request objects.
3) dissimilar remote access demand is encapsulated as dissimilar request object, then that concrete remote access realizes details under encapsulation, be the part not needing service developer to be concerned about, developer only needs to pay close attention to these and encapsulates the unified interface provided, and simplifies the task of developer.
4) concurrence performance of sub-request object improves overall level of efficiency.
Also it should be noted that, term " comprises " or its any other variant is intended to contain comprising of nonexcludability, thus make to comprise the process of a series of key element, method, commodity or system and not only comprise those key elements, but also comprise other key elements clearly do not listed, or be also included as the intrinsic key element of this process, method, commodity or system.When not more restrictions, the key element limited by statement " comprising ... ", and be not precluded within process, method, commodity or the system comprising described key element and also there is other identical element.
It will be understood by those skilled in the art that the embodiment of the application can be provided as method, system or computer program.Therefore, the application can adopt the form of complete hardware embodiment, completely software implementation or the embodiment in conjunction with software and hardware aspect.And the application can adopt in one or more form wherein including the upper computer program implemented of computer-usable storage medium (including but not limited to magnetic disc store, CD-ROM, optical memory etc.) of computer usable program code.
The foregoing is only the embodiment of the application, be not limited to the application.To those skilled in the art, the application can have various modifications and variations.Any amendment done within all spirit in the application and principle, equivalent replacement, improvement etc., within the right that all should be included in the application.