Skip to main content

cmd_echo.go

Filename: cmd_echo.go

  1. Overview

This file defines the ECHO command for the DiceDB system. The ECHO command simply returns the message that was passed to it as an argument.

  1. Detailed Documentation

    cECHO

    • Purpose: Defines the metadata for the ECHO command.
    • Type: *CommandMeta
    • Fields:
      • Name: The name of the command ("ECHO").
      • Syntax: The syntax of the command ("ECHO message").
      • HelpShort: A short description of the command.
      • HelpLong: A longer description of the command.
      • Examples: Examples of how to use the command.
      • Eval: The evalECHO function to pre-evaluate the command.
      • Execute: The executeECHO function to execute the command.

    init()

    • Purpose: Registers the ECHO command with the CommandRegistry.
    • Parameters: None
    • Returns: None

    evalECHO(c *Cmd, s *dstore.Store) (*CmdRes, error)

    • Purpose: Evaluates the ECHO command and constructs the response.
    • Parameters:
      • c: A pointer to the Cmd struct representing the command.
      • s: A pointer to the dstore.Store struct representing the data store.
    • Returns:
      • *CmdRes: A pointer to the CmdRes struct containing the response.
      • error: An error if the number of arguments is incorrect.
    type Cmd struct {
    C *Command
    }

    type CmdRes struct {
    R *wire.Response
    }

    executeECHO(c *Cmd, sm *shardmanager.ShardManager) (*CmdRes, error)

    • Purpose: Executes the ECHO command within a shard.
    • Parameters:
      • c: A pointer to the Cmd struct representing the command.
      • sm: A pointer to the shardmanager.ShardManager struct.
    • Returns:
      • *CmdRes: A pointer to the CmdRes struct containing the response.
      • error: An error if one occurs during evaluation.
  2. Code Examples

    None

  3. Getting Started Relevance