Thread: [Cppcms-users] non-greedy moint points
Brought to you by:
artyom-beilis
|
From: Marcel H. <ke...@co...> - 2013-07-14 22:17:03
Attachments:
signature.asc
|
Hi everybody,
now my seconds problem :/
I have a json rpc server running a async app via an intrusive ptr.
Also I'd like to have a sync app that will serve my "static" HTML-pages.
The current setup is
> booster::intrusive_ptr<WebAPI> bgworker(new WebAPI(srv));
>
> srv.applications_pool().mount(bgworker,
> cppcms::mount_point("/webapi(/(.*))", 1));
> srv.applications_pool().mount(cppcms::applications_factory<Dispatcher>(),
> cppcms::mount_point("/index(/(.*))", 1));
But this is not what I want. I want to provide all rpc calls under the
webapi domain and everything else under /, so nothing more.
Now I have to write /index/edit, instead of /edit -> that's annoying.
Any help?
|
|
From: Petr J. <ele...@ex...> - 2013-07-14 22:43:59
Attachments:
signature.asc
|
Do you really need an asynchronous application? Does WebAPI deviate from
the normal working scenario of request -> response ?
I'm trying to understand your problem.
On 15/07/2013 8:16 AM, Marcel Hellwig wrote:
> Hi everybody,
>
> now my seconds problem :/
> I have a json rpc server running a async app via an intrusive ptr.
> Also I'd like to have a sync app that will serve my "static" HTML-pages.
>
> The current setup is
>
>> booster::intrusive_ptr<WebAPI> bgworker(new WebAPI(srv));
>>
>> srv.applications_pool().mount(bgworker,
>> cppcms::mount_point("/webapi(/(.*))", 1));
>> srv.applications_pool().mount(cppcms::applications_factory<Dispatcher>(),
>> cppcms::mount_point("/index(/(.*))", 1));
> But this is not what I want. I want to provide all rpc calls under the
> webapi domain and everything else under /, so nothing more.
> Now I have to write /index/edit, instead of /edit -> that's annoying.
>
> Any help?
>
>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>
>
>
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
--
Please use PGP to encrypt your email to ensure our privacy is respected.
|
|
From: Marcel H. <ke...@co...> - 2013-07-14 22:59:00
Attachments:
signature.asc
|
On 15.07.2013 00:43, Petr Janda wrote: > Do you really need an asynchronous application? I WANT an rpc server in background ;) > Does WebAPI deviate from > the normal working scenario of request -> response ? > > I'm trying to understand your problem. > webAPI is a class, derived from cppcms::rpc::json_rpc_server, as mentioned before. There is no problem running both, sync and async apps, afaik, but my problem is the mount_point. In dispatching the order of "attach" is relevant, that means /webapi before / is legal and webapi will be called, mounts in appliation_pool does not follow this rule :/ |
|
From: Petr J. <ele...@ex...> - 2013-07-14 23:15:30
Attachments:
signature.asc
|
Your mountpoints seem to be an issue because you are creating 2 separate
applications that have no common parent.
I explained to you that you need to rethink your application design so
that sub applications (your Index and your WebAPI) have a common parent.
Mounts in application_pool follow the same rule. you need to write your
regular expressions properly.
Theres no reason why something like this should not work:
MyMainApp constructor:
attach(new WebAPI(srv), "webapi", "/webapi{1}", "^/webapi(/(.*))?$", 1);
attach(new Index(srv), "index", "/index{1}", "^/(.*)?$", 1);
On 15/07/2013 8:58 AM, Marcel Hellwig wrote:
> On 15.07.2013 00:43, Petr Janda wrote:
>> Do you really need an asynchronous application?
> I WANT an rpc server in background ;)
>> Does WebAPI deviate from
>> the normal working scenario of request -> response ?
>>
>> I'm trying to understand your problem.
>>
> webAPI is a class, derived from cppcms::rpc::json_rpc_server, as
> mentioned before.
> There is no problem running both, sync and async apps, afaik, but my
> problem is the mount_point. In dispatching the order of "attach" is
> relevant, that means /webapi before / is legal and webapi will be
> called, mounts in appliation_pool does not follow this rule :/
>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>
>
>
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
--
Please use PGP to encrypt your email to ensure our privacy is respected.
|
|
From: Petr J. <ele...@ex...> - 2013-07-14 23:24:24
Attachments:
signature.asc
|
What is your specific reason to run RPC server as an async app? > > On 15/07/2013 8:58 AM, Marcel Hellwig wrote: >> On 15.07.2013 00:43, Petr Janda wrote: >>> Do you really need an asynchronous application? >> I WANT an rpc server in background ;) >>> Does WebAPI deviate from >>> the normal working scenario of request -> response ? >>> >>> I'm trying to understand your problem. >>> >> webAPI is a class, derived from cppcms::rpc::json_rpc_server, as >> mentioned before. >> There is no problem running both, sync and async apps, afaik, but my >> problem is the mount_point. In dispatching the order of "attach" is >> relevant, that means /webapi before / is legal and webapi will be >> called, mounts in appliation_pool does not follow this rule :/ >> >> >> >> ------------------------------------------------------------------------------ >> See everything from the browser to the database with AppDynamics >> Get end-to-end visibility with application monitoring from AppDynamics >> Isolate bottlenecks and diagnose root cause in seconds. >> Start your free trial of AppDynamics Pro today! >> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk >> >> >> >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> > > > > > ------------------------------------------------------------------------------ > See everything from the browser to the database with AppDynamics > Get end-to-end visibility with application monitoring from AppDynamics > Isolate bottlenecks and diagnose root cause in seconds. > Start your free trial of AppDynamics Pro today! > http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk > > > > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > -- Please use PGP to encrypt your email to ensure our privacy is respected. |
|
From: Petr J. <ele...@ex...> - 2013-07-15 00:03:42
Attachments:
signature.asc
|
If you are dead-set on making WebAPI asynchronous, why not rewrite your
mapping like this:
booster::intrusive_ptr<WebAPI> bgworker(new WebAPI(srv));
srv.applications_pool().mount(bgworker,
cppcms::mount_point("/webapi(/(.*))", 1));
srv.applications_pool().mount(cppcms::applications_factory<Dispatcher>());
Specify your mapping for Dispatcher class in the constructor of
Dispatcher as:
mapper().root(settings().get<string>("myapp.root"));
dispatcher().assign("^/somefunction$", &Dispatcher::index, this);
mapper().assign("somefunction", "/somefunction")
dispatcher().assign("^(.*)$", &Dispatcher::index, this); //catch all regexp
mapper().assign("")
On 15/07/2013 9:24 AM, Petr Janda wrote:
> What is your specific reason to run RPC server as an async app?
>
>
>>
>> On 15/07/2013 8:58 AM, Marcel Hellwig wrote:
>>> On 15.07.2013 00:43, Petr Janda wrote:
>>>> Do you really need an asynchronous application?
>>> I WANT an rpc server in background ;)
>>>> Does WebAPI deviate from
>>>> the normal working scenario of request -> response ?
>>>>
>>>> I'm trying to understand your problem.
>>>>
>>> webAPI is a class, derived from cppcms::rpc::json_rpc_server, as
>>> mentioned before.
>>> There is no problem running both, sync and async apps, afaik, but my
>>> problem is the mount_point. In dispatching the order of "attach" is
>>> relevant, that means /webapi before / is legal and webapi will be
>>> called, mounts in appliation_pool does not follow this rule :/
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> See everything from the browser to the database with AppDynamics
>>> Get end-to-end visibility with application monitoring from AppDynamics
>>> Isolate bottlenecks and diagnose root cause in seconds.
>>> Start your free trial of AppDynamics Pro today!
>>> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>>>
>>>
>>>
>>> _______________________________________________
>>> Cppcms-users mailing list
>>> Cpp...@li...
>>> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>>>
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> See everything from the browser to the database with AppDynamics
>> Get end-to-end visibility with application monitoring from AppDynamics
>> Isolate bottlenecks and diagnose root cause in seconds.
>> Start your free trial of AppDynamics Pro today!
>> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>>
>>
>>
>> _______________________________________________
>> Cppcms-users mailing list
>> Cpp...@li...
>> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>>
>
>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>
>
>
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
--
Please use PGP to encrypt your email to ensure our privacy is respected.
|
|
From: Marcel H. <ke...@co...> - 2013-07-15 09:19:15
Attachments:
signature.asc
|
On 15.07.2013 02:03, Petr Janda wrote:
> If you are dead-set on making WebAPI asynchronous, why not rewrite your
> mapping like this:
>
>
> booster::intrusive_ptr<WebAPI> bgworker(new WebAPI(srv));
>
> srv.applications_pool().mount(bgworker,
> cppcms::mount_point("/webapi(/(.*))", 1));
> srv.applications_pool().mount(cppcms::applications_factory<Dispatcher>());
This is how I do it, expect that you don't create a specific mount point
for the dispatcher. I tried it, no luck :/
> Specify your mapping for Dispatcher class in the constructor of
> Dispatcher as:
>
> mapper().root(settings().get<string>("myapp.root"));
>
> dispatcher().assign("^/somefunction$", &Dispatcher::index, this);
> mapper().assign("somefunction", "/somefunction")
>
> dispatcher().assign("^(.*)$", &Dispatcher::index, this); //catch all regexp
>
> mapper().assign("")
The only difference is, that you do mapper.assign(""), the rest is still
the same.
> What is your specific reason to run RPC server as an async app?
Async is "better" than sync, because it does not run in the main loop
and therefore can handle more connections.
http://cppcms.com/wikipp/en/page/cppcms_1x_application_lifetime
http://permalink.gmane.org/gmane.comp.lib.cppcms.user/580
> attach(new WebAPI(srv), "webapi", "/webapi{1}", "^/webapi(/(.*))?$", 1);
> attach(new Index(srv), "index", "/index{1}", "^/(.*)?$", 1);
Here you mount WebAPI as sync app, that's not what I want. :/
|
|
From: Petr J. <ele...@ex...> - 2013-07-15 13:36:31
Attachments:
signature.asc
|
> This is how I do it, expect that you don't create a specific mount point > for the dispatcher. I tried it, no luck :/ Then Artyom should explain why matching ^webapi$ and "^index$" works, but ^webapi$ and ^(.*)$ doesn't. Logically, the regular expression defined first should be the one evaluated first. > Async is "better" than sync, because it does not run in the main loop > and therefore can handle more connections. I'm curious now, because synchronous application should have a higher performance than asynchronous. Synchronous application is designed to utilize multiple CPUs/cores in a non-blocking way. The 2nd link even recommends to dispatch any having lifting from an async app to a sync app. So it boils down to this - if you need long polling or process any server-side events, use an async app. I don't know what exactly your WebAPI does, but by the sounds of it, most of the work should be done synchronously. Generally APIs are synchronous (request->response cycle) but yours may be different. |
|
From: Artyom B. <art...@ya...> - 2013-07-15 10:19:40
|
You can use nagative look-around http://stackoverflow.com/questions/406230/regular-expression-to-match-string-not-containing-a-word Something like that cppcms::mount_point("/webapi(/(.*))", 1) cppcms::mount_point("^(?!/webapi)(/(.*))", 1) Not sure about exact syntax but the general idea should be clear, the second mount point should match all but /webapi Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >________________________________ > From: Marcel Hellwig <ke...@co...> >To: cpp...@li... >Sent: Monday, July 15, 2013 1:16 AM >Subject: [Cppcms-users] non-greedy moint points > > >Hi everybody, > >now my seconds problem :/ >I have a json rpc server running a async app via an intrusive ptr. >Also I'd like to have a sync app that will serve my "static" HTML-pages. > >The current setup is > >> booster::intrusive_ptr<WebAPI> bgworker(new WebAPI(srv)); >> >> srv.applications_pool().mount(bgworker, >> cppcms::mount_point("/webapi(/(.*))", 1)); >> srv.applications_pool().mount(cppcms::applications_factory<Dispatcher>(), >> cppcms::mount_point("/index(/(.*))", 1)); >But this is not what I want. I want to provide all rpc calls under the >webapi domain and everything else under /, so nothing more. >Now I have to write /index/edit, instead of /edit -> that's annoying. > >Any help? > > >------------------------------------------------------------------------------ >See everything from the browser to the database with AppDynamics >Get end-to-end visibility with application monitoring from AppDynamics >Isolate bottlenecks and diagnose root cause in seconds. >Start your free trial of AppDynamics Pro today! >http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |
|
From: Marcel H. <ke...@co...> - 2013-07-15 10:33:21
Attachments:
signature.asc
|
On 15.07.2013 12:19, Artyom Beilis wrote: > You can use nagative look-around > > http://stackoverflow.com/questions/406230/regular-expression-to-match-string-not-containing-a-word > > Something like that > > > cppcms::mount_point("/webapi(/(.*))", 1) > cppcms::mount_point("^(?!/webapi)(/(.*))", 1) > > Not sure about exact syntax but the general idea should be clear, the > second mount point should match all but /webapi Awesome. Never hear of negative look-around regex. It works, thank you. And also thank you Petr, you made me thinking ;) > > Artyom Beilis > -------------- > CppCMS - C++ Web Framework: http://cppcms.com/ > CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ |