Class: Pubilion::Config

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

Overview

Configuration for Pubilion

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.credentialsString?

Credentials file path for access to Cloud Pub/Sub. If not set, it will try to get from environment variable GOOGLE_APPLICATION_CREDENTIALS. If not set and GOOGLE_APPLICATION_CREDENTIALS is not set, it will implicitly set by Google Cloud SDK.

Returns:

  • (String, nil)


38
39
40
# File 'lib/pubilion/config.rb', line 38

def credentials
  @credentials ||= ENV.fetch("GOOGLE_APPLICATION_CREDENTIALS", nil)
end

.project_idString?

Google Cloud Project ID. If it is not set, it will try to get from environment variable PUBSUB_PROJECT_ID. If it still unsettled, implicitly set by Google Cloud SDK.

Returns:

  • (String, nil)


29
30
31
# File 'lib/pubilion/config.rb', line 29

def project_id
  @project_id ||= ENV.fetch("PUBSUB_PROJECT_ID", nil)
end

.subscriptionString?

Subscription name. If not set, it will try to get from PUBSUB_SUBSCRIPTION. This configuration is required for Pubilion::Worker.

Returns:

  • (String, nil)


56
57
58
# File 'lib/pubilion/config.rb', line 56

def subscription
  @subscription ||= ENV.fetch("PUBSUB_SUBSCRIPTION", nil)
end

.topicString?

Topic name of subscription. If not set, it will try to get from PUBSUB_TOPIC. This configuration is required for Pubilion::Worker.

Returns:

  • (String, nil)


47
48
49
# File 'lib/pubilion/config.rb', line 47

def topic
  @topic ||= ENV.fetch("PUBSUB_TOPIC", nil)
end

Class Method Details

.configure {|config| ... } ⇒ void

This method returns an undefined value.

Configure Pubilion.

Examples:

Pubilion::Config.configure do |config|
  config.project_id = "my-project"
  config.credentials = "/path/to/credentials.json"
  config.topic = "my-topic"
  config.subscription = "my-subscription"
end

Yields:

  • (config)

    Configuration object



20
21
22
# File 'lib/pubilion/config.rb', line 20

def configure
  yield self
end