event_store_client 1.0.16 → 1.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d62066afdde555199d9c861d201fb6e0ce00e7aa1ab6e1b2f0082d1716162b0
4
- data.tar.gz: 5ef9fddbf08dfded189dd9d76f6e3d874e806563c234e126f07db9936aa186e8
3
+ metadata.gz: f5eebe6985468ff2cd381dd397f0e30ff5459f3cc783f2f24ec3af8e489e52cd
4
+ data.tar.gz: 2d6654fcf4aede64b32f6ae9a9b9390f09ed714917d3cb87157581791f4b97f1
5
5
  SHA512:
6
- metadata.gz: 194e9e53e41971b37611bd888b2421580ad36b650bedcd99a4ae501c7cc531efc0f4ed7b694f9c4259eb2420820a84f7cb27331bd70b262faefcad856f85ba00
7
- data.tar.gz: b5f1e84bb0aec686825263842ac2ad756150afee6dda5a87e6f40157e8b2b6062c6d4918d3913e96900fa40c356e5ff76f52ede239eeb96b70069bafd9d0ad2c
6
+ metadata.gz: 7c08741b831569f05bc6016484ef4f22d36a371c63d57d76ad29fc9ed9ae1fed82e06abd9e511705c9585ef7d5e4868ad41de488822e4b9ade066272f26f4334
7
+ data.tar.gz: d7141f9192166b232fbe73f47dfa994ea79f4b155b75ae436f13b2d979b1460341f2829bed97dd3e7388c7f0daf36fad4c08813b823ba90d9bebf10026972754
@@ -98,7 +98,10 @@ module EventStoreClient
98
98
  # @return Dry::Monads::Result::Success or Dry::Monads::Result::Failure
99
99
  #
100
100
  def join_streams(name, streams)
101
- Commands::Projections::Create.new.call(name, streams)
101
+ res = Commands::Projections::Create.new.call(name, streams)
102
+ return if res.success?
103
+
104
+ Commands::Projections::Update.new.call(name, streams)
102
105
  end
103
106
 
104
107
  # @api private
@@ -12,7 +12,7 @@ module EventStoreClient
12
12
  def self.inherited(klass)
13
13
  super
14
14
  klass.class_eval do
15
- include Dry::Monads[:result]
15
+ include Dry::Monads[:try, :result]
16
16
 
17
17
  def self.use_request(request_klass)
18
18
  CommandRegistrar.register_request(self, request: request_klass)
@@ -33,8 +33,11 @@ module EventStoreClient
33
33
  }
34
34
  }
35
35
 
36
- service.create(request.new(options: options), metadata: metadata)
37
- Success()
36
+ res = Try do
37
+ service.create(request.new(options: options), metadata: metadata)
38
+ end
39
+
40
+ res.error? ? res.to_result : Success()
38
41
  rescue ::GRPC::Unknown => e
39
42
  Failure(:conflict) if e.message.include?('Conflict')
40
43
  end
@@ -30,7 +30,9 @@ module EventStoreClient
30
30
  name: name,
31
31
  emit_enabled: true
32
32
  }
33
+
33
34
  service.update(request.new(options: options), metadata: metadata)
35
+
34
36
  Success()
35
37
  rescue ::GRPC::AlreadyExists
36
38
  Failure(:conflict)
@@ -6,6 +6,7 @@ require 'event_store_client/adapters/http/commands/persistent_subscriptions/crea
6
6
  require 'event_store_client/adapters/http/commands/persistent_subscriptions/read'
7
7
 
8
8
  require 'event_store_client/adapters/http/commands/projections/create'
9
+ require 'event_store_client/adapters/http/commands/projections/update'
9
10
 
10
11
  require 'event_store_client/adapters/http/commands/streams/append'
11
12
  require 'event_store_client/adapters/http/commands/streams/delete'
@@ -137,7 +137,10 @@ module EventStoreClient
137
137
  # @return Dry::Monads::Result::Success or Dry::Monads::Result::Failure
138
138
  #
139
139
  def join_streams(name, streams, options: {})
140
- Commands::Projections::Create.new(connection).call(name, streams, options: options)
140
+ res = Commands::Projections::Create.new(connection).call(name, streams, options: options)
141
+ return res if res.success?
142
+
143
+ Commands::Projections::Update.new(connection).call(name, streams, options: options)
141
144
  end
142
145
 
143
146
  # @api private
@@ -16,12 +16,15 @@ module EventStoreClient
16
16
  })
17
17
  STRING
18
18
 
19
- connection.call(
19
+
20
+ res = connection.call(
20
21
  :post,
21
22
  "/projections/continuous?name=#{name}&type=js&enabled=yes&emit=true&trackemittedstreams=true", # rubocop:disable Metrics/LineLength
22
23
  body: data,
23
24
  headers: {}
24
25
  )
26
+
27
+ (200...300).cover?(res.status) ? Success() : Failure(res)
25
28
  end
26
29
  end
27
30
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EventStoreClient
4
+ module HTTP
5
+ module Commands
6
+ module Projections
7
+ class Update < Command
8
+ def call(name, streams, options: {})
9
+ data =
10
+ <<~STRING
11
+ fromStreams(#{streams})
12
+ .when({
13
+ $any: function(s,e) {
14
+ linkTo("#{name}", e)
15
+ }
16
+ })
17
+ STRING
18
+ res = connection.call(
19
+ :put,
20
+ "/projection/#{name}/query?type=js&enabled=yes&emit=true&trackemittedstreams=true", # rubocop:disable Metrics/LineLength
21
+ body: data,
22
+ headers: {}
23
+ )
24
+
25
+ (200...300).cover?(res.status) ? Success() : Failure(res)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EventStoreClient
4
- VERSION = '1.0.16'
4
+ VERSION = '1.0.17'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_store_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.16
4
+ version: 1.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Wilgosz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-31 00:00:00.000000000 Z
11
+ date: 2021-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable
@@ -198,6 +198,7 @@ files:
198
198
  - lib/event_store_client/adapters/http/commands/persistent_subscriptions/create.rb
199
199
  - lib/event_store_client/adapters/http/commands/persistent_subscriptions/read.rb
200
200
  - lib/event_store_client/adapters/http/commands/projections/create.rb
201
+ - lib/event_store_client/adapters/http/commands/projections/update.rb
201
202
  - lib/event_store_client/adapters/http/commands/streams/append.rb
202
203
  - lib/event_store_client/adapters/http/commands/streams/delete.rb
203
204
  - lib/event_store_client/adapters/http/commands/streams/link_to.rb
@@ -244,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
245
  - !ruby/object:Gem::Version
245
246
  version: '0'
246
247
  requirements: []
247
- rubygems_version: 3.0.6
248
+ rubygems_version: 3.1.4
248
249
  signing_key:
249
250
  specification_version: 4
250
251
  summary: Ruby integration for https://eventstore.org