Class: EventStoreClient::GRPC::Commands::Command
- Inherits:
-
Object
- Object
- EventStoreClient::GRPC::Commands::Command
- Includes:
- Configuration
- 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(**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.
Methods included from Configuration
Constructor Details
#initialize(**conn_options) ⇒ Command
Returns a new instance of Command.
28 29 30 |
# File 'lib/event_store_client/adapters/grpc/commands/command.rb', line 28 def initialize(**) @connection = EventStoreClient::GRPC::Connection.new(**) 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.
33 34 35 |
# File 'lib/event_store_client/adapters/grpc/commands/command.rb', line 33 def call raise NotImplementedError end |
#connection_options ⇒ Hash
Returns connection options' hash.
58 59 60 |
# File 'lib/event_store_client/adapters/grpc/commands/command.rb', line 58 def @connection. end |
#metadata ⇒ Hash
38 39 40 41 42 43 44 |
# File 'lib/event_store_client/adapters/grpc/commands/command.rb', line 38 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.
48 49 50 |
# File 'lib/event_store_client/adapters/grpc/commands/command.rb', line 48 def request CommandRegistrar.request(self.class) end |
#service ⇒ Object
Returns GRPC request stub class. E.g. EventStore::Client::Streams::Streams::Stub.
53 54 55 |
# File 'lib/event_store_client/adapters/grpc/commands/command.rb', line 53 def service connection.call(CommandRegistrar.service(self.class)) end |