evt-event_source-event_store-http 0.3.2.0 → 0.3.3.0
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2da5ff3d1c6852715b6c30e6fd25dab89933ea5f
|
4
|
+
data.tar.gz: b47ee0428a91bd8a6b4aa8c74d227d09b318406f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1577eed85af7c0c4750bc41b18cc96c3ad849a575e0dc5ac230856445a48cb41065e1e669b4f523fcce2d6515f87a48f41c4286a50676ea332b11317a84a02d5
|
7
|
+
data.tar.gz: 509e26f3c1436494f2a0ff1df4e11be3f686659a462c953b070c5390a73b4b45e8b4a6432bc86ac3eb187d301c18453d8f6328650ccf52492b9bbef73261d0f1
|
@@ -8,6 +8,7 @@ require 'event_source/event_store/http/stream_name'
|
|
8
8
|
|
9
9
|
require 'event_source/event_store/http/get'
|
10
10
|
require 'event_source/event_store/http/get/assertions'
|
11
|
+
require 'event_source/event_store/http/get/last'
|
11
12
|
require 'event_source/event_store/http/get/result'
|
12
13
|
|
13
14
|
require 'event_source/event_store/http/put'
|
@@ -12,13 +12,15 @@ module EventSource
|
|
12
12
|
@precedence ||= Defaults.precedence
|
13
13
|
end
|
14
14
|
|
15
|
-
dependency :session, Session
|
16
15
|
dependency :read_stream, ::EventStore::HTTP::ReadStream
|
16
|
+
dependency :session, Session
|
17
17
|
|
18
18
|
def self.build(batch_size: nil, precedence: nil, long_poll_duration: nil, session: nil)
|
19
19
|
instance = new batch_size, precedence, long_poll_duration
|
20
|
-
|
20
|
+
|
21
|
+
session = Session.configure instance, session: session
|
21
22
|
::EventStore::HTTP::ReadStream.configure instance, session: session
|
23
|
+
|
22
24
|
instance.configure
|
23
25
|
instance
|
24
26
|
end
|
@@ -38,6 +40,8 @@ module EventSource
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def call(stream_name, position: nil)
|
43
|
+
stream_name = StreamName.canonize stream_name
|
44
|
+
|
41
45
|
logger.trace { "Reading stream (StreamName: #{stream_name}, Position: #{position || '(start)'}, Direction: #{direction}, BatchSize: #{batch_size})" }
|
42
46
|
|
43
47
|
if precedence == :desc
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module EventSource
|
2
|
+
module EventStore
|
3
|
+
module HTTP
|
4
|
+
class Get
|
5
|
+
class Last
|
6
|
+
include Log::Dependency
|
7
|
+
|
8
|
+
configure :get
|
9
|
+
|
10
|
+
dependency :read_stream, ::EventStore::HTTP::ReadStream
|
11
|
+
dependency :session, Session
|
12
|
+
|
13
|
+
def self.build(session: nil)
|
14
|
+
instance = new
|
15
|
+
instance.configure session: session
|
16
|
+
instance
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.call(stream_name, **build_arguments)
|
20
|
+
instance = build **build_arguments
|
21
|
+
instance.(stream_name)
|
22
|
+
end
|
23
|
+
|
24
|
+
def configure(session: nil)
|
25
|
+
session = Session.configure self, session: session
|
26
|
+
|
27
|
+
read_stream = ::EventStore::HTTP::ReadStream.configure(
|
28
|
+
self,
|
29
|
+
session: session
|
30
|
+
)
|
31
|
+
|
32
|
+
read_stream.embed_body
|
33
|
+
read_stream.output_schema = Result
|
34
|
+
end
|
35
|
+
|
36
|
+
def call(stream_name)
|
37
|
+
stream_name = StreamName.canonize stream_name
|
38
|
+
|
39
|
+
logger.trace { "Getting last event of stream (StreamName: #{stream_name})" }
|
40
|
+
|
41
|
+
begin
|
42
|
+
last_event, * = read_stream.(
|
43
|
+
stream_name,
|
44
|
+
position: :head,
|
45
|
+
direction: :backward,
|
46
|
+
batch_size: 1
|
47
|
+
)
|
48
|
+
rescue ::EventStore::HTTP::ReadStream::StreamNotFoundError
|
49
|
+
end
|
50
|
+
|
51
|
+
logger.debug { "Got last event of stream (StreamName: #{stream_name}, EventType: #{event&.type.inspect}, Position: #{event&.position.inspect}, GlobalPosition: #{event&.global_position.inspect})" }
|
52
|
+
|
53
|
+
last_event
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -3,7 +3,7 @@ module EventSource
|
|
3
3
|
module HTTP
|
4
4
|
module StreamName
|
5
5
|
def self.canonize(stream_or_stream_name)
|
6
|
-
stream = EventSource::Stream.
|
6
|
+
stream = EventSource::Stream.build stream_or_stream_name
|
7
7
|
|
8
8
|
if stream.category?
|
9
9
|
category_stream_name stream.name
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt-event_source-event_store-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-event_source
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- lib/event_source/event_store/http/controls/write.rb
|
73
73
|
- lib/event_source/event_store/http/get.rb
|
74
74
|
- lib/event_source/event_store/http/get/assertions.rb
|
75
|
+
- lib/event_source/event_store/http/get/last.rb
|
75
76
|
- lib/event_source/event_store/http/get/result.rb
|
76
77
|
- lib/event_source/event_store/http/log.rb
|
77
78
|
- lib/event_source/event_store/http/put.rb
|