Struct haproxy_api::Core
source · [−]pub struct Core<'lua> { /* private fields */ }
Expand description
The “Core” class contains all the HAProxy core functions.
Implementations
sourceimpl<'lua> Core<'lua>
impl<'lua> Core<'lua>
sourcepub fn proxies(&self) -> Result<HashMap<String, Proxy<'lua>>>
pub fn proxies(&self) -> Result<HashMap<String, Proxy<'lua>>>
Returns a map of declared proxies (frontends and backends), indexed by proxy name.
sourcepub fn backends(&self) -> Result<HashMap<String, Proxy<'lua>>>
pub fn backends(&self) -> Result<HashMap<String, Proxy<'lua>>>
Returns a map of declared proxies with backend capability, indexed by the backend name.
sourcepub fn frontends(&self) -> Result<HashMap<String, Proxy<'lua>>>
pub fn frontends(&self) -> Result<HashMap<String, Proxy<'lua>>>
Returns a map of declared proxies with frontend capability, indexed by the frontend name.
sourcepub fn thread(&self) -> Result<u16>
pub fn thread(&self) -> Result<u16>
Returns the executing thread number starting at 0. If thread is 0, Lua scope is shared by all threads, otherwise the scope is dedicated to a single thread. This is HAProxy >=2.4 feature.
sourcepub fn log<S>(&self, level: LogLevel, msg: &S) -> Result<()> where
S: AsRef<str> + ?Sized,
pub fn log<S>(&self, level: LogLevel, msg: &S) -> Result<()> where
S: AsRef<str> + ?Sized,
Sends a log on the default syslog server if it is configured and on the stderr if it is allowed.
sourcepub fn add_acl(&self, filename: &str, key: &str) -> Result<()>
pub fn add_acl(&self, filename: &str, key: &str) -> Result<()>
Adds the ACL key
in the ACLs list referenced by filename
.
sourcepub fn del_acl(&self, filename: &str, key: &str) -> Result<()>
pub fn del_acl(&self, filename: &str, key: &str) -> Result<()>
Deletes the ACL entry by key
in the ACLs list referenced by filename
.
sourcepub fn del_map(&self, filename: &str, key: &str) -> Result<()>
pub fn del_map(&self, filename: &str, key: &str) -> Result<()>
Deletes the map entry indexed with the specified key
in the list of maps
referenced by his filename
.
sourcepub fn set_map(&self, filename: &str, key: &str, value: &str) -> Result<()>
pub fn set_map(&self, filename: &str, key: &str, value: &str) -> Result<()>
Sets the value
associated to the key
in the map referenced by filename
.
sourcepub fn get_info(&self) -> Result<Vec<String>>
pub fn get_info(&self) -> Result<Vec<String>>
Returns HAProxy core information (uptime, pid, memory pool usage, tasks number, …).
sourcepub fn now(&self) -> Result<Time>
pub fn now(&self) -> Result<Time>
Returns the current time.
The time returned is fixed by the HAProxy core and assures than the hour will be monotonic
and that the system call gettimeofday
will not be called too.
sourcepub fn http_date(&self, date: &str) -> Result<u64>
pub fn http_date(&self, date: &str) -> Result<u64>
Takes a string representing http date, and returns an integer containing the corresponding date with a epoch format. A valid http date me respect the format IMF, RFC850 or ASCTIME.
sourcepub fn imf_date(&self, date: &str) -> Result<u64>
pub fn imf_date(&self, date: &str) -> Result<u64>
Take a string representing IMF date, and returns an integer containing the corresponding date with a epoch format.
sourcepub fn rfc850_date(&self, date: &str) -> Result<u64>
pub fn rfc850_date(&self, date: &str) -> Result<u64>
Takess a string representing RFC850 date, and returns an integer containing the corresponding date with a epoch format.
sourcepub fn asctime_date(&self, date: &str) -> Result<u64>
pub fn asctime_date(&self, date: &str) -> Result<u64>
Takes a string representing ASCTIME date, and returns an integer containing the corresponding date with a epoch format.
sourcepub fn register_action<A, F>(
&self,
name: &str,
actions: &[Action],
nb_args: usize,
func: F
) -> Result<()> where
A: FromLuaMulti<'lua>,
F: Fn(&'lua Lua, A) -> Result<()> + Send + 'static,
pub fn register_action<A, F>(
&self,
name: &str,
actions: &[Action],
nb_args: usize,
func: F
) -> Result<()> where
A: FromLuaMulti<'lua>,
F: Fn(&'lua Lua, A) -> Result<()> + Send + 'static,
Registers a function executed as an action.
The expected actions are tcp-req
, tcp-res
, http-req
or http-res
.
All the registered actions can be used in HAProxy with the prefix lua.
.
sourcepub fn register_async_action<A, F, FR>(
&self,
name: &str,
actions: &[&str],
nb_args: usize,
func: F
) -> Result<()> where
A: FromLuaMulti<'lua>,
F: Fn(&'lua Lua, A) -> FR + Send + 'static,
FR: Future<Output = Result<()>> + 'static,
pub fn register_async_action<A, F, FR>(
&self,
name: &str,
actions: &[&str],
nb_args: usize,
func: F
) -> Result<()> where
A: FromLuaMulti<'lua>,
F: Fn(&'lua Lua, A) -> FR + Send + 'static,
FR: Future<Output = Result<()>> + 'static,
Registers an asynchronous function executed as an action.
sourcepub fn register_lua_action<S>(
&self,
name: &str,
actions: &[&str],
nb_args: usize,
code: &S
) -> Result<()> where
S: AsChunk<'lua> + ?Sized,
pub fn register_lua_action<S>(
&self,
name: &str,
actions: &[&str],
nb_args: usize,
code: &S
) -> Result<()> where
S: AsChunk<'lua> + ?Sized,
Same as register_action
but using Lua function.
sourcepub fn register_converters<A, R, F>(&self, name: &str, func: F) -> Result<()> where
A: FromLuaMulti<'lua>,
R: ToLua<'lua>,
F: Fn(&'lua Lua, A) -> Result<R> + Send + 'static,
pub fn register_converters<A, R, F>(&self, name: &str, func: F) -> Result<()> where
A: FromLuaMulti<'lua>,
R: ToLua<'lua>,
F: Fn(&'lua Lua, A) -> Result<R> + Send + 'static,
Registers a function executed as a converter.
All the registered converters can be used in HAProxy with the prefix lua.
.
sourcepub fn register_async_converters<A, R, F, FR>(
&self,
name: &str,
func: F
) -> Result<()> where
A: FromLuaMulti<'lua>,
R: ToLua<'lua>,
F: Fn(&'lua Lua, A) -> FR + Send + 'static,
FR: Future<Output = Result<R>> + 'static,
pub fn register_async_converters<A, R, F, FR>(
&self,
name: &str,
func: F
) -> Result<()> where
A: FromLuaMulti<'lua>,
R: ToLua<'lua>,
F: Fn(&'lua Lua, A) -> FR + Send + 'static,
FR: Future<Output = Result<R>> + 'static,
Registers an asynchronous function executed as a converter.
sourcepub fn register_lua_converters<S>(&self, name: &str, code: &S) -> Result<()> where
S: AsChunk<'lua> + ?Sized,
pub fn register_lua_converters<S>(&self, name: &str, code: &S) -> Result<()> where
S: AsChunk<'lua> + ?Sized,
Same as register_converters
but using Lua function.
sourcepub fn register_fetches<A, R, F>(&self, name: &str, func: F) -> Result<()> where
A: FromLuaMulti<'lua>,
R: ToLua<'lua>,
F: Fn(&'lua Lua, A) -> Result<R> + Send + 'static,
pub fn register_fetches<A, R, F>(&self, name: &str, func: F) -> Result<()> where
A: FromLuaMulti<'lua>,
R: ToLua<'lua>,
F: Fn(&'lua Lua, A) -> Result<R> + Send + 'static,
Registers a function executed as sample fetch.
All the registered sample fetch can be used in HAProxy with the prefix lua.
.
sourcepub fn register_async_fetches<A, R, F, FR>(
&self,
name: &str,
func: F
) -> Result<()> where
A: FromLuaMulti<'lua>,
R: ToLua<'lua>,
F: Fn(&'lua Lua, A) -> FR + Send + 'static,
FR: Future<Output = Result<R>> + 'static,
pub fn register_async_fetches<A, R, F, FR>(
&self,
name: &str,
func: F
) -> Result<()> where
A: FromLuaMulti<'lua>,
R: ToLua<'lua>,
F: Fn(&'lua Lua, A) -> FR + Send + 'static,
FR: Future<Output = Result<R>> + 'static,
Registers an asynchronous function executed as sample fetch.
sourcepub fn register_lua_fetches<S>(&self, name: &str, code: &S) -> Result<()> where
S: AsChunk<'lua> + ?Sized,
pub fn register_lua_fetches<S>(&self, name: &str, code: &S) -> Result<()> where
S: AsChunk<'lua> + ?Sized,
Same as register_fetches
but using Lua function.
sourcepub fn register_lua_service<S>(
&self,
name: &str,
mode: ServiceMode,
code: &S
) -> Result<()> where
S: AsChunk<'lua> + ?Sized,
pub fn register_lua_service<S>(
&self,
name: &str,
mode: ServiceMode,
code: &S
) -> Result<()> where
S: AsChunk<'lua> + ?Sized,
Registers a Lua function executed as a service.
All the registered service can be used in HAProxy with the prefix lua.
.
sourcepub fn register_init<F>(&self, func: F) -> Result<()> where
F: Fn(&'lua Lua) -> Result<()> + Send + 'static,
pub fn register_init<F>(&self, func: F) -> Result<()> where
F: Fn(&'lua Lua) -> Result<()> + Send + 'static,
Registers a function executed after the configuration parsing. This is useful to check any parameters.
sourcepub fn register_task<F>(&self, func: F) -> Result<()> where
F: Fn(&'lua Lua) -> Result<()> + Send + 'static,
pub fn register_task<F>(&self, func: F) -> Result<()> where
F: Fn(&'lua Lua) -> Result<()> + Send + 'static,
Registers and start an independent task. The task is started when the HAProxy main scheduler starts.
sourcepub fn register_async_task<F, FR>(&self, func: F) -> Result<()> where
F: Fn(&'lua Lua) -> FR + Send + 'static,
FR: Future<Output = Result<()>> + 'static,
pub fn register_async_task<F, FR>(&self, func: F) -> Result<()> where
F: Fn(&'lua Lua) -> FR + Send + 'static,
FR: Future<Output = Result<()>> + 'static,
Registers and start an independent asynchronous task.
sourcepub fn register_lua_task<S>(&self, code: &S) -> Result<()> where
S: AsChunk<'lua> + ?Sized,
pub fn register_lua_task<S>(&self, code: &S) -> Result<()> where
S: AsChunk<'lua> + ?Sized,
Same as register_task
but using Lua function.
sourcepub fn register_lua_cli<S>(
&self,
path: &[&str],
usage: &str,
code: &S
) -> Result<()> where
S: AsChunk<'lua> + ?Sized,
pub fn register_lua_cli<S>(
&self,
path: &[&str],
usage: &str,
code: &S
) -> Result<()> where
S: AsChunk<'lua> + ?Sized,
Registers a Lua function executed as a cli command.
sourcepub fn set_nice(&self, nice: i32) -> Result<()>
pub fn set_nice(&self, nice: i32) -> Result<()>
Changes the nice of the current task or current session.
sourcepub fn parse_addr(&self, addr: &str) -> Result<AnyUserData<'lua>>
pub fn parse_addr(&self, addr: &str) -> Result<AnyUserData<'lua>>
Parses ipv4 or ipv6 addresses and its facultative associated network.
sourcepub fn match_addr(
&self,
addr1: AnyUserData<'_>,
addr2: AnyUserData<'_>
) -> Result<bool>
pub fn match_addr(
&self,
addr1: AnyUserData<'_>,
addr2: AnyUserData<'_>
) -> Result<bool>
Matches two networks. For example “127.0.0.1/32” matches “127.0.0.0/8”. The order of network is not important.
Trait Implementations
Auto Trait Implementations
impl<'lua> !RefUnwindSafe for Core<'lua>
impl<'lua> !Send for Core<'lua>
impl<'lua> !Sync for Core<'lua>
impl<'lua> Unpin for Core<'lua>
impl<'lua> !UnwindSafe for Core<'lua>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more