Method: Sparrow::Server#process_message

Defined in:
lib/sparrow/server.rb

#process_message(ln) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/sparrow/server.rb', line 104

def process_message ln
  @data = ln
  if ln =~ SET_REGEX
    set_command
  elsif ln =~ ADD_REGEX
    add_command
  elsif ln =~ REPLACE_REGEX
    replace_command
  elsif ln =~ GET_REGEX
    get_command
  elsif ln =~ DELETE_REGEX
    delete_command
  elsif ln =~ QUIT_REGEX
    quit_command
  elsif ln =~ VERSION_REGEX
    version_command
  elsif ln =~ FLUSH_ALL_REGEX
    flush_all_command
  elsif ln =~ STATS_REGEX
    stats_command
  elsif @expecting_body
    process_body
  else
    raise StatementInvalid
  end
  @data = nil
  @split_args = nil

rescue ClientError => e
  logger.error e
  publish CLIENT_ERROR, e
  publish ERROR
rescue => e
  logger.error e
  publish SERVER_ERROR, e
end