Welcome! Log In Create A New Profile

Advanced

Breaking content generation phase into multiple phases or adding custom events in content phase

Kaustubh Deorukhkar
June 17, 2015 02:18PM
Hi,

I am working on a custom module where I need to use a third party library
and make sync/async calls to APIs. I do not have control over what the
library does internally but any async API call on library would call a
callback which indicates that content generation phase continue with
forming response and sending it back to client.

Here is psuedo code:
- content_handler_called
-- some_initializations
-- Call library Async API with callback
-- nginx should continue processing other events
...
-- some point of time the callback is triggered, which should resume the
request say by raising a custom event in nginx event loop so nginx can
process remaining part of request.

As i understand nginx works primarily on events based on sockets but in
this case invocation of this library api cannot generate any socket events.

Question is how do I pause the current request processing so nginx can
continue with other requests and when api callback is trigger, nginx should
be able to resume the request processing.

Looking at some other modules I found
1> mysql module intercepts the socket calls of libmysqlclient
2> we can use additional socket to communicate between API callback and
nginx event loop.
3> I believe openresty lua module should be achieving similar async
behavior for content handler phase.

1 is not possible, 2 is a bit bad due to additional sockets. Anyone can
throw some light how openresty lua module achieves this?

We want to avoid upstream server model if this is already possible with
nginx.

Is there some mechanism to trigger custom events.
Is the nginx event loop thread safe if we have some mechanism to trigger
custom events?

Hoping for inputs. Thanks in advance!!
Kaustubh
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Breaking content generation phase into multiple phases or adding custom events in content phase

Kaustubh Deorukhkar 744 June 17, 2015 02:18PM

Re: Breaking content generation phase into multiple phases or adding custom events in content phase

Yichun Zhang (agentzh) 354 June 17, 2015 11:28PM

Re: Breaking content generation phase into multiple phases or adding custom events in content phase

Jeff Kaufman 610 June 18, 2015 07:08AM

Re: Breaking content generation phase into multiple phases or adding custom events in content phase

Yichun Zhang (agentzh) 340 June 18, 2015 11:08PM

Re: Breaking content generation phase into multiple phases or adding custom events in content phase

Jeff Kaufman 384 June 19, 2015 08:36AM

Re: Re: Breaking content generation phase into multiple phases or adding custom events in content phase

kaustubh 461 June 24, 2015 12:02AM

Re: Breaking content generation phase into multiple phases or adding custom events in content phase

kaustubh 443 June 22, 2015 02:20AM

Re: Breaking content generation phase into multiple phases or adding custom events in content phase

Jeff Kaufman 386 June 23, 2015 05:58AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 200
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready