Class: TQ::QueueSpec

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of QueueSpec.



101
102
103
104
105
106
107
108
# File 'lib/tq.rb', line 101

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.



100
101
102
# File 'lib/tq.rb', line 100

def lease_duration
  @lease_duration
end

#locationObject (readonly)

Returns the value of attribute location.



100
101
102
# File 'lib/tq.rb', line 100

def location
  @location
end

#max_tasksObject (readonly)

Returns the value of attribute max_tasks.



100
101
102
# File 'lib/tq.rb', line 100

def max_tasks
  @max_tasks
end

#nameObject (readonly)

Returns the value of attribute name.



100
101
102
# File 'lib/tq.rb', line 100

def name
  @name
end

#projectObject (readonly)

Returns the value of attribute project.



100
101
102
# File 'lib/tq.rb', line 100

def project
  @project
end

Class Method Details

.from_hash(data) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/tq.rb', line 88

def self.from_hash(data)
  return new( 
    data['project'], 
    data['location'], 
    data['name'],
    **( { lease_duration: data['lease_duration'],
          max_tasks: data['max_tasks']
        }.reject {|k,v| v.nil?}
      )
   )
end

Instance Method Details

#queue_nameObject



110
111
112
# File 'lib/tq.rb', line 110

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