Class: OctaSpace::Client
- Inherits:
-
Object
- Object
- OctaSpace::Client
- Defined in:
- lib/octaspace/client.rb
Overview
Main entry point for the OctaSpace SDK
Aggregates all resource groups and constructs the appropriate HTTP transport based on configuration.
Instance Attribute Summary collapse
-
#accounts ⇒ Object
readonly
Returns the value of attribute accounts.
-
#apps ⇒ Object
readonly
Returns the value of attribute apps.
-
#idle_jobs ⇒ Object
readonly
Returns the value of attribute idle_jobs.
-
#network ⇒ Object
readonly
Returns the value of attribute network.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
-
#services ⇒ Object
readonly
Returns the value of attribute services.
-
#sessions ⇒ Object
readonly
Returns the value of attribute sessions.
Instance Method Summary collapse
-
#initialize(api_key: nil, transport: nil, **opts) ⇒ Client
constructor
A new instance of Client.
-
#shutdown ⇒ Object
Shut down persistent connections (only relevant in keep_alive mode).
-
#transport_stats ⇒ Hash
Transport diagnostics (pool stats when in keep_alive mode).
Constructor Details
#initialize(api_key: nil, transport: nil, **opts) ⇒ Client
Returns a new instance of Client.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/octaspace/client.rb', line 44 def initialize(api_key: nil, transport: nil, **opts) @config = build_config(api_key, opts) @transport = transport || build_transport @accounts = Resources::Accounts.new(@transport) @nodes = Resources::Nodes.new(@transport) @sessions = Resources::Sessions.new(@transport) @apps = Resources::Apps.new(@transport) @network = Resources::Network.new(@transport) @services = Resources::Services.new(@transport) @idle_jobs = Resources::IdleJobs.new(@transport) end |
Instance Attribute Details
#accounts ⇒ Object (readonly)
Returns the value of attribute accounts.
38 39 40 |
# File 'lib/octaspace/client.rb', line 38 def accounts @accounts end |
#apps ⇒ Object (readonly)
Returns the value of attribute apps.
38 39 40 |
# File 'lib/octaspace/client.rb', line 38 def apps @apps end |
#idle_jobs ⇒ Object (readonly)
Returns the value of attribute idle_jobs.
38 39 40 |
# File 'lib/octaspace/client.rb', line 38 def idle_jobs @idle_jobs end |
#network ⇒ Object (readonly)
Returns the value of attribute network.
38 39 40 |
# File 'lib/octaspace/client.rb', line 38 def network @network end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
38 39 40 |
# File 'lib/octaspace/client.rb', line 38 def nodes @nodes end |
#services ⇒ Object (readonly)
Returns the value of attribute services.
38 39 40 |
# File 'lib/octaspace/client.rb', line 38 def services @services end |
#sessions ⇒ Object (readonly)
Returns the value of attribute sessions.
38 39 40 |
# File 'lib/octaspace/client.rb', line 38 def sessions @sessions end |
Instance Method Details
#shutdown ⇒ Object
Shut down persistent connections (only relevant in keep_alive mode)
57 58 59 |
# File 'lib/octaspace/client.rb', line 57 def shutdown @transport.respond_to?(:shutdown) && @transport.shutdown end |
#transport_stats ⇒ Hash
Transport diagnostics (pool stats when in keep_alive mode)
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/octaspace/client.rb', line 63 def transport_stats if @transport.respond_to?(:transport_stats) @transport.transport_stats elsif @transport.respond_to?(:pool_stats) {mode: :persistent, pools: @transport.pool_stats} elsif @config.urls.size > 1 {mode: :standard, rotator: @transport.instance_variable_get(:@rotator)&.stats} else {mode: :standard, url: @config.urls.first} end end |