Class: EventStoreClient::GRPC::Commands::Projections::Create

Inherits:
Command
  • Object
show all
Defined in:
lib/event_store_client/adapters/grpc/commands/projections/create.rb

Instance Method Summary collapse

Methods inherited from Command

inherited, #metadata

Methods included from Configuration

#config

Instance Method Details

#call(name, streams) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/event_store_client/adapters/grpc/commands/projections/create.rb', line 17

def call(name, streams)
  data = "    fromStreams(\#{streams})\n    .when({\n      $any: function(s,e) {\n        linkTo(\"\#{name}\", e)\n      }\n    })\n  STRING\n\n  options =\n    {\n      query: data,\n      continuous: {\n        name: name,\n        track_emitted_streams: true\n      }\n    }\n\n  service.create(request.new(options: options), metadata: metadata)\n  Success()\nrescue ::GRPC::Unknown => e\n  Failure(:conflict) if e.message.include?('Conflict')\nend\n"