g-wan

How to write complex application to be used under G-WAN


I want to know the good practices when developing applications utilizing GWAN.

I have starter small app (but crucial part of big project) which will be utilizing C++ OOP. At least that means I have classes to get initialized on HTTP requests.

How I am supposed to structure the sources in order to use them in effective and practical manner while developing for GWAN? Do I have to develop the application separately and link it like a shared/static library? Or can I include them and GWAN do the build as it's doing for the scripts in the CSP folder? I found that if I put them in the CSP folder the result is failure to startup the server as it fails with error for missing main function in the cpp files which are holding classes implementations. Because of this I accepted that putting sources in CSP is not the way to do the work and there should only be initial script which will route all requests to the application.

Another thing which is related is that I am struggling to find out practical working environment to allow me to build and test faster in the case I'd have to build a library to be utilized trough CSP. Maybe I will create a way to test the app separately, however testing fast in GWAN environment is a non-visible solution for me at this time, which I believe is there.

The deployment of updated version of the APP under GWAN should happens as easy and fast as possible - what is the way? I do know that this question will likely clear by acknowledging answers to the above but let me leave it just in case I am very wrong with my current understandings on this whole topic.


Solution

  • The /csp directory should only contain entry point servlets - that is, a source code file with a main() that can be invoked by a remote client.

    You can have functions (called from several servlets) in source code form (or in compiled form) placed in the /includes (.h) and /libraries directories (.c, *.obj, *.a, *.lib).

    Quick development and testing can be done with a servlet used to test your code until it is mature enough to be stored in /includes or /libraries.

    For huge projects, it makes a lot of sense to use pre-compiled libraries as this will speed-up on-the-fly servlet compilation (as compared to a large collection of include files).

    Last but not least, G-WAN being designed for lean coding, C++ might not be as optimal as plain C for this purpose - just think of the hidden cost of constructors, their order, their sometimes redundant actions, hidden memory allocations, etc. - on the top of the huge C++ runtime overhead, high compilation times, blackbox standard libraries, etc.

    At TWD, for Global-WAN (relying on G-WAN), we have spent quite a lot of time at rewritting C++ (non-standard) libraries in plain C, with very tangible gains in terms of performance, bug and deadlock cleanup, and memory usage.

    What you don't see might hurt - and hurt badly because, well, you don't see it until it's too late.

    Hope this helps.