GenReactor

GenReactor is Bondy's behaviour for a process whose state is a store of constraints and whose logic is rules, the way gen_server is the behaviour for a process with arbitrary state.

You tell a GenReactor a fact. Its rules fire until the store settles, and the events they emit are passed to handle_event/2, which decides which ones the caller hears. It is a normal OTP process: it has a pid, it can be registered, and it goes in a supervision tree.

bondy
module RateLimiter implements GenReactor(Event = Allowed | Denied)