Class: Aidp::Temporal::Connection
- Inherits:
-
Object
- Object
- Aidp::Temporal::Connection
- Defined in:
- lib/aidp/temporal/connection.rb
Overview
Manages Temporal client connections Handles connection pooling, configuration, and lifecycle
Constant Summary collapse
- DEFAULT_TARGET_HOST =
"localhost:7233"- DEFAULT_NAMESPACE =
"default"
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#close ⇒ Object
Close the connection.
-
#connect ⇒ Object
Get or create a connected client Thread-safe lazy initialization.
-
#connected? ⇒ Boolean
Check if connected.
-
#initialize(config = {}) ⇒ Connection
constructor
A new instance of Connection.
-
#namespace ⇒ Object
Get namespace.
-
#target_host ⇒ Object
Get target host.
Constructor Details
#initialize(config = {}) ⇒ Connection
Returns a new instance of Connection.
15 16 17 18 19 |
# File 'lib/aidp/temporal/connection.rb', line 15 def initialize(config = {}) @config = normalize_config(config) @client = nil @mutex = Mutex.new end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
13 14 15 |
# File 'lib/aidp/temporal/connection.rb', line 13 def client @client end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/aidp/temporal/connection.rb', line 13 def config @config end |
Instance Method Details
#close ⇒ Object
Close the connection
35 36 37 38 39 |
# File 'lib/aidp/temporal/connection.rb', line 35 def close @mutex.synchronize do @client = nil end end |
#connect ⇒ Object
Get or create a connected client Thread-safe lazy initialization
23 24 25 26 27 |
# File 'lib/aidp/temporal/connection.rb', line 23 def connect @mutex.synchronize do @client ||= create_client end end |
#connected? ⇒ Boolean
Check if connected
30 31 32 |
# File 'lib/aidp/temporal/connection.rb', line 30 def connected? @mutex.synchronize { !@client.nil? } end |
#namespace ⇒ Object
Get namespace
47 48 49 |
# File 'lib/aidp/temporal/connection.rb', line 47 def namespace @config[:namespace] end |
#target_host ⇒ Object
Get target host
42 43 44 |
# File 'lib/aidp/temporal/connection.rb', line 42 def target_host @config[:target_host] end |