evt-consumer-postgres 0.1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5d147e491fa712d35abeaebcc0c1f5e50156ba7d
4
+ data.tar.gz: 601b341ec4809e57634e242d9bad037d8837812d
5
+ SHA512:
6
+ metadata.gz: 1180f82832a6cdf5137d3a750faa1b89f87084a4a610df2e0cb8ad71a835f9a63afe589ebd76c5f8ccb3e30384054445e12d9dbffb027d132f6937168698e121
7
+ data.tar.gz: 3f6e858e159d64d0e96cd79800c2a3fb84f7e32b253fae33abd57fc5673843f9ba4c988d70006d916d17c81d89a4354bbc5e5f15b2a23405354295183a990809
@@ -0,0 +1,8 @@
1
+ require 'consumer'
2
+
3
+ require 'messaging/postgres'
4
+
5
+ require 'consumer/postgres/position_store'
6
+ require 'consumer/postgres/position_store/messages'
7
+ require 'consumer/postgres/position_store/stream_name'
8
+ require 'consumer/postgres/postgres'
@@ -0,0 +1,13 @@
1
+ require 'consumer/controls'
2
+
3
+ require 'event_source/postgres/controls'
4
+
5
+ require 'consumer/postgres/controls/category'
6
+ require 'consumer/postgres/controls/id'
7
+ require 'consumer/postgres/controls/event_data'
8
+ require 'consumer/postgres/controls/position'
9
+ require 'consumer/postgres/controls/position/store/message'
10
+ require 'consumer/postgres/controls/position/stream/write'
11
+ require 'consumer/postgres/controls/stream_name'
12
+
13
+ require 'consumer/postgres/controls/consumer'
@@ -0,0 +1,7 @@
1
+ module Consumer
2
+ module Postgres
3
+ module Controls
4
+ Category = EventSource::Postgres::Controls::Category
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ module Consumer
2
+ module Postgres
3
+ module Controls
4
+ module Consumer
5
+ class Example
6
+ include ::Consumer::Postgres
7
+ end
8
+
9
+ class Incrementing
10
+ include ::Consumer::Postgres
11
+
12
+ handler do |event_data|
13
+ logger.info { "Handled event (StreamName: #{event_data.stream_name}, GlobalPosition: #{event_data.global_position})" }
14
+ logger.debug { event_data.data.pretty_inspect }
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,7 @@
1
+ module Consumer
2
+ module Postgres
3
+ module Controls
4
+ EventData = ::Consumer::Controls::EventData
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Consumer
2
+ module Postgres
3
+ module Controls
4
+ ID = Identifier::UUID::Controls::Incrementing
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ module Consumer
2
+ module Postgres
3
+ module Controls
4
+ module Position
5
+ def self.example
6
+ 11
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ module Consumer
2
+ module Postgres
3
+ module Controls
4
+ module Position
5
+ module Store
6
+ module Message
7
+ def self.example(position: nil)
8
+ position ||= Position.example
9
+
10
+ message = PositionStore::Messages::PositionUpdated.new
11
+ message.position = position
12
+ message
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ module Consumer
2
+ module Postgres
3
+ module Controls
4
+ module Position
5
+ module Stream
6
+ module Write
7
+ def self.call(stream_name=nil, position: nil)
8
+ stream_name ||= StreamName::Position.example
9
+
10
+ message = Store::Message.example position: position
11
+
12
+ Messaging::Postgres::Write.(message, stream_name)
13
+
14
+ stream_name
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,33 @@
1
+ module Consumer
2
+ module Postgres
3
+ module Controls
4
+ StreamName = ::Consumer::Controls::StreamName
5
+
6
+ module StreamName
7
+ module Position
8
+ def self.example(id: nil, randomize_category: nil, types: nil)
9
+ types ||= []
10
+
11
+ types << 'position'
12
+
13
+ StreamName.example(
14
+ id: id,
15
+ randomize_category: randomize_category,
16
+ types: types
17
+ )
18
+ end
19
+
20
+ module Category
21
+ def self.example(category: nil)
22
+ category = Controls::Category.example category: category
23
+
24
+ position_type = 'position'
25
+
26
+ EventSource::Postgres::StreamName.stream_name category, type: position_type
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,49 @@
1
+ module Consumer
2
+ module Postgres
3
+ class PositionStore
4
+ include Consumer::PositionStore
5
+
6
+ initializer :stream_name
7
+
8
+ dependency :read, EventSource::Postgres::Get::Last
9
+ dependency :session, EventSource::Postgres::Session
10
+ dependency :write, ::Messaging::Postgres::Write
11
+
12
+ def self.build(stream_name, session: nil)
13
+ position_stream_name = StreamName.get stream_name
14
+
15
+ instance = new position_stream_name
16
+ EventSource::Postgres::Session.configure instance, session: session
17
+ instance.configure
18
+ instance
19
+ end
20
+
21
+ def configure
22
+ EventSource::Postgres::Get::Last.configure(
23
+ self,
24
+ session: session,
25
+ attr_name: :read
26
+ )
27
+
28
+ Messaging::Postgres::Write.configure self, session: session
29
+ end
30
+
31
+ def get
32
+ event_data = read.(stream_name)
33
+
34
+ return nil if event_data.nil?
35
+
36
+ message = Messaging::Message::Import.(event_data, Messages::PositionUpdated)
37
+
38
+ message.position
39
+ end
40
+
41
+ def put(position)
42
+ message = Messages::PositionUpdated.new
43
+ message.position = position
44
+
45
+ write.(message, stream_name)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,13 @@
1
+ module Consumer
2
+ module Postgres
3
+ class PositionStore
4
+ module Messages
5
+ class PositionUpdated
6
+ include Messaging::Message
7
+
8
+ attribute :position, Integer
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,29 @@
1
+ module Consumer
2
+ module Postgres
3
+ class PositionStore
4
+ module StreamName
5
+ def self.get(stream_name)
6
+ id = EventSource::Postgres::StreamName.get_id stream_name
7
+ entity = EventSource::Postgres::StreamName.get_entity_name stream_name
8
+ type_list = EventSource::Postgres::StreamName.get_types stream_name
9
+
10
+ position_type = Type.get
11
+
12
+ type_list << position_type unless type_list.include? position_type
13
+
14
+ EventSource::Postgres::StreamName.stream_name(
15
+ entity,
16
+ id,
17
+ types: type_list
18
+ )
19
+ end
20
+
21
+ module Type
22
+ def self.get
23
+ 'position'
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,24 @@
1
+ module Consumer
2
+ module Postgres
3
+ def self.included(cls)
4
+ cls.class_exec do
5
+ include ::Consumer
6
+ end
7
+ end
8
+
9
+ def configure(session: nil, batch_size: nil, position_store: nil)
10
+ EventSource::Postgres::Get.configure(
11
+ self,
12
+ session: session,
13
+ batch_size: batch_size
14
+ )
15
+
16
+ PositionStore.configure(
17
+ self,
18
+ stream_name,
19
+ position_store: position_store,
20
+ session: session
21
+ )
22
+ end
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: evt-consumer-postgres
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - The Eventide Project
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: evt-consumer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: evt-messaging-postgres
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test_bench
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: " "
56
+ email: opensource@eventide-project.org
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - lib/consumer/postgres.rb
62
+ - lib/consumer/postgres/controls.rb
63
+ - lib/consumer/postgres/controls/category.rb
64
+ - lib/consumer/postgres/controls/consumer.rb
65
+ - lib/consumer/postgres/controls/event_data.rb
66
+ - lib/consumer/postgres/controls/id.rb
67
+ - lib/consumer/postgres/controls/position.rb
68
+ - lib/consumer/postgres/controls/position/store/message.rb
69
+ - lib/consumer/postgres/controls/position/stream/write.rb
70
+ - lib/consumer/postgres/controls/stream_name.rb
71
+ - lib/consumer/postgres/position_store.rb
72
+ - lib/consumer/postgres/position_store/messages.rb
73
+ - lib/consumer/postgres/position_store/stream_name.rb
74
+ - lib/consumer/postgres/postgres.rb
75
+ homepage: https://github.com/eventide-project/consumer-postgres
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: 2.2.3
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.6.8
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Category and stream consumer for postgres
99
+ test_files: []