evt-event_source-event_store-http 0.4.1.0 → 0.5.0.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: 2471ec549215e8ef715f9e98f8b35f29fab33e5c
4
- data.tar.gz: 65b4239536e53a32602a79271ba92863e80f50a4
3
+ metadata.gz: e234d3e5c4a4ac1c7be3dc92ca3db216d9d7af01
4
+ data.tar.gz: ae71e953b37fe95220da7e7e751e1c93c58030dd
5
5
  SHA512:
6
- metadata.gz: 84d19a26771167272496bea456fc7f45b2a71819e0b0ac7a58690a359f5f168e63ea19e2a638f7cbf7ebca1667fd47241078b738e61083d61f4af5001fe2f5d3
7
- data.tar.gz: 2824c4dffc8c26a8e25040dba435075e5d47fe9c4bd35d3d59cc07efabf4ada0c8d31e7c209b0c13c49daffe5b18326f2b61a0139945ef3fa1c225c0410c0ccf
6
+ metadata.gz: 0f6bebd66fcff3a2108ff13278fe0c6677c9ecc0c02a2cb886adbd90aff61393eb9990b264276b7395cabf35f9707c34b86ceea54c1a426aae1b3c0cb88446a3
7
+ data.tar.gz: e9a3bc9d3133769d90163037a737595303f1a49363277cb04ac4833999e6895a02d94d4fdebeb8f7aa7e9599f74dd7b8878eaf689509c1a67265754f3a174287
@@ -6,17 +6,13 @@ module EventSource
6
6
 
7
7
  configure :get
8
8
 
9
- initializer :batch_size, w(:precedence), a(:long_poll_duration)
10
-
11
- def precedence
12
- @precedence ||= Defaults.precedence
13
- end
9
+ initializer :batch_size, a(:long_poll_duration)
14
10
 
15
11
  dependency :read_stream, ::EventStore::HTTP::ReadStream
16
12
  dependency :session, Session
17
13
 
18
- def self.build(batch_size: nil, precedence: nil, long_poll_duration: nil, session: nil)
19
- instance = new batch_size, precedence, long_poll_duration
14
+ def self.build(batch_size: nil, long_poll_duration: nil, session: nil)
15
+ instance = new batch_size, long_poll_duration
20
16
 
21
17
  session = Session.configure instance, session: session
22
18
  ::EventStore::HTTP::ReadStream.configure instance, session: session
@@ -42,67 +38,22 @@ module EventSource
42
38
  def call(stream_name, position: nil)
43
39
  stream_name = StreamName.canonize stream_name
44
40
 
45
- logger.trace { "Reading stream (StreamName: #{stream_name}, Position: #{position || '(start)'}, Direction: #{direction}, BatchSize: #{batch_size})" }
46
-
47
- if precedence == :desc
48
- position = desc_position stream_name, position
49
-
50
- if position < 0
51
- logger.debug { "Reading backward across start of stream (StreamName: #{stream_name}, Position: #{position || '(start)'}, Direction: #{direction}, BatchSize: #{batch_size}, Events: 0)" }
52
- return []
53
- end
54
- end
41
+ logger.trace { "Reading stream (StreamName: #{stream_name}, Position: #{position || '(start)'}, BatchSize: #{batch_size})" }
55
42
 
56
43
  begin
57
44
  events = read_stream.(
58
45
  stream_name,
59
46
  position: position,
60
- direction: direction,
61
47
  batch_size: batch_size
62
48
  )
63
49
  rescue ::EventStore::HTTP::ReadStream::StreamNotFoundError
64
50
  events = []
65
51
  end
66
52
 
67
- events.reverse! if precedence == :desc
68
-
69
- logger.debug { "Done reading stream (StreamName: #{stream_name}, Position: #{position || '(start)'}, Direction: #{direction}, BatchSize: #{batch_size}, Events: #{events.count})" }
53
+ logger.debug { "Done reading stream (StreamName: #{stream_name}, Position: #{position || '(start)'}, BatchSize: #{batch_size}, Events: #{events.count})" }
70
54
 
71
55
  events
72
56
  end
73
-
74
- def desc_position(stream_name, position)
75
- begin
76
- head_event, * = read_stream.(
77
- stream_name,
78
- position: :head,
79
- direction: :backward,
80
- batch_size: 1
81
- )
82
- rescue ::EventStore::HTTP::ReadStream::StreamNotFoundError
83
- return -1
84
- end
85
-
86
- if position.nil?
87
- head_event.position
88
- else
89
- head_event.position - position
90
- end
91
- end
92
-
93
- def direction
94
- if precedence == :asc
95
- :forward
96
- else
97
- :backward
98
- end
99
- end
100
-
101
- module Defaults
102
- def self.precedence
103
- :asc
104
- end
105
- end
106
57
  end
107
58
  end
108
59
  end
@@ -4,31 +4,8 @@ module EventSource
4
4
  class Read
5
5
  include EventSource::Read
6
6
 
7
- def self.build(*)
8
- instance = super
9
- instance.configure_long_poll
10
- instance
11
- end
12
-
13
- def configure(batch_size: nil, precedence: nil, session: nil)
14
- Get.configure(
15
- self,
16
- batch_size: batch_size,
17
- precedence: precedence,
18
- session: session
19
- )
20
- end
21
-
22
- def configure_long_poll
23
- cycle = iterator.cycle
24
-
25
- return if cycle.instance_of? Cycle::None
26
-
27
- maximum_milliseconds = cycle.maximum_milliseconds
28
-
29
- long_poll_duration = Rational(maximum_milliseconds, 1000).ceil
30
-
31
- get.read_stream.enable_long_poll long_poll_duration
7
+ def configure(batch_size: nil, session: nil)
8
+ Get.configure self, batch_size: batch_size, session: session
32
9
  end
33
10
  end
34
11
  end
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.4.1.0
4
+ version: 0.5.0.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-25 00:00:00.000000000 Z
11
+ date: 2017-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-event_source