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 +4 -4
- data/lib/event_store_client/adapters/grpc/client.rb +4 -1
- data/lib/event_store_client/adapters/grpc/commands/command.rb +1 -1
- data/lib/event_store_client/adapters/grpc/commands/projections/create.rb +5 -2
- data/lib/event_store_client/adapters/grpc/commands/projections/update.rb +2 -0
- data/lib/event_store_client/adapters/http.rb +1 -0
- data/lib/event_store_client/adapters/http/client.rb +4 -1
- data/lib/event_store_client/adapters/http/commands/projections/create.rb +4 -1
- data/lib/event_store_client/adapters/http/commands/projections/update.rb +31 -0
- data/lib/event_store_client/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5eebe6985468ff2cd381dd397f0e30ff5459f3cc783f2f24ec3af8e489e52cd
|
4
|
+
data.tar.gz: 2d6654fcf4aede64b32f6ae9a9b9390f09ed714917d3cb87157581791f4b97f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
37
|
-
|
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
|
@@ -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
|
-
|
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
|
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.
|
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-
|
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.
|
248
|
+
rubygems_version: 3.1.4
|
248
249
|
signing_key:
|
249
250
|
specification_version: 4
|
250
251
|
summary: Ruby integration for https://eventstore.org
|