emanator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +1 -0
- data/emanator.gemspec +26 -0
- data/lib/emanator.rb +32 -0
- data/lib/emanator/version.rb +5 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c7ea9c57b950ab0465c7b27492d956fb7dc125d8
|
4
|
+
data.tar.gz: 77d8d0747234f98984e89011be02adaa95eb602a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bdb6a7dbde2285fb6e6473de873b1d2c4a30e82cda9501e14347eedd054bb2f4443e82f67b98a6ab750ad714f44db3f59a6cdc9936ce6ba41e5c0e4b121b9786
|
7
|
+
data.tar.gz: 8b9f58e6a74e1ef2db6840c10a879d8c70c6dc9bbb7c48d72818736b6e5a2810ffe47f649c664747211a83a6a60cbaa8d0681f25554c5b0ae0072d60ab1bd56b
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Frank Murphy
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
wip - logical view replication of a postgres database via CDC
|
data/emanator.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'emanator/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'emanator'
|
9
|
+
spec.version = Emanator::VERSION
|
10
|
+
spec.authors = ['Frank Murphy']
|
11
|
+
spec.email = ['fmurphy@instructure.com']
|
12
|
+
|
13
|
+
spec.summary = 'incremental updates of materialized views'
|
14
|
+
spec.description = 'incremental updates of materialized views'
|
15
|
+
spec.homepage = 'https://github.com/anirishduck/emanator.rb'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.bindir = 'bin'
|
22
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_dependency 'sql-parser', '~> 0.0.2'
|
26
|
+
end
|
data/lib/emanator.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sql-parser'
|
4
|
+
|
5
|
+
include SqlParser::Statement
|
6
|
+
|
7
|
+
module Emanator
|
8
|
+
class Replica
|
9
|
+
def initialize(target, view)
|
10
|
+
@target = target
|
11
|
+
@view = view
|
12
|
+
parser = SQLParser::Parser.new
|
13
|
+
@ast = parser.scan_str(view)
|
14
|
+
end
|
15
|
+
|
16
|
+
def operate(change)
|
17
|
+
match(@ast, DirectSelect => select(@ast.query_expression, change))
|
18
|
+
end
|
19
|
+
|
20
|
+
def select(query, change)
|
21
|
+
match(query, Select =>
|
22
|
+
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
def process(change_data)
|
27
|
+
[
|
28
|
+
"UPDATE emanator_progress SET txid = #{change_data.txid}"
|
29
|
+
]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: emanator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Frank Murphy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-10-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sql-parser
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.2
|
27
|
+
description: incremental updates of materialized views
|
28
|
+
email:
|
29
|
+
- fmurphy@instructure.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- Gemfile
|
35
|
+
- LICENSE.txt
|
36
|
+
- README.md
|
37
|
+
- emanator.gemspec
|
38
|
+
- lib/emanator.rb
|
39
|
+
- lib/emanator/version.rb
|
40
|
+
homepage: https://github.com/anirishduck/emanator.rb
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata: {}
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.5.2.3
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: incremental updates of materialized views
|
64
|
+
test_files: []
|