mode.types — mode-ng 0.4.0 documentation

# `mode.types`

class mode.types.BaseSignalT(*, name: Optional[str] = None, owner: Optional[Type] = None, loop: Optional[AbstractEventLoop] = None, default_sender: Optional[Any] = None, receivers: Optional[MutableSet[Union[Callable[[], Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]]], weakref[Union[Callable[[T, Any, mode.types.signals.BaseSignalT, Any], NoneType], Callable[[T, Any, mode.types.signals.BaseSignalT, Any], Awaitable[NoneType]]]]]]] = None, filter_receivers: Optional[MutableMapping[Any, MutableSet[Union[Callable[[], Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]]], weakref[Union[Callable[[T, Any, mode.types.signals.BaseSignalT, Any], NoneType], Callable[[T, Any, mode.types.signals.BaseSignalT, Any], Awaitable[NoneType]]]]]]]] = None)

  Base type for all signals.

  abstract clone(**kwargs: Any) → BaseSignalT
  abstract connect(fun: Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]], **kwargs: Any) → Callable
  abstract disconnect(fun: Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]], *, sender: Optional[Any] = None, weak: bool = True) → None
  name: str
  owner: Optional[Type]
  abstract with_default_sender(sender: Optional[Any] = None) → BaseSignalT

class mode.types.DiagT(service: ServiceT)

  Diag keeps track of a services diagnostic flags.

  flags: set[str]
  last_transition: MutableMapping[str, float]
  abstract set_flag(flag: str) → None
  abstract unset_flag(flag: str) → None

class mode.types.ServiceT(*, beacon: Optional[NodeT] = None, loop: Optional[AbstractEventLoop] = None)

  Abstract type for an asynchronous service that can be started/stopped.

  See also

  `mode.Service`.

  Diag: Type[DiagT]
  abstract async add_async_context(context: AsyncContextManager) → Any
  abstract add_context(context: ContextManager) → Any
  abstract add_dependency(service: ServiceT) → ServiceT
  abstract async add_runtime_dependency(service: ServiceT) → ServiceT
  async_exit_stack: AsyncExitStack
  property beacon: NodeT
  abstract async crash(reason: BaseException) → None
  abstract property crash_reason: Optional[BaseException]
  abstract property crashed: bool
  diag: DiagT
  exit_stack: ExitStack
  abstract property label: str
  abstract property loop: AbstractEventLoop
  abstract async maybe_start() → bool
  abstract async restart() → None
  restart_count: int = 0
  abstract service_reset() → None
  abstract set_shutdown() → None
  abstract property shortlabel: str
  abstract property should_stop: bool
  shutdown_timeout: float
  abstract async start() → None
  abstract property started: bool
  abstract property state: str
  abstract async stop() → None
  supervisor: Optional[SupervisorStrategyT] = None
  wait_for_shutdown: bool = False
  abstract async wait_until_stopped() → None

class mode.types.SignalT(*, name: Optional[str] = None, owner: Optional[Type] = None, loop: Optional[AbstractEventLoop] = None, default_sender: Optional[Any] = None, receivers: Optional[MutableSet[Union[Callable[[], Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]]], weakref[Union[Callable[[T, Any, mode.types.signals.BaseSignalT, Any], NoneType], Callable[[T, Any, mode.types.signals.BaseSignalT, Any], Awaitable[NoneType]]]]]]] = None, filter_receivers: Optional[MutableMapping[Any, MutableSet[Union[Callable[[], Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]]], weakref[Union[Callable[[T, Any, mode.types.signals.BaseSignalT, Any], NoneType], Callable[[T, Any, mode.types.signals.BaseSignalT, Any], Awaitable[NoneType]]]]]]]] = None)

  Base class for all async signals (using `async def`).

  abstract clone(**kwargs: Any) → SignalT
  abstract async send(sender: T_contra, *args: Any, **kwargs: Any) → None
  abstract with_default_sender(sender: Any = None) → SignalT

class mode.types.SupervisorStrategyT(*services: ServiceT, max_restarts: Union[timedelta, int, float, str] = 100.0, over: Union[timedelta, int, float, str] = 1.0, raises: Optional[Type[BaseException]] = None, replacement: Optional[Callable[[ServiceT, int], Awaitable[ServiceT]]] = None, **kwargs: Any)

  Base type for all supervisor strategies.

  Diag: Type[DiagT]
  abstract add(*services: ServiceT) → None
  async_exit_stack: AsyncExitStack
  diag: DiagT
  abstract discard(*services: ServiceT) → None
  exit_stack: ExitStack
  max_restarts: float
  over: float
  raises: Type[BaseException]
  replacement: Optional[ReplacementT]
  abstract async restart_service(service: ServiceT) → None
  abstract service_operational(service: ServiceT) → bool
  shutdown_timeout: float
  abstract wakeup() → None

class mode.types.SyncSignalT(*, name: Optional[str] = None, owner: Optional[Type] = None, loop: Optional[AbstractEventLoop] = None, default_sender: Optional[Any] = None, receivers: Optional[MutableSet[Union[Callable[[], Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]]], weakref[Union[Callable[[T, Any, mode.types.signals.BaseSignalT, Any], NoneType], Callable[[T, Any, mode.types.signals.BaseSignalT, Any], Awaitable[NoneType]]]]]]] = None, filter_receivers: Optional[MutableMapping[Any, MutableSet[Union[Callable[[], Union[Callable[[T, Any, BaseSignalT, Any], None], Callable[[T, Any, BaseSignalT, Any], Awaitable[None]]]], weakref[Union[Callable[[T, Any, mode.types.signals.BaseSignalT, Any], NoneType], Callable[[T, Any, mode.types.signals.BaseSignalT, Any], Awaitable[NoneType]]]]]]]] = None)

  Base class for all synchronous signals (using regular `def`).

  abstract clone(**kwargs: Any) → SyncSignalT
  abstract send(sender: T_contra, *args: Any, **kwargs: Any) → None
  abstract with_default_sender(sender: Any = None) → SyncSignalT