Browse Source

Add ngx_http_dyups_module into tengine

pull/622/head
yzprofile 10 years ago
parent
commit
27dea31e21
  1. 11
      auto/modules
  2. 8
      auto/options
  3. 10
      auto/sources
  4. 23
      src/http/modules/ngx_http_dyups.h
  5. 88
      src/http/modules/ngx_http_dyups_lua.c
  6. 19
      src/http/modules/ngx_http_dyups_lua.h
  7. 2580
      src/http/modules/ngx_http_dyups_module.c

11
auto/modules

@ -1,4 +1,3 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
@ -701,6 +700,16 @@ if [ $HTTP_UPSTREAM_DYNAMIC = YES ]; then
HTTP_SRCS="$HTTP_SRCS $HTTP_UPSTREAM_DYNAMIC_SRCS"
fi
if [ $HTTP_DYNAMIC_UPSTREAM = YES ]; then
HTTP_MODULES="$HTTP_MODULES $HTTP_DYUPS_MODULE"
HTTP_SRCS="$HTTP_SRCS $HTTP_DYUPS_SRCS"
if [ $HTTP_DYNAMIC_UPSTREAM_LUA = YES ]; then
HTTP_SRCS="$HTTP_SRCS $HTTP_DYUPS_LUA_SRCS"
HTTP_DEPS="$HTTP_DEPS $HTTP_DYUPS_LUA_DEPS"
have=NGX_DYUPS_LUA . auto/have
fi
fi
if [ $HTTP_STUB_STATUS = YES ]; then
have=NGX_STAT_STUB . auto/have
NGX_DSO_ABI_COMPATIBILITY=$(($NGX_DSO_ABI_COMPATIBILITY|$NGX_DSO_STAT_STUB_TAG))

8
auto/options

@ -261,6 +261,8 @@ HTTP_UPSTREAM_LEAST_CONN=YES
HTTP_UPSTREAM_SESSION_STICKY=YES
HTTP_UPSTREAM_KEEPALIVE=YES
HTTP_UPSTREAM_DYNAMIC=YES
HTTP_DYNAMIC_UPSTREAM=NO
HTTP_DYNAMIC_UPSTREAM_LUA=NO
HTTP_UPSTREAM_CONSISTENT_HASH=YES
HTTP_UPSTREAM_CONSISTENT_HASH_SHARED=NO
HTTP_UPSTREAM_RBTREE=YES
@ -624,6 +626,9 @@ use the \"--without-http_limit_conn_module\" option instead"
--without-http_upstream_keepalive_module) HTTP_UPSTREAM_KEEPALIVE=NO ;;
--without-http_upstream_dynamic_module) HTTP_UPSTREAM_DYNAMIC=NO ;;
--with-http_dyups_module) HTTP_DYNAMIC_UPSTREAM=YES ;;
--with-http_dyups_lua_api) HTTP_DYNAMIC_UPSTREAM_LUA=YES ;;
--with-http_perl_module) HTTP_PERL=YES ;;
--with-perl_modules_path=*) NGX_PERL_MODULES="$value" ;;
--with-perl=*) NGX_PERL="$value" ;;
@ -874,6 +879,8 @@ cat << END
--without-http_stub_status_module disable ngx_http_stub_status_module
--without-http_reqstat_module disable ngx_http_reqstat_module
--with-http_dyups_module enable ngx_http_dyups_module
--with-http_perl_module enable ngx_http_perl_module
--with-perl_modules_path=PATH set Perl modules path
--with-perl=PATH set perl binary pathname
@ -1095,6 +1102,7 @@ elif [ $NGX_STATIC_ALL_MODULES = YES ]; then
HTTP_UPSTREAM_SESSION_STICKY=YES
HTTP_UPSTREAM_KEEPALIVE=YES
HTTP_UPSTREAM_DYNAMIC=YES
HTTP_DYNAMIC_UPSTREAM=YES
HTTP_REQ_STATUS=YES
HTTP_AUTH_REQUEST=YES
MAIL=YES

10
auto/sources

