eventq_base 1.15.0-java → 1.16.0-java

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
  SHA256:
3
- metadata.gz: 3e775e37e2b345a940c9c1c639661ed173a077b787dc28efb4245448a218083c
4
- data.tar.gz: 5ee3ac3fb1810b18c8f4510cdaa17d98f4d01eac46cdbf960df1da0cd174d765
3
+ metadata.gz: be631fe763d5b378958552cdad1e6d611333ab246cf65701f44bd0c3c4ebbea7
4
+ data.tar.gz: 554006ae4e44b39110632c0f1a9950dcec3313bfe3b1c9495ff37d5b468e9d85
5
5
  SHA512:
6
- metadata.gz: 879bccd09f01df061bd0e2ad3ba2e110f38da121358f9ab8ee05f9b41f101dc1df655676546a82dfd64c1abaabe8c7922811d173e539b1ecd22e90943728da3a
7
- data.tar.gz: 85d1945fda553fe7d61a272eec97e3443ef247f4f69c7f567e1c1568b9fb79a449811da475f19d7d1aef7e2e5499ba67b75013db4843e2f34f35f383b662429e
6
+ metadata.gz: 9a12003164ca23896aaff1350cf1d7f594efb1377603a7a0a976e404df73e189e829a64394baac9503c51394d8daf47ea45ba6544657738eb3a4b98b72d4d8f1
7
+ data.tar.gz: 5cd4c5eb5dd9eed3f74a9f8e3931d9d9b8f72ffb3051bdeb66fa25254341d4a7f95f10b96d9aae9e8c12f18392bd691d02b2b2ecd8b37ab4657427a573884737
@@ -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,18 @@
1
+ module EventQ
2
+ module SerializationProviders
3
+ module JRuby
4
+ module Oj
5
+ class TimeWriter < AttributeWriter
6
+ def valid?(obj)
7
+ obj.is_a?(Time)
8
+ end
9
+ def exec(obj)
10
+ {
11
+ '^t': obj.to_f
12
+ }
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ 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,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,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
@@ -0,0 +1,2 @@
1
+ require_relative 'jruby/oj'
2
+ require_relative 'jruby/oj_serialization_provider'
@@ -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
- unless RUBY_PLATFORM =~ /java/
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 == nil
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
@@ -1,3 +1,3 @@
1
1
  module EventqBase
2
- VERSION = "1.15.0"
2
+ VERSION = "1.16.0"
3
3
  end
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.15.0
4
+ version: 1.16.0
5
5
  platform: java
6
6
  authors:
7
7
  - vaughanbrittonsage
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-26 00:00:00.000000000 Z
11
+ date: 2018-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -120,6 +120,19 @@ files:
120
120
  - lib/eventq_base/queue_worker_contract.rb
121
121
  - lib/eventq_base/serialization_providers.rb
122
122
  - lib/eventq_base/serialization_providers/binary_serialization_provider.rb
123
+ - lib/eventq_base/serialization_providers/jruby.rb
124
+ - lib/eventq_base/serialization_providers/jruby/oj.rb
125
+ - lib/eventq_base/serialization_providers/jruby/oj/array_writer.rb
126
+ - lib/eventq_base/serialization_providers/jruby/oj/attribute_writer.rb
127
+ - lib/eventq_base/serialization_providers/jruby/oj/class_writer.rb
128
+ - lib/eventq_base/serialization_providers/jruby/oj/date_time_writer.rb
129
+ - lib/eventq_base/serialization_providers/jruby/oj/date_writer.rb
130
+ - lib/eventq_base/serialization_providers/jruby/oj/hash_writer.rb
131
+ - lib/eventq_base/serialization_providers/jruby/oj/rational_writer.rb
132
+ - lib/eventq_base/serialization_providers/jruby/oj/serializer.rb
133
+ - lib/eventq_base/serialization_providers/jruby/oj/time_writer.rb
134
+ - lib/eventq_base/serialization_providers/jruby/oj/value_writer.rb
135
+ - lib/eventq_base/serialization_providers/jruby/oj_serialization_provider.rb
123
136
  - lib/eventq_base/serialization_providers/json_serialization_provider.rb
124
137
  - lib/eventq_base/serialization_providers/oj_serialization_provider.rb
125
138
  - lib/eventq_base/signature_providers.rb