Class: Gcpc::Subscriber::SubscriptionClient
- Inherits:
-
Object
- Object
- Gcpc::Subscriber::SubscriptionClient
- Defined in:
- lib/gcpc/subscriber/subscription_client.rb
Constant Summary collapse
- DEFAULT_CONNECT_TIMEOUT =
5
Instance Method Summary collapse
- #get ⇒ Google::Cloud::Pubsub::Subscription
-
#initialize(project_id:, subscription_name:, credentials:, emulator_host:, connect_timeout: DEFAULT_CONNECT_TIMEOUT) ⇒ SubscriptionClient
constructor
A new instance of SubscriptionClient.
Constructor Details
#initialize(project_id:, subscription_name:, credentials:, emulator_host:, connect_timeout: DEFAULT_CONNECT_TIMEOUT) ⇒ SubscriptionClient
Returns a new instance of SubscriptionClient.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/gcpc/subscriber/subscription_client.rb', line 12 def initialize(project_id:, subscription_name:, credentials:, emulator_host:, connect_timeout: DEFAULT_CONNECT_TIMEOUT) project = Google::Cloud::Pubsub.new( project_id: project_id, credentials: credentials, emulator_host: emulator_host, ) @project = project @subscription_name = subscription_name @connect_timeout = connect_timeout end |
Instance Method Details
#get ⇒ Google::Cloud::Pubsub::Subscription
24 25 26 27 28 29 30 31 32 |
# File 'lib/gcpc/subscriber/subscription_client.rb', line 24 def get t = nil Timeout.timeout(@connect_timeout) do t = @project.subscription(@subscription_name) end t rescue Timeout::Error => e raise "Getting subscription \"#{@subscription_name}\" from project \"#{@project.project_id}\" timed out!" end |