Class: RailsCloudTasks::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_engine = AppEngine, google_auth = Google::Auth) ⇒ Configuration

Returns a new instance of Configuration.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rails_cloud_tasks/configuration.rb', line 9

def initialize(app_engine = AppEngine, google_auth = Google::Auth)
  @service_account_email = ENV['GCP_SERVICE_ACCOUNT']
  @location_id = ENV['GCP_LOCATION']
  @project_id = ENV['GCP_PROJECT']
  @host = ENV['GCP_APP_ENDPOINT']
  @tasks_path = '/tasks'
  @scheduler_file_path = './config/scheduler.yml'
  @scheduler_prefix_name = 'rails-cloud'

  @app_engine = app_engine
  @google_auth = google_auth
end

Instance Attribute Details

#app_engineObject (readonly)

Returns the value of attribute app_engine.



7
8
9
# File 'lib/rails_cloud_tasks/configuration.rb', line 7

def app_engine
  @app_engine
end

#google_authObject (readonly)

Returns the value of attribute google_auth.



7
8
9
# File 'lib/rails_cloud_tasks/configuration.rb', line 7

def google_auth
  @google_auth
end

#hostObject

Returns the value of attribute host.



3
4
5
# File 'lib/rails_cloud_tasks/configuration.rb', line 3

def host
  @host
end

#location_idObject

Returns the value of attribute location_id.



3
4
5
# File 'lib/rails_cloud_tasks/configuration.rb', line 3

def location_id
  @location_id
end

#project_idObject



31
32
33
# File 'lib/rails_cloud_tasks/configuration.rb', line 31

def project_id
  @project_id ||= app_engine.project_id
end

#scheduler_file_pathObject

Returns the value of attribute scheduler_file_path.



3
4
5
# File 'lib/rails_cloud_tasks/configuration.rb', line 3

def scheduler_file_path
  @scheduler_file_path
end

#scheduler_prefix_nameObject

Returns the value of attribute scheduler_prefix_name.



3
4
5
# File 'lib/rails_cloud_tasks/configuration.rb', line 3

def scheduler_prefix_name
  @scheduler_prefix_name
end

#service_account_emailObject

Returns the value of attribute service_account_email.



3
4
5
# File 'lib/rails_cloud_tasks/configuration.rb', line 3

def 
  @service_account_email
end

#tasks_pathObject

Returns the value of attribute tasks_path.



3
4
5
# File 'lib/rails_cloud_tasks/configuration.rb', line 3

def tasks_path
  @tasks_path
end

Instance Method Details

#authObject



35
36
37
# File 'lib/rails_cloud_tasks/configuration.rb', line 35

def auth
  @auth ||= authenticate
end

#inject_routesObject



22
23
24
25
26
27
28
29
# File 'lib/rails_cloud_tasks/configuration.rb', line 22

def inject_routes
  tasks_path = @tasks_path

  Rails.application.routes.append do
    post "#{tasks_path}/:job_class", to: RailsCloudTasks::Rack::Jobs
    post tasks_path, to: RailsCloudTasks::Rack::Tasks
  end
end