Skip to content

Commit

Permalink
fix commands doc in python (valkey-io#964)
Browse files Browse the repository at this point in the history
  • Loading branch information
shohamazon authored Feb 14, 2024
1 parent 6ea7701 commit 8466748
Show file tree
Hide file tree
Showing 4 changed files with 297 additions and 233 deletions.
44 changes: 29 additions & 15 deletions python/python/glide/async_commands/cluster_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class ClusterCommands(CoreCommands):
async def custom_command(
self, command_args: List[str], route: Optional[Route] = None
) -> TResult:
"""Executes a single command, without checking inputs.
"""
Executes a single command, without checking inputs.
@remarks - This function should only be used for single-response commands. Commands that don't return response (such as SUBSCRIBE), or that return potentially more than a single response (such as XREAD), or that change the client's behavior (such as entering pub/sub mode on RESP2 connections) shouldn't be called using this function.
@example - Return a list of all pub/sub clients from all nodes:
Expand All @@ -38,13 +39,14 @@ async def info(
sections: Optional[List[InfoSection]] = None,
route: Optional[Route] = None,
) -> TClusterResponse[str]:
"""Get information and statistics about the Redis server.
"""
Get information and statistics about the Redis server.
See https://redis.io/commands/info/ for details.
Args:
sections (Optional[List[InfoSection]]): A list of InfoSection values specifying which sections of
information to retrieve. When no parameter is provided, the default option is assumed.
route (Optional[Route]): The command will be routed to all primeries, unless `route` is provided, in which
route (Optional[Route]): The command will be routed to all primaries, unless `route` is provided, in which
case the client will route the command to the nodes defined by `route`. Defaults to None.
Returns:
Expand All @@ -64,7 +66,8 @@ async def exec(
transaction: BaseTransaction | ClusterTransaction,
route: Optional[TSingleNodeRoute] = None,
) -> Optional[List[TResult]]:
"""Execute a transaction by processing the queued commands.
"""
Execute a transaction by processing the queued commands.
See https://redis.io/topics/Transactions/ for details on Redis Transactions.
Args:
Expand All @@ -86,11 +89,14 @@ async def config_resetstat(
self,
route: Optional[Route] = None,
) -> TOK:
"""Reset the statistics reported by Redis.
"""
Resets the statistics reported by Redis using the INFO and LATENCY HISTOGRAM commands.
See https://redis.io/commands/config-resetstat/ for details.
Args:
route (Optional[Route]): The command will be routed automatically to all nodes, unless `route` is provided, in which
case the client will route the command to the nodes defined by `route`. Defaults to None.
Returns:
OK: Returns "OK" to confirm that the statistics were successfully reset.
"""
Expand All @@ -102,13 +108,16 @@ async def config_rewrite(
self,
route: Optional[Route] = None,
) -> TOK:
"""Rewrite the configuration file with the current configuration.
"""
Rewrite the configuration file with the current configuration.
See https://redis.io/commands/config-rewrite/ for details.
Args:
route (Optional[TRoute]): The command will be routed automatically to all nodes, unless `route` is provided, in which
case the client will route the command to the nodes defined by `route`. Defaults to None.
Returns:
OK: OK is returned when the configuration was rewritten properly. Otherwise an error is returned.
OK: OK is returned when the configuration was rewritten properly. Otherwise an error is raised.
"""
return cast(
TOK, await self._execute_command(RequestType.ConfigRewrite, [], route)
Expand All @@ -118,8 +127,10 @@ async def client_id(
self,
route: Optional[Route] = None,
) -> TClusterResponse[int]:
"""Returns the current connection id.
"""
Returns the current connection id.
See https://redis.io/commands/client-id/ for more information.
Args:
route (Optional[Route]): The command will be sent to a random node, unless `route` is provided, in which
case the client will route the command to the nodes defined by `route`.
Expand All @@ -138,17 +149,19 @@ async def client_id(
async def ping(
self, message: Optional[str] = None, route: Optional[Route] = None
) -> str:
"""Ping the Redis server.
"""
Ping the Redis server.
See https://redis.io/commands/ping/ for more details.
Args:
message (Optional[str]): An optional message to include in the PING command. If not provided,
the server will respond with "PONG". If provided, the server will respond with a copy of the message.
message (Optional[str]): An optional message to include in the PING command. If not provided,
the server will respond with "PONG". If provided, the server will respond with a copy of the message
route (Optional[Route]): The command will be sent to all primaries, unless `route` is provided, in which
case the client will route the command to the nodes defined by `route`
Returns:
str: "PONG" if 'message' is not provided, otherwise return a copy of 'message'.
str: "PONG" if `message` is not provided, otherwise return a copy of `message`.
Examples:
>>> await client.ping()
Expand All @@ -162,7 +175,8 @@ async def ping(
async def config_get(
self, parameters: List[str], route: Optional[Route] = None
) -> TClusterResponse[Dict[str, str]]:
"""Get the values of configuration parameters.
"""
Get the values of configuration parameters.
See https://redis.io/commands/config-get/ for details.
Args:
Expand Down Expand Up @@ -191,7 +205,8 @@ async def config_get(
async def config_set(
self, parameters_map: Mapping[str, str], route: Optional[Route] = None
) -> TOK:
"""Set configuration parameters to the specified values.
"""
Set configuration parameters to the specified values.
See https://redis.io/commands/config-set/ for details.
Args:
Expand Down Expand Up @@ -238,7 +253,6 @@ async def client_getname(
>>> await client.client_getname(AllNodes())
{'addr': 'Connection Name'', 'addr2': 'Connection Name', 'addr3': 'Connection Name'}
"""

return cast(
TClusterResponse[Optional[str]],
await self._execute_command(RequestType.ClientGetName, [], route),
Expand Down
Loading

0 comments on commit 8466748

Please sign in to comment.