apiotics 0.1.82 → 0.1.83

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: 42c9d9b1e585d4e2c1f82632353bbb0bd6c739ef
4
- data.tar.gz: aece1bb701a6d1aa433517b3b580619cd2df87f1
3
+ metadata.gz: 60cdc0f1790b8f4586b322d2662215b21de02abc
4
+ data.tar.gz: 4b9f828b1fec118b4f14b9173cea23cc7afa63b8
5
5
  SHA512:
6
- metadata.gz: cdff2446906b94c0dd0d2fb71d4808e865df96c89f477321c7833945d27dca46eef2bf4eb0f666953ba62a0ded643b7fe4bf83c07b36eedae5848424ea7a8b8e
7
- data.tar.gz: eef266027ba28c8a81edea98866d188a89765f017d8f9628511168a6eb9c57fe29579c12599b6be9706b5108fc37c68a99675b1389b0af4e7fc5a37e46309632
6
+ metadata.gz: 6fa9d5dd364846ab88578c2924ea817c54611106860cb3617b7ac3f2a4e2f91ee3b804a4ceb3f4dd455719b66c4bfb9b247bc8634a7418999c84e46fa9249f19
7
+ data.tar.gz: f2a499ec53ee6a37db9510f1913f1ec0a05813ffdf72ee0213a5cb2b27ef2f4e1d2e061de21582615932f6eca85c3d051a42335bd58c1440aeeda5a172ed7641
@@ -14,9 +14,13 @@ module Apiotics
14
14
  end
15
15
 
16
16
  def send(msg)
17
- connection = TCPSocket.open(@server, @port)
18
- connection.puts( msg )
19
- connection.close
17
+ if Apiotics.configuration.redis_comms_connection == false
18
+ connection = TCPSocket.open(@server, @port)
19
+ connection.puts( msg )
20
+ connection.close
21
+ else
22
+ $redis.publish Apiotics.configuration.public_key, msg
23
+ end
20
24
  end
21
25
 
22
26
  end
@@ -1,7 +1,7 @@
1
1
  module Apiotics
2
2
  class Configuration
3
3
 
4
- attr_accessor :public_key, :private_key, :local_logging, :targets, :local_port, :server, :server_port, :portal, :push, :tls, :verify_peer, :handshake, :parents, :reduced_metadata, :production_host, :interface_kinds
4
+ attr_accessor :public_key, :private_key, :local_logging, :targets, :local_port, :server, :server_port, :portal, :push, :tls, :verify_peer, :handshake, :parents, :reduced_metadata, :redis_comms_connection, :interface_kinds
5
5
 
6
6
  def initialize
7
7
  @public_key = nil
@@ -18,7 +18,7 @@ module Apiotics
18
18
  @handshake = true
19
19
  @parents = {}
20
20
  @reduced_metadata = false
21
- @production_host = nil
21
+ @redis_comms_connection = false
22
22
  @interface_kinds = {
23
23
  "string" => "string",
24
24
  "text" => "string",
@@ -108,20 +108,36 @@ module Apiotics
108
108
 
109
109
  def listen_local
110
110
  begin
111
- server = TCPServer.open(@localport)
112
- if Apiotics.configuration.handshake == true
113
- self.send('{"action":"connect"}')
114
- end
115
- loop do
116
- Thread.fork(server.accept) do |client|
117
- s = client.gets
118
- if @error_msg != nil
119
- string = '{"error":"' + error_msg + '"}'
120
- client.puts(string)
121
- end
122
- #puts s
123
- self.send(s)
124
- end
111
+ if Apiotics.configuration.redis_comms_connection == false
112
+ server = TCPServer.open(@localport)
113
+ if Apiotics.configuration.handshake == true
114
+ self.send('{"action":"connect"}')
115
+ end
116
+ loop do
117
+ Thread.fork(server.accept) do |client|
118
+ s = client.gets
119
+ if @error_msg != nil
120
+ string = '{"error":"' + error_msg + '"}'
121
+ client.puts(string)
122
+ end
123
+ #puts s
124
+ self.send(s)
125
+ end
126
+ end
127
+ else
128
+ if Apiotics.configuration.handshake == true
129
+ self.send('{"action":"connect"}')
130
+ end
131
+ $redis.subscribe(Apiotics.configuration.public_key) do |on|
132
+ on.message do |channel, msg|
133
+ if @error_msg != nil
134
+ string = '{"error":"' + error_msg + '"}'
135
+ client.puts(string)
136
+ end
137
+ #puts msg
138
+ self.send(msg)
139
+ end
140
+ end
125
141
  end
126
142
  rescue => e
127
143
  puts e
@@ -1,3 +1,3 @@
1
1
  module Apiotics
2
- VERSION = '0.1.82'
2
+ VERSION = '0.1.83'
3
3
  end
@@ -9,5 +9,5 @@ Apiotics.configure do |config|
9
9
  config.handshake = true
10
10
  config.local_logging = false
11
11
  config.reduced_metadata = false
12
- config.production_host = nil
12
+ config.redis_comms_connection = false
13
13
  end
@@ -4,4 +4,4 @@
4
4
 
5
5
  require 'daemons'
6
6
 
7
- Daemons.run('lib/scripts/server.rb', ontop: true, no_pidfiles: true)
7
+ Daemons.run('lib/scripts/server.rb', ontop: false)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apiotics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.82
4
+ version: 0.1.83
5
5
  platform: ruby
6
6
  authors:
7
7
  - MicroArx Corporation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-12 00:00:00.000000000 Z
11
+ date: 2017-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails