def inject(self,<EOL>require: Optional[List[Text]] = None,<EOL>fail: Text = '<STR_LIT>',<EOL>var_name: Text = '<STR_LIT>'):
def decorator(func):<EOL><INDENT>async def health_check(cls) -> Iterator[HealthCheckFail]:<EOL><INDENT>if not callable(getattr(cls, fail, None)):<EOL><INDENT>yield HealthCheckFail(<EOL>'<STR_LIT>',<EOL>f'<STR_LIT>'<EOL>f'<STR_LIT>'<EOL>f'<STR_LIT>'<EOL>)<EOL><DEDENT><DEDENT>if require:<EOL><INDENT>func.health_check = health_check<EOL><DEDENT>@wraps(func)<EOL>async def wrapper(state: Union[BaseState, BaseTrigger], **kwargs):<EOL><INDENT>conv_id = state.request.conversation.id<EOL>key = f'<STR_LIT>'<EOL>x = self.open(key)<EOL>async with x as context:<EOL><INDENT>for item in (require or []):<EOL><INDENT>if item not in context:<EOL><INDENT>return await getattr(state, fail)(state, **kwargs)<EOL><DEDENT><DEDENT>kwargs[var_name] = context<EOL>return await func(state, **kwargs)<EOL><DEDENT><DEDENT>return wrapper<EOL><DEDENT>return decorator<EOL>
This is a decorator intended to be used on states (and actually only
work on state handlers).

The `require` argument is a list of keys to be checked in the context.
If at least one of them is missing, then instead of calling the handler
another method will be called. By default the method is
`missing_context` but it can be configured using the `fail` argument.

The context will be injected into the handler as a keyword arg. By
default, the arg is expected to be named `context` but you can change
it to anything you'd like using `var_name`.

See `create_context_store()` for a full example.