@ -1,4 +1,3 @@
# Copyright (C) Igor Sysoev
# Copyright (C) Nginx, Inc.
@ -571,6 +570,13 @@ HTTP_UPSTREAM_DYNAMIC_MODULE=ngx_http_upstream_dynamic_module
HTTP_UPSTREAM_DYNAMIC_SRCS=" \
src/http/modules/ngx_http_upstream_dynamic_module.c"
HTTP_DYUPS_MODULE=ngx_http_dyups_module
HTTP_DYUPS_SRCS="src/http/modules/ngx_http_dyups_module.c"
HTTP_DYUPS_DEPS="src/http/modules/ngx_http_dyups.h"
HTTP_DYUPS_LUA_SRCS="src/http/modules/ngx_http_dyups_lua.c"
HTTP_DYUPS_LUA_DEPS="src/http/modules/ngx_http_dyups_lua.h"
HTTP_REQ_STATUS_MODULE=ngx_http_reqstat_module
HTTP_REQ_STATUS_SRCS=src/http/modules/ngx_http_reqstat_module.c
HTTP_REQ_STATUS_DEPS=src/http/modules/ngx_http_reqstat.h
@ -772,5 +778,3 @@ NGX_HTTP_TFS_MODULE_SRCS="src/http/modules/tfs/ngx_tfs_common.c \
src/http/modules/tfs/ngx_http_tfs_meta_server_message.c \
src/http/modules/tfs/ngx_http_tfs_peer_connection.c \
src/http/modules/tfs/ngx_http_tfs_server_handler.c "

23
src/http/modules/ngx_http_dyups.h

@ -0,0 +1,23 @@
/*
* Copyright (C) 2010-2014 Alibaba Group Holding Limited
*/
#ifndef _NGX_HTTP_DYUPS_H_INCLUDE_
#define _NGX_HTTP_DYUPS_H_INCLUDE_
#include <ngx_config.h>
#include <ngx_core.h>
ngx_int_t ngx_dyups_update_upstream(ngx_str_t *name, ngx_buf_t *buf,
ngx_str_t *rv);
ngx_int_t ngx_dyups_delete_upstream(ngx_str_t *name, ngx_str_t *rv);
extern ngx_flag_t ngx_http_dyups_api_enable;
#endif

88
src/http/modules/ngx_http_dyups_lua.c

@ -0,0 +1,88 @@
/*
* Copyright (C) 2010-2014 Alibaba Group Holding Limited
*/
#include <ngx_http.h>
#include <ngx_http_dyups.h>
#include <ngx_http_dyups_lua.h>
static int ngx_http_dyups_lua_register(lua_State *L);
static int ngx_http_lua_update_upstream(lua_State *L);
static int ngx_http_lua_delete_upstream(lua_State *L);
static int
ngx_http_lua_update_upstream(lua_State *L)
{
size_t size;
ngx_int_t status;
ngx_str_t name, rv;
ngx_buf_t buf;
if (lua_gettop(L) != 2) {
return luaL_error(L, "exactly 2 arguments expected");
}
name.data = (u_char *) luaL_checklstring(L, 1, &name.len);
buf.pos = buf.start = (u_char *) luaL_checklstring(L, 2, &size);
buf.last = buf.end = buf.pos + size;
status = ngx_dyups_update_upstream(&name, &buf, &rv);
lua_pushinteger(L, (lua_Integer) status);
lua_pushlstring(L, (char *) rv.data, rv.len);
return 2;
}
static int
ngx_http_lua_delete_upstream(lua_State *L)
{
ngx_int_t status;
ngx_str_t name, rv;
if (lua_gettop(L) != 1) {
return luaL_error(L, "exactly 1 argument expected");
}
name.data = (u_char *) luaL_checklstring(L, 1, &name.len);
status = ngx_dyups_delete_upstream(&name, &rv);
lua_pushinteger(L, (lua_Integer) status);
lua_pushlstring(L, (char *) rv.data, rv.len);
return 2;
}
static int
ngx_http_dyups_lua_register(lua_State *L)
{
lua_createtable(L, 0, 1);
lua_pushcfunction(L, ngx_http_lua_update_upstream);
lua_setfield(L, -2, "update");
lua_pushcfunction(L, ngx_http_lua_delete_upstream);
lua_setfield(L, -2, "delete");
return 1;
}
ngx_int_t
ngx_http_dyups_lua_preload(ngx_conf_t *cf)
{
if (ngx_http_lua_add_package_preload(cf, "ngx.dyups",
ngx_http_dyups_lua_register)
!= NGX_OK)
{
return NGX_ERROR;
}
return NGX_OK;
}

19
src/http/modules/ngx_http_dyups_lua.h

@ -0,0 +1,19 @@
/*
* Copyright (C) 2010-2014 Alibaba Group Holding Limited
*/
#ifndef _NGX_HTTP_DYUPS_LUA_H_INCLUDE_
#define _NGX_HTTP_DYUPS_LUA_H_INCLUDE_
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http_lua_api.h>
#include <lualib.h>
#include <lauxlib.h>
ngx_int_t ngx_http_dyups_lua_preload(ngx_conf_t *cf);
#endif

2580
src/http/modules/ngx_http_dyups_module.c
File diff suppressed because it is too large
View File

Loading…
Cancel
Save