Class: EventStoreClient::GRPC::Commands::Command
- Inherits:
-
Object
- Object
- EventStoreClient::GRPC::Commands::Command
- Defined in:
- lib/event_store_client/adapters/grpc/commands/command.rb
Direct Known Subclasses
Gossip::ClusterInfo, Streams::Append, Streams::AppendMultiple, Streams::Delete, Streams::HardDelete, Streams::LinkTo, Streams::LinkToMultiple, Streams::Read, Streams::ReadPaginated, Streams::Subscribe
Class Method Summary collapse
Instance Method Summary collapse
-
#call ⇒ Object
Override it in your implementation of command.
-
#connection_options ⇒ Hash
Connection options’ hash.
-
#initialize(config:, **conn_options) ⇒ Command
constructor
A new instance of Command.
- #metadata ⇒ Hash
-
#request ⇒ Object
GRPC params class to be used in the request.
-
#service ⇒ Object
GRPC request stub class.
Constructor Details
#initialize(config:, **conn_options) ⇒ Command
Returns a new instance of Command.
26 27 28 29 |
# File 'lib/event_store_client/adapters/grpc/commands/command.rb', line 26 def initialize(config:, **) @config = config @connection = EventStoreClient::GRPC::Connection.new(config: config, **) end |
Class Method Details
.use_request(request_klass) ⇒ Object
8 9 10 |
# File 'lib/event_store_client/adapters/grpc/commands/command.rb', line 8 def use_request(request_klass) CommandRegistrar.register_request(self, request: request_klass) end |
.use_service(service_klass) ⇒ Object
12 13 14 |
# File 'lib/event_store_client/adapters/grpc/commands/command.rb', line 12 def use_service(service_klass) CommandRegistrar.register_service(self, service: service_klass) end |
Instance Method Details
#call ⇒ Object
Override it in your implementation of command.
32 33 34 |
# File 'lib/event_store_client/adapters/grpc/commands/command.rb', line 32 def call raise NotImplementedError end |
#connection_options ⇒ Hash
Returns connection options’ hash.
57 58 59 |
# File 'lib/event_store_client/adapters/grpc/commands/command.rb', line 57 def @connection. end |
#metadata ⇒ Hash
37 38 39 40 41 42 43 |
# File 'lib/event_store_client/adapters/grpc/commands/command.rb', line 37 def return {} unless connection.class.secure? credentials = Base64.encode64("#{connection.username}:#{connection.password}").delete("\n") { 'authorization' => "Basic #{credentials}" } end |
#request ⇒ Object
Returns GRPC params class to be used in the request. E.g.EventStore::Client::Streams::ReadReq.
47 48 49 |
# File 'lib/event_store_client/adapters/grpc/commands/command.rb', line 47 def request CommandRegistrar.request(self.class) end |
#service ⇒ Object
Returns GRPC request stub class. E.g. EventStore::Client::Streams::Streams::Stub.
52 53 54 |
# File 'lib/event_store_client/adapters/grpc/commands/command.rb', line 52 def service connection.call(CommandRegistrar.service(self.class)) end |