Feedback on my module

Tarek Ziade tarek at mozilla.com
Fri Apr 1 20:29:07 MSD 2011


On 04/01/2011 04:44 PM, Umesh Sirsiwal wrote:
> Hey Tarek,
> You can use combination of nginx_memc 
> (http://wiki.nginx.org/HttpMemcModule) and nginx_lua 
> (https://github.com/chaoslawful/lua-nginx-module) to achieve the same 
> result.

Oh sweet, scripting sounds like a better approach, no need to recompile 
on every change. and Lua coroutines seem light & fast.

I'll give it a shot, thanks.

>
> Here is an example:
>
> |location /blah {
>          rewrite_by_lua '
> 	    if($http_x_target_service == nil) then
> 		return
> 	    end
> 	    local res = ngx.location.capture("/memc/$http_x_target_service")
>
>              if res.status != ngx.HTTP_OK then
>                 	ngx.exit(||ngx.|HTTP_SERVICE_UNAVAILABLE)
> 	        return
> 	|     end
> 	    if(res.body != "up") then
> 		||ngx.exit(||ngx.|HTTP_SERVICE_UNAVAILABLE)
>   		return
> 	    end
> |||         ';
>
>          # proxy_pass
>      }
> |
>
> -Umesh
>
> On 04/01/2011 08:07 AM, Tarek Ziade wrote:
>> Hey,
>>
>> I hope this is the right list for this kind of question -- seems more
>> suitable than nginx@ --
>>
>> I have started the development of a module that does the following:
>>
>> One each request, if a X-Target-Service header is present, the module
>> checks in memcached a flag. Depending on the value, it returns a 503 or
>> pass the request to the upstream server.
>>
>> The goal here is to manage in memcache the status of backend services
>> the application uses like twitter, linkedin etc, and reject any request
>> to the server if those services are down for any reason.
>>
>> I would love to get some feedback/advices from anyone experimented in
>> Nginx, as I am new to this and my C skills are from college ;)
>>
>> The memcached code still need a few changes like catching any
>> libmemcached error etc, but the nginx module logic is basically done.
>>
>> the code is here:https://bitbucket.org/tarek/nginx-sstatus/src/
>>
>> Cheers
>> Tarek
>>
>
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://nginx.org/mailman/listinfo/nginx-devel


-- 
Tarek Ziade - Mozilla Services

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx-devel/attachments/20110401/a67699d5/attachment.html>


More information about the nginx-devel mailing list