mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
MINOR: hlua_fcn: add Patref:prepare() method
Just like the "prepare map" or "prepare acl" on the cli, but for Lua: it leverages the pattern API to create a subset (ie: a new generation id) that will automatically be used as target for following Patref operations (add/set/del...) until the "commit" method is invoked to atomically push the pending updates.
This commit is contained in:
parent
8bce7ff854
commit
fe394598c5
@ -3456,6 +3456,12 @@ Patref class
|
|||||||
:returns: true if the pattern reference is used to handle maps instead
|
:returns: true if the pattern reference is used to handle maps instead
|
||||||
of acl, false otherwise.
|
of acl, false otherwise.
|
||||||
|
|
||||||
|
.. js:function:: Patref.prepare(ref)
|
||||||
|
|
||||||
|
Create a new empty version for Patref Object. It can be used to manipulate
|
||||||
|
the Patref object with update methods without applying the updates until the
|
||||||
|
commit() method is called.
|
||||||
|
|
||||||
.. js:function:: Patref.commit(ref)
|
.. js:function:: Patref.commit(ref)
|
||||||
|
|
||||||
Tries to commit pending Patref object updates, that is updates made to the
|
Tries to commit pending Patref object updates, that is updates made to the
|
||||||
@ -3467,6 +3473,8 @@ Patref class
|
|||||||
|
|
||||||
:returns: true on success and nil on failure (followed by an error message).
|
:returns: true on success and nil on failure (followed by an error message).
|
||||||
|
|
||||||
|
See :js:func:`Patref.prepare()`
|
||||||
|
|
||||||
.. _applethttp_class:
|
.. _applethttp_class:
|
||||||
|
|
||||||
AppletHTTP class
|
AppletHTTP class
|
||||||
|
@ -2694,6 +2694,17 @@ int hlua_patref_commit(lua_State *L)
|
|||||||
return _hlua_patref_clear(L, LUA_OK, 0);
|
return _hlua_patref_clear(L, LUA_OK, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int hlua_patref_prepare(lua_State *L)
|
||||||
|
{
|
||||||
|
struct hlua_patref *ref;
|
||||||
|
|
||||||
|
ref = hlua_checkudata(L, 1, class_patref_ref);
|
||||||
|
BUG_ON(!ref);
|
||||||
|
ref->curr_gen = pat_ref_newgen(ref->ptr);
|
||||||
|
ref->flags |= HLUA_PATREF_FL_GEN;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void hlua_fcn_new_patref(lua_State *L, struct pat_ref *ref)
|
void hlua_fcn_new_patref(lua_State *L, struct pat_ref *ref)
|
||||||
{
|
{
|
||||||
struct hlua_patref *_ref;
|
struct hlua_patref *_ref;
|
||||||
@ -2721,6 +2732,7 @@ void hlua_fcn_new_patref(lua_State *L, struct pat_ref *ref)
|
|||||||
/* set public methods */
|
/* set public methods */
|
||||||
hlua_class_function(L, "get_name", hlua_patref_get_name);
|
hlua_class_function(L, "get_name", hlua_patref_get_name);
|
||||||
hlua_class_function(L, "is_map", hlua_patref_is_map);
|
hlua_class_function(L, "is_map", hlua_patref_is_map);
|
||||||
|
hlua_class_function(L, "prepare", hlua_patref_prepare);
|
||||||
hlua_class_function(L, "commit", hlua_patref_commit);
|
hlua_class_function(L, "commit", hlua_patref_commit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user