Class: TQ::QueueSpec

Inherits:
Object
  • Object
show all
Extended by:
Utils
Defined in:
lib/tq.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

options_including

Constructor Details

#initialize(project, location, name, lease_duration: '60s', max_tasks: 1) ⇒ QueueSpec

Returns a new instance of QueueSpec.



107
108
109
110
111
112
113
114
# File 'lib/tq.rb', line 107

def initialize(project, location, name,
               lease_duration: '60s', max_tasks: 1)
    @project = project
    @location = location
    @name = name
    @lease_duration = lease_duration
    @max_tasks = max_tasks
end

Instance Attribute Details

#lease_durationObject (readonly)

Returns the value of attribute lease_duration.



106
107
108
# File 'lib/tq.rb', line 106

def lease_duration
  @lease_duration
end

#locationObject (readonly)

Returns the value of attribute location.



106
107
108
# File 'lib/tq.rb', line 106

def location
  @location
end

#max_tasksObject (readonly)

Returns the value of attribute max_tasks.



106
107
108
# File 'lib/tq.rb', line 106

def max_tasks
  @max_tasks
end

#nameObject (readonly)

Returns the value of attribute name.



106
107
108
# File 'lib/tq.rb', line 106

def name
  @name
end

#projectObject (readonly)

Returns the value of attribute project.



106
107
108
# File 'lib/tq.rb', line 106

def project
  @project
end

Class Method Details

.from_hash(data) ⇒ Object



97
98
99
100
101
102
103
104
# File 'lib/tq.rb', line 97

def self.from_hash(data)
  return new( 
    data['project'], 
    data['location'], 
    data['name'],
    **options_including(['lease_duration','max_tasks'], data)
   )
end

Instance Method Details

#queue_nameObject



116
117
118
# File 'lib/tq.rb', line 116

def queue_name
  "projects/#{project}/locations/#{location}/queues/#{name}"
end