Module: Lita::External

Extended by:
External
Included in:
External
Defined in:
lib/lita/external.rb,
lib/lita/external/cli.rb,
lib/lita/external/robot.rb,
lib/lita/external/version.rb

Defined Under Namespace

Modules: CLI Classes: Robot

Constant Summary collapse

VERSION =
"0.1.2"

Instance Method Summary collapse

Instance Method Details

#blocking_redisObject

It’s important to use another redis connection than Lita’s one, because we are using long blocking calls and redis use a mutex around these



14
15
16
# File 'lib/lita/external.rb', line 14

def blocking_redis
  @blocking_redis ||= Redis::Namespace.new(Lita::REDIS_NAMESPACE, redis: Redis.new(Lita.config.redis))
end

#dump_message(message) ⇒ Object



18
19
20
21
22
23
# File 'lib/lita/external.rb', line 18

def dump_message(message)
  # The robot instance contains Proc and other non serializable attributes
  # Also, it's a singleton and should be set again in the receiving process anyway
  message.instance_variable_set(:@robot, nil)
  Marshal.dump(message)
end

#load_message(payload, robot:) ⇒ Object



25
26
27
28
29
# File 'lib/lita/external.rb', line 25

def load_message(payload, robot: )
  message = Marshal.load(payload)
  message.instance_variable_set(:@robot, robot)
  message
end