我正在尝试实施Sneakers,但我遇到了一些问题。您可以在下面找到订阅我的队列的代码和实际错误。
require 'sneakers'
require 'jwt'
require 'redis'
require 'json'
$redis = Redis.new(url: ENV['REDIS_URL'], password: ENV['REDIS_PASSWORD'])
class Processor
include Sneakers::Worker
QUEUE_NAME = :my_queue
from_queue QUEUE_NAME
def work(msg)
message = JSON.parse(msg)
if message["type"] == "error"
$redis.incr "processor:#{err["error"]}"
end
controller = Object.const_get message['controller']
action = message['method']
controller.public_send(action, message['msg'])
ack!
end
end
错误:
[Exception error="uninitialized constant V1" error_class=NameError worker_class=Processor
味精对象
{\"controller\":\"V1::x::yController\",\"method\":\"my_method"\}
欢迎任何帮助,谢谢!
更新
即使得到像我这样的简单模型User
也会导致同样的错误。
[Exception error="uninitialized constant User"
我正在像这样运行运动鞋工人:
sneakers work UserCreate --require app/workers/user_create.rb