MCPcopy
hub / github.com/redis/redis-py / set_pubsub_node

Method set_pubsub_node

redis/asyncio/cluster.py:3459–3491  ·  view source on GitHub ↗

The pubsub node will be set according to the passed node, host and port When none of the node, host, or port are specified - the node is set to None and will be determined by the keyslot of the channel in the first command to be executed. RedisClusterExceptio

(
        self,
        cluster: "RedisCluster",
        node: Optional["ClusterNode"] = None,
        host: Optional[str] = None,
        port: Optional[int] = None,
    )

Source from the content-addressed store, hash-verified

3457 )
3458
3459 def set_pubsub_node(
3460 self,
3461 cluster: "RedisCluster",
3462 node: Optional["ClusterNode"] = None,
3463 host: Optional[str] = None,
3464 port: Optional[int] = None,
3465 ) -> None:
3466 """
3467 The pubsub node will be set according to the passed node, host and port
3468 When none of the node, host, or port are specified - the node is set
3469 to None and will be determined by the keyslot of the channel in the
3470 first command to be executed.
3471 RedisClusterException will be thrown if the passed node does not exist
3472 in the cluster.
3473 If host is passed without port, or vice versa, a DataError will be
3474 thrown.
3475 """
3476 if node is not None:
3477 # node is passed by the user
3478 self._raise_on_invalid_node(cluster, node, node.host, node.port)
3479 pubsub_node = node
3480 elif host is not None and port is not None:
3481 # host and port passed by the user
3482 node = cluster.get_node(host=host, port=port)
3483 self._raise_on_invalid_node(cluster, node, host, port)
3484 pubsub_node = node
3485 elif host is not None or port is not None:
3486 # only one of host and port is specified
3487 raise DataError("Specify both host and port")
3488 else:
3489 # nothing specified by the user
3490 pubsub_node = None
3491 self.node = pubsub_node
3492
3493 def get_pubsub_node(self) -> Optional["ClusterNode"]:
3494 """

Callers 1

__init__Method · 0.95

Calls 3

DataErrorClass · 0.90
get_nodeMethod · 0.45

Tested by

no test coverage detected