faust.app.router

Route messages to Faust nodes by partitioning.

class faust.app.router.Router(app: AppT)[source]

Router for app.router.

key_store(table_name: str, key: Optional[Union[bytes, _ModelT, Any]]) URL[source]

Return the URL of web server that hosts key in table.

Return type:

URL

external_topic_key_store(topic: TopicT, key: Optional[Union[bytes, _ModelT, Any]]) URL[source]

Return the URL of web server that processes the key in a topics.

Return type:

URL

table_metadata(table_name: str) MutableMapping[str, MutableMapping[str, List[int]]][source]

Return metadata stored for table in the partition assignor.

Return type:

_GenericAlias[str, _GenericAlias[str, _GenericAlias[int]]]

tables_metadata() MutableMapping[str, MutableMapping[str, List[int]]][source]

Return metadata stored for all tables in the partition assignor.

Return type:

_GenericAlias[str, _GenericAlias[str, _GenericAlias[int]]]

external_topics_metadata() MutableMapping[str, MutableMapping[str, List[int]]][source]

Return metadata stored for all external topics in the partition assignor.

Return type:

_GenericAlias[str, _GenericAlias[str, _GenericAlias[int]]]

async route_req(table_name: str, key: Optional[Union[bytes, _ModelT, Any]], web: Web, request: Request) Response[source]

Route request to worker having key in table.

Parameters:
  • table_name (str) – Name of the table.

  • key (_UnionGenericAlias[bytes, _ModelT, Any, None]) – The key that we want.

  • web (Web) – The currently sued web driver,

  • request (Request) – The web request currently being served.

Return type:

Response

async route_topic_req(topic: TopicT, key: Optional[Union[bytes, _ModelT, Any]], web: Web, request: Request) Response[source]

Route request to a worker that processes the partition with the given key.

Parameters:
  • topic (TopicT) – the topic to route request for.

  • key (_UnionGenericAlias[bytes, _ModelT, Any, None]) – The key that we want.

  • web (Web) – The currently sued web driver,

  • request (Request) – The web request currently being served.

Return type:

Response