Module: CarrotRpc::ClientServer

Included in:
RpcClient, RpcServer
Defined in:
lib/carrot_rpc/client_server.rb

Overview

Common functionality for Client and Server.

Instance Method Summary collapse

Instance Method Details

#queue_name(new_name) ⇒ String #queue_nameString

Overloads:

  • #queue_name(new_name) ⇒ String
    Note:

    Default naming not performed. Class must pass queue name.

    Allows for class level definition of queue name.

    Parameters:

    • new_name (String)

      the queue name for the class.

    Returns:

    • (String)

      ‘new_name`

  • #queue_nameString

    The current queue name previously set with ‘#queue_name(new_name)`.

    Returns:

    • (String)


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/carrot_rpc/client_server.rb', line 15

def queue_name(*args)
  if args.length == 0
    @queue_name
  elsif args.length == 1
    @queue_name = args[0]
  else
    fail ArgumentError,
         "queue_name(new_name) :: new_name or queue_name() :: " \
         "current_name are the only ways to call queue_name"
  end
end

#queue_options(options) ⇒ Object #queue_optionsHash

Overloads:

  • #queue_options(options) ⇒ Object

    Allows for custom queue options, such as durable.

  • #queue_optionsHash

    The current queue options previously set with ‘#queue_options(options)`.

    Returns:

    • (Hash)


37
38
39
40
41
42
43
44
45
46
47
# File 'lib/carrot_rpc/client_server.rb', line 37

def queue_options(*args)
  if args.length == 0
    @queue_options || {}
  elsif args.length == 1
    @queue_options = args[0]
  else
    fail ArgumentError,
         "queue_options(options) :: options or queue_options() :: " \
         "current_options are the only ways to call queue_options"
  end
end

#test_queue_name(name, append_name = false) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/carrot_rpc/client_server.rb', line 49

def test_queue_name(name, append_name = false)
  return name unless append_name
  if name
    "#{name}_test"
  else
    fail CarrotRpc::Exception::InvalidQueueName
  end
end