eventq_base 1.15.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/eventq_base/serialization_providers.rb +6 -3
- data/lib/eventq_base/serialization_providers/jruby.rb +2 -0
- data/lib/eventq_base/serialization_providers/jruby/oj.rb +10 -0
- data/lib/eventq_base/serialization_providers/jruby/oj/array_writer.rb +20 -0
- data/lib/eventq_base/serialization_providers/jruby/oj/attribute_writer.rb +24 -0
- data/lib/eventq_base/serialization_providers/jruby/oj/class_writer.rb +20 -0
- data/lib/eventq_base/serialization_providers/jruby/oj/date_time_writer.rb +33 -0
- data/lib/eventq_base/serialization_providers/jruby/oj/date_writer.rb +22 -0
- data/lib/eventq_base/serialization_providers/jruby/oj/hash_writer.rb +18 -0
- data/lib/eventq_base/serialization_providers/jruby/oj/rational_writer.rb +20 -0
- data/lib/eventq_base/serialization_providers/jruby/oj/serializer.rb +17 -0
- data/lib/eventq_base/serialization_providers/jruby/oj/time_writer.rb +18 -0
- data/lib/eventq_base/serialization_providers/jruby/oj/value_writer.rb +16 -0
- data/lib/eventq_base/serialization_providers/jruby/oj_serialization_provider.rb +25 -0
- data/lib/eventq_base/version.rb +1 -1
- metadata +15 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7bc52253b5e75c043fcdb12327c7ebdda89d225
|
4
|
+
data.tar.gz: 80c4aec87566f6a76c0968fd1bc928764408170a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98ba8648aba395b3cf0d0e2ee8901315d410fc0e201a6a6d194fcd2cf895e96ee6011388aca8d9d6c4400b6ba1c4cc41d1754cda3f7a2cd8fd777fdff74e76f9
|
7
|
+
data.tar.gz: 06072ad359b209d8e31d4f3b5ce420ae8356e979807b7563324e58ffc1ed0dd30ded3aa42f0e6bf0ed2758a20912e6c034829505c234b42e7f38af0f0a8ca868
|
@@ -2,6 +2,7 @@ require_relative 'serialization_providers/json_serialization_provider'
|
|
2
2
|
unless RUBY_PLATFORM =~ /java/
|
3
3
|
require_relative 'serialization_providers/oj_serialization_provider'
|
4
4
|
end
|
5
|
+
require_relative 'serialization_providers/jruby'
|
5
6
|
require_relative 'serialization_providers/binary_serialization_provider'
|
6
7
|
|
7
8
|
module EventQ
|
@@ -14,7 +15,9 @@ module EventQ
|
|
14
15
|
class Manager
|
15
16
|
def initialize
|
16
17
|
@providers = {}
|
17
|
-
|
18
|
+
if RUBY_PLATFORM =~ /java/
|
19
|
+
@providers[OJ_PROVIDER] = EventQ::SerializationProviders::JRuby::OjSerializationProvider
|
20
|
+
else
|
18
21
|
@providers[OJ_PROVIDER] = EventQ::SerializationProviders::OjSerializationProvider
|
19
22
|
end
|
20
23
|
@providers[JSON_PROVIDER] = EventQ::SerializationProviders::JsonSerializationProvider
|
@@ -23,11 +26,11 @@ module EventQ
|
|
23
26
|
|
24
27
|
def get_provider(provider_type)
|
25
28
|
provider = @providers[provider_type]
|
26
|
-
if provider
|
29
|
+
if provider.nil?
|
27
30
|
raise "Invalid provider type specified: #{provider_type}"
|
28
31
|
end
|
29
32
|
return provider.new
|
30
33
|
end
|
31
34
|
end
|
32
35
|
end
|
33
|
-
end
|
36
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require_relative 'oj/attribute_writer'
|
2
|
+
require_relative 'oj/class_writer'
|
3
|
+
require_relative 'oj/rational_writer'
|
4
|
+
require_relative 'oj/date_time_writer'
|
5
|
+
require_relative 'oj/date_writer'
|
6
|
+
require_relative 'oj/time_writer'
|
7
|
+
require_relative 'oj/array_writer'
|
8
|
+
require_relative 'oj/hash_writer'
|
9
|
+
require_relative 'oj/value_writer'
|
10
|
+
require_relative 'oj/serializer'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module EventQ
|
2
|
+
module SerializationProviders
|
3
|
+
module JRuby
|
4
|
+
module Oj
|
5
|
+
class ArrayWriter < AttributeWriter
|
6
|
+
def valid?(obj)
|
7
|
+
obj.is_a?(Array)
|
8
|
+
end
|
9
|
+
def exec(obj)
|
10
|
+
array = []
|
11
|
+
obj.each do |a|
|
12
|
+
array << AttributeWriter.exec(a)
|
13
|
+
end
|
14
|
+
array
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module EventQ
|
2
|
+
module SerializationProviders
|
3
|
+
module JRuby
|
4
|
+
module Oj
|
5
|
+
class AttributeWriter
|
6
|
+
|
7
|
+
def self.exec(obj)
|
8
|
+
aw = descendants.detect { |a| a.new.valid?(obj) } || ClassWriter
|
9
|
+
aw.new.exec(obj)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.descendants
|
13
|
+
descendants = []
|
14
|
+
ObjectSpace.each_object(singleton_class) do |k|
|
15
|
+
next if k.singleton_class?
|
16
|
+
descendants.unshift k unless k == self
|
17
|
+
end
|
18
|
+
descendants
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module EventQ
|
2
|
+
module SerializationProviders
|
3
|
+
module JRuby
|
4
|
+
module Oj
|
5
|
+
class ClassWriter < AttributeWriter
|
6
|
+
def valid?(obj)
|
7
|
+
false
|
8
|
+
end
|
9
|
+
def exec(obj)
|
10
|
+
hash = { '^o': obj.class }
|
11
|
+
obj.instance_variables.each do |key|
|
12
|
+
hash[key[1..-1]] = AttributeWriter.exec(obj.instance_variable_get(key))
|
13
|
+
end
|
14
|
+
hash
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module EventQ
|
2
|
+
module SerializationProviders
|
3
|
+
module JRuby
|
4
|
+
module Oj
|
5
|
+
class DateTimeWriter < AttributeWriter
|
6
|
+
def valid?(obj)
|
7
|
+
obj.is_a?(DateTime)
|
8
|
+
end
|
9
|
+
def exec(obj)
|
10
|
+
seconds = obj.strftime('%S%N')
|
11
|
+
d = 1_000_000_000
|
12
|
+
if seconds.start_with?('0')
|
13
|
+
seconds[0] = ''
|
14
|
+
d = 100_000_000
|
15
|
+
end
|
16
|
+
|
17
|
+
{
|
18
|
+
'^O': 'DateTime',
|
19
|
+
year: obj.year,
|
20
|
+
month: obj.month,
|
21
|
+
day: obj.day,
|
22
|
+
hour: obj.hour,
|
23
|
+
min: obj.min,
|
24
|
+
sec: RationalWriter.new.exec(Rational(Integer(seconds), d)),
|
25
|
+
offset: RationalWriter.new.exec(obj.offset),
|
26
|
+
start: obj.start
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module EventQ
|
2
|
+
module SerializationProviders
|
3
|
+
module JRuby
|
4
|
+
module Oj
|
5
|
+
class DateWriter < AttributeWriter
|
6
|
+
def valid?(obj)
|
7
|
+
obj.is_a?(Date) && !obj.is_a?(DateTime)
|
8
|
+
end
|
9
|
+
def exec(obj)
|
10
|
+
{
|
11
|
+
'^O': 'Date',
|
12
|
+
year: obj.year,
|
13
|
+
month: obj.month,
|
14
|
+
day: obj.day,
|
15
|
+
start: obj.start
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module EventQ
|
2
|
+
module SerializationProviders
|
3
|
+
module JRuby
|
4
|
+
module Oj
|
5
|
+
class HashWriter < AttributeWriter
|
6
|
+
def valid?(obj)
|
7
|
+
obj.is_a?(Hash)
|
8
|
+
end
|
9
|
+
def exec(obj)
|
10
|
+
obj.each do |key, value|
|
11
|
+
obj[key] = AttributeWriter.exec(value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module EventQ
|
2
|
+
module SerializationProviders
|
3
|
+
module JRuby
|
4
|
+
module Oj
|
5
|
+
class RationalWriter < AttributeWriter
|
6
|
+
def valid?(obj)
|
7
|
+
obj.is_a?(Rational)
|
8
|
+
end
|
9
|
+
def exec(obj)
|
10
|
+
{
|
11
|
+
'^O': 'Rational',
|
12
|
+
numerator: obj.numerator,
|
13
|
+
denominator: obj.denominator
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module EventQ
|
2
|
+
module SerializationProviders
|
3
|
+
module JRuby
|
4
|
+
module Oj
|
5
|
+
class Serializer
|
6
|
+
def dump(obj)
|
7
|
+
JSON.dump(AttributeWriter.exec(obj))
|
8
|
+
end
|
9
|
+
|
10
|
+
def load(json)
|
11
|
+
raise NotImplementedError.new("[#{self.class}] - #load method has not yet been implemented.")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module EventQ
|
2
|
+
module SerializationProviders
|
3
|
+
module JRuby
|
4
|
+
module Oj
|
5
|
+
class ValueWriter < AttributeWriter
|
6
|
+
def valid?(obj)
|
7
|
+
obj.is_a?(String) || obj.is_a?(Integer) || obj.is_a?(Float)
|
8
|
+
end
|
9
|
+
def exec(obj)
|
10
|
+
obj
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module EventQ
|
2
|
+
module SerializationProviders
|
3
|
+
module JRuby
|
4
|
+
class OjSerializationProvider
|
5
|
+
def initialize
|
6
|
+
@json_serializer = EventQ::SerializationProviders::JsonSerializationProvider.new
|
7
|
+
@oj_serializer = Oj::Serializer.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def serialize(object)
|
11
|
+
@oj_serializer.dump(object)
|
12
|
+
end
|
13
|
+
|
14
|
+
def deserialize(json)
|
15
|
+
begin
|
16
|
+
return @oj_serializer.load(json)
|
17
|
+
rescue
|
18
|
+
EventQ.log(:debug, "[#{self.class}] - Failed to deserialize using Oj, falling back to JsonSerializationProvider.")
|
19
|
+
return @json_serializer.deserialize(json)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/eventq_base/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eventq_base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vaughanbrittonsage
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -134,6 +134,19 @@ files:
|
|
134
134
|
- lib/eventq_base/queue_worker_contract.rb
|
135
135
|
- lib/eventq_base/serialization_providers.rb
|
136
136
|
- lib/eventq_base/serialization_providers/binary_serialization_provider.rb
|
137
|
+
- lib/eventq_base/serialization_providers/jruby.rb
|
138
|
+
- lib/eventq_base/serialization_providers/jruby/oj.rb
|
139
|
+
- lib/eventq_base/serialization_providers/jruby/oj/array_writer.rb
|
140
|
+
- lib/eventq_base/serialization_providers/jruby/oj/attribute_writer.rb
|
141
|
+
- lib/eventq_base/serialization_providers/jruby/oj/class_writer.rb
|
142
|
+
- lib/eventq_base/serialization_providers/jruby/oj/date_time_writer.rb
|
143
|
+
- lib/eventq_base/serialization_providers/jruby/oj/date_writer.rb
|
144
|
+
- lib/eventq_base/serialization_providers/jruby/oj/hash_writer.rb
|
145
|
+
- lib/eventq_base/serialization_providers/jruby/oj/rational_writer.rb
|
146
|
+
- lib/eventq_base/serialization_providers/jruby/oj/serializer.rb
|
147
|
+
- lib/eventq_base/serialization_providers/jruby/oj/time_writer.rb
|
148
|
+
- lib/eventq_base/serialization_providers/jruby/oj/value_writer.rb
|
149
|
+
- lib/eventq_base/serialization_providers/jruby/oj_serialization_provider.rb
|
137
150
|
- lib/eventq_base/serialization_providers/json_serialization_provider.rb
|
138
151
|
- lib/eventq_base/serialization_providers/oj_serialization_provider.rb
|
139
152
|
- lib/eventq_base/signature_providers.rb
|