# Registering Nginx callback in external library

**URL:** <https://www.ruby-forum.com/t/registering-nginx-callback-in-external-library/219044>\
**Category:** NGINX\
**Created:** [April 19, 2012, 10:40am UTC](https://www.ruby-forum.com/t/registering-nginx-callback-in-external-library/219044 "2012-04-19T10:40:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [April 19, 2012, 10:40am UTC](https://www.ruby-forum.com/t/registering-nginx-callback-in-external-library/219044/1 "2012-04-19T10:40:18Z")

</div>

Hi All,

Here’s what I wanted to do:

1. I wanted to write a Nginx location handler for example “/mylocation”  
which when invoked should call another program to get the response.

2. The other external program provides a client library where we can  
register callbacks.

3. The external program will call the callback when the data is  
available.

I wanted to know if I am using an external library and one of the  
external  
API is asking for registering callback, how i can achieve this in Nginx.

I cannot give any function from my handler, as that is called internally  
by  
the nginx Core.

Please guide me how I can register a callback inside Nginx which will be  
called by the external program.

Thanks,

Raul.

---

<div class="post-metadata">

**Author:** ![Sammy\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ac91a4/32.png) [@Sammy\_R](https://www.ruby-forum.com/u/Sammy_R)\
**Post date:** [April 20, 2012, 2:12am UTC](https://www.ruby-forum.com/t/registering-nginx-callback-in-external-library/219044/2 "2012-04-20T02:12:05Z")

</div>

Anything on this guys.

Raul

–  
View this message in context:  
[http://nginx.2469901.n2.nabble.com/Registering-Nginx-callback-in-external-library-tp7479794p7482648.html](http://nginx.2469901.n2.nabble.com/Registering-Nginx-callback-in-external-library-tp7479794p7482648.html)  
Sent from the nginx mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Sammy\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ac91a4/32.png) [@Sammy\_R](https://www.ruby-forum.com/u/Sammy_R)\
**Post date:** [April 20, 2012, 9:22am UTC](https://www.ruby-forum.com/t/registering-nginx-callback-in-external-library/219044/3 "2012-04-20T09:22:31Z")

</div>

On Thu, Apr 19, 2012 at 4:39 PM, Sammy R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I wanted to know if I am using an external library and one of the external  
> API is asking for registering callback, how i can achieve this in Nginx.

Take a look at the ngx\_drizzle module which integrates the external  
client library libdrizzle into the Nginx core and generates outputs  
for an nginx location:

```
http://wiki.nginx.org/HttpDrizzleModule

```

Also take a look at the ngx\_postgres module which integrates external  
client library libpq into the Nginx core:

```
https://github.com/FRiCKLE/ngx_postgres

```

Hope this helps,  
-agentzh

---

<div class="post-metadata">

**Author:** ![Sammy\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ac91a4/32.png) [@Sammy\_R](https://www.ruby-forum.com/u/Sammy_R)\
**Post date:** [April 23, 2012, 6:26am UTC](https://www.ruby-forum.com/t/registering-nginx-callback-in-external-library/219044/4 "2012-04-23T06:26:58Z")

</div>

Hi,

Thanks for your pointers, but one thing I still not understood from the  
links you have provided is that how I can register a callback in my  
handler  
which will be called by the external library.

In the links you have provided the read write event handler is called  
when  
any read write happens on the DB. But my case it’s the external program  
who  
will call the Nginx callback.  
So I am not sure how I can pass a callback from Nginx to external  
library  
API.

Please tell me what I can do in this scenario.

Thanks,  
Raul.

–  
View this message in context:  
[http://nginx.2469901.n2.nabble.com/Registering-Nginx-callback-in-external-library-tp7479794p7490644.html](http://nginx.2469901.n2.nabble.com/Registering-Nginx-callback-in-external-library-tp7479794p7490644.html)  
Sent from the nginx mailing list archive at [Nabble.com](http://Nabble.com).
