github.com/status-im/status-go@v1.1.0/services/connector/command_registry.go (about)

     1  package connector
     2  
     3  import "github.com/status-im/status-go/services/connector/commands"
     4  
     5  type CommandRegistry struct {
     6  	commands map[string]commands.RPCCommand
     7  }
     8  
     9  func NewCommandRegistry() *CommandRegistry {
    10  	return &CommandRegistry{
    11  		commands: make(map[string]commands.RPCCommand),
    12  	}
    13  }
    14  
    15  func (r *CommandRegistry) Register(method string, command commands.RPCCommand) {
    16  	r.commands[method] = command
    17  }
    18  
    19  func (r *CommandRegistry) GetCommand(method string) (commands.RPCCommand, bool) {
    20  	command, exists := r.commands[method]
    21  	return command, exists
    22  }