pyrlang.pattern_match¶
Patterns for selective receive and for GenServer handlers.
- pyrlang.pattern_match.always_match(_)¶
A pattern function that accepts every message.
- pyrlang.pattern_match.handle_do_nothing(data)¶
A handler that returns the message unchanged.
- class pyrlang.pattern_match.Pattern(match_fun=None, match_success_fun=None)¶
Bases:
objectA pattern is a pair of matcher function, and an async handler function. Matcher will be checked with the incoming message, and if it returned True, the async handler will be invoked. This is typically done in the process receive handler, but potential uses are not limited to it.
- is_match(data)¶
This checks whether ‘data’ matches something we expect.
- async on_match_success(data)¶
This should be called on the successful match. The handler may return a value or an awaitable; an awaitable is awaited.