Commit Graph

7 Commits

Author SHA1 Message Date
Kazuhiro Suzuki
6157fe2ca5 Update spec 2015-12-18 11:39:16 +09:00
Kazuhiro Suzuki
0d1b0bee9f Add cleanup intercepts function
This function purges specified target module, which was created as a proxy,
and its backuped original module, then reloads original module.
2015-12-18 10:26:50 +09:00
Mike Wallace
1f719ab8a5 Add copyright and Apache License Version 2.0 2015-09-11 17:06:34 +01:00
Engel A. Sanchez
a72ea9de4c Save intercept beams in basho-patches
You can now choose to save the intercept modules in basho-patches so
that they are loaded on a restart. This should be useful to modify
Riak's behavior at startup time.
2014-06-19 23:24:09 -04:00
Steve Vinoski
fbbacdd0b3 support for anonymous function intercepts
Allow intercept functions passed to rt_intercept:add/2 to be anonymous. In
compiled code they can either be a plain anonymous function, assuming they
don't use any variables from the surrounding context, or they can be a
2-tuple like this:

{[FreeVar1, ...],
 fun(Arg1, ...) -> ... end}

where FreeVar1 etc. is a list of free variables to be closed over so that
they can be used within the anonymous function. For making interactive
calls to rt_intercept:add/2 from the Erlang shell, only the anonymous
function form is required, even if it uses free variables, though the
2-tuple form is also acceptable.

For compiled code, support for anonymous intercept functions is implemented
via a parse transform, and so to use anonymous functions the intercept
structure(s) containing them must be defined directly inline as part of the
final argument to rt_intercept:add/2, i.e., they cannot be first assigned
to a variable that is then used within the argument. This is because the
value of such a variable might not be visible to the parse transform.

Add a description of anonymous function intercepts to the README.
2014-04-25 15:07:02 -04:00
Sean Cribbs
e76ff55175 Fix function name typo. 2013-01-03 09:23:15 -05:00
Ryan Zezeski
d284dcfc22 Add intercepts
Intercepts provide the ability to easily and efficiently intercept
function calls.  Giving the ability to change the code being executed
as well as affect local and global state.
2012-12-20 16:14:28 -05:00