Class: EventStoreClient::GRPC::Connection

Inherits:
Object
  • Object
show all
Includes:
Extensions::OptionsExtension
Defined in:
lib/event_store_client/adapters/grpc/connection.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Extensions::OptionsExtension

included, #options_hash

Constructor Details

#initialize(config:, **options) ⇒ Connection

Returns a new instance of Connection.



56
57
58
59
# File 'lib/event_store_client/adapters/grpc/connection.rb', line 56

def initialize(config:, **options)
  @config = config
  super
end

Class Method Details

.new(config:, **options) ⇒ Object

Resolve which connection class we instantiate, based on config.eventstore_url.tls config option. If :new method is called from SecureConnection or InsecureConnection class - then that particular class will be instantiated despite on config.eventstore_url.tls config option. Example:

```ruby
config.eventstore_url.tls = true
Connection.new # => #<EventStoreClient::GRPC::Cluster::SecureConnection>

config.eventstore_url.tls = false
Connection.new # => #<EventStoreClient::GRPC::Cluster::InsecureConnection>

Cluster::SecureConnection.new
# => #<EventStoreClient::GRPC::Cluster::SecureConnection>
Cluster::InsecureConnection.new
# => #<EventStoreClient::GRPC::Cluster::InsecureConnection>
```

Parameters:



28
29
30
31
32
33
34
35
36
# File 'lib/event_store_client/adapters/grpc/connection.rb', line 28

def new(config:, **options)
  return super unless self == Connection

  if config.eventstore_url.tls
    Cluster::SecureConnection.new(config: config, **options)
  else
    Cluster::InsecureConnection.new(config: config, **options)
  end
end

.secure?Boolean

Checks if connection class is secure

Returns:

  • (Boolean)


40
41
42
# File 'lib/event_store_client/adapters/grpc/connection.rb', line 40

def secure?
  self == Cluster::SecureConnection
end

Instance Method Details

#call(stub_class) ⇒ Object

Raises:

  • (NotImplementedError)


61
62
63
# File 'lib/event_store_client/adapters/grpc/connection.rb', line 61

def call(stub_class)
  raise NotImplementedError
end