trophonius 2.1 → 2.1.5
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/config.rb +1 -0
- data/lib/connectors/connection.rb +45 -41
- data/lib/connectors/connection_manager.rb +8 -0
- data/lib/connectors/redis_manager.rb +9 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ecc1055be56103548bd16bca808ff5a939e0ee7bbb2650d92f14cfb8e4d18da
|
4
|
+
data.tar.gz: 5b7319bc6b276601a9208db83771f7e2b94c1a981d43f752f5af74370ddad44d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2922556fcf044ffd33a83f7b2645d866e22f4be011813c833eecbb087e9563e9c9f15c72954645544ffc6bad2982b1f66057de0696f35febd3be9878f6bdf006
|
7
|
+
data.tar.gz: bf26bdb6b2ce439f4d302fdd3075c9fc07d73acbdfe0dd0ec5981e2ebad5c2ef89735a69d419e812b77bc965f72f730c8fef1335fae0f04d8355d95597ef93d8
|
data/lib/config.rb
CHANGED
@@ -27,6 +27,7 @@ module Trophonius
|
|
27
27
|
config_accessor(:belongs_to_relations) { {} }
|
28
28
|
config_accessor(:local_network) { false }
|
29
29
|
config_accessor(:redis_connection) { false }
|
30
|
+
config_accessor(:redis_no_verify) { false }
|
30
31
|
config_accessor(:pool_size) { 5 }
|
31
32
|
config_accessor(:debug) { false }
|
32
33
|
end
|
@@ -2,9 +2,11 @@ require 'time'
|
|
2
2
|
require 'base64'
|
3
3
|
require 'securerandom'
|
4
4
|
require 'connectors/redis_manager'
|
5
|
+
require 'debug_printer'
|
5
6
|
|
6
7
|
module Trophonius
|
7
8
|
class Connection
|
9
|
+
include DebugPrinter
|
8
10
|
attr_reader :id
|
9
11
|
|
10
12
|
def initialize
|
@@ -24,6 +26,49 @@ module Trophonius
|
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
29
|
+
##
|
30
|
+
# Disconnects from the FileMaker server
|
31
|
+
#
|
32
|
+
def disconnect
|
33
|
+
uri = URI::RFC2396_Parser.new
|
34
|
+
url =
|
35
|
+
URI(
|
36
|
+
uri.escape(
|
37
|
+
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
38
|
+
Trophonius.config.database
|
39
|
+
}/sessions/#{Trophonius.config.redis_connection ? Trophonius::RedisManager.get_key(key: 'token') : @token}"
|
40
|
+
)
|
41
|
+
)
|
42
|
+
ssl_verifyhost = Trophonius.config.local_network ? 0 : 2
|
43
|
+
ssl_verifypeer = !Trophonius.config.local_network
|
44
|
+
|
45
|
+
request =
|
46
|
+
Typhoeus::Request.new(
|
47
|
+
url,
|
48
|
+
method: :delete,
|
49
|
+
params: {},
|
50
|
+
ssl_verifyhost: ssl_verifyhost,
|
51
|
+
ssl_verifypeer: ssl_verifypeer,
|
52
|
+
headers: { 'Content-Type' => 'application/json' }
|
53
|
+
)
|
54
|
+
temp = request.run
|
55
|
+
|
56
|
+
begin
|
57
|
+
parsed = JSON.parse(temp.response_body)
|
58
|
+
|
59
|
+
DebugPrinter.print_debug('RECEIVED DISCONNECT', parsed)
|
60
|
+
rescue StandardError => e
|
61
|
+
puts e
|
62
|
+
puts e.backtrace
|
63
|
+
Error.throw_error('1631')
|
64
|
+
end
|
65
|
+
Error.throw_error(parsed['messages'][0]['code']) if parsed['messages'][0]['code'] != '0'
|
66
|
+
Trophonius::RedisManager.disconnect! if Trophonius.config.redis_connection
|
67
|
+
@token = nil
|
68
|
+
@last_connection = nil
|
69
|
+
true
|
70
|
+
end
|
71
|
+
|
27
72
|
private
|
28
73
|
|
29
74
|
##
|
@@ -113,47 +158,6 @@ module Trophonius
|
|
113
158
|
parsed['response']['token']
|
114
159
|
end
|
115
160
|
|
116
|
-
##
|
117
|
-
# Disconnects from the FileMaker server
|
118
|
-
#
|
119
|
-
def disconnect
|
120
|
-
uri = URI::RFC2396_Parser.new
|
121
|
-
url =
|
122
|
-
URI(
|
123
|
-
uri.escape(
|
124
|
-
"http#{Trophonius.config.ssl == true ? 's' : ''}://#{Trophonius.config.host}/fmi/data/v1/databases/#{
|
125
|
-
Trophonius.config.database
|
126
|
-
}/sessions/#{Trophonius.config.redis_connection ? Trophonius::RedisManager.get_key(key: 'token') : @token}"
|
127
|
-
)
|
128
|
-
)
|
129
|
-
ssl_verifyhost = Trophonius.config.local_network ? 0 : 2
|
130
|
-
ssl_verifypeer = !Trophonius.config.local_network
|
131
|
-
|
132
|
-
request =
|
133
|
-
Typhoeus::Request.new(
|
134
|
-
url,
|
135
|
-
method: :delete,
|
136
|
-
params: {},
|
137
|
-
ssl_verifyhost: ssl_verifyhost,
|
138
|
-
ssl_verifypeer: ssl_verifypeer,
|
139
|
-
headers: { 'Content-Type' => 'application/json' }
|
140
|
-
)
|
141
|
-
temp = request.run
|
142
|
-
|
143
|
-
begin
|
144
|
-
parsed = JSON.parse(temp.response_body)
|
145
|
-
rescue StandardError => e
|
146
|
-
puts e
|
147
|
-
puts e.backtrace
|
148
|
-
Error.throw_error('1631')
|
149
|
-
end
|
150
|
-
Error.throw_error(parsed['messages'][0]['code']) if parsed['messages'][0]['code'] != '0'
|
151
|
-
Trophonius::RedisManager.disconnect! if Trophonius.config.redis_connection
|
152
|
-
@token = nil
|
153
|
-
@last_connection = nil
|
154
|
-
true
|
155
|
-
end
|
156
|
-
|
157
161
|
##
|
158
162
|
# Returns the receive time of the last received token
|
159
163
|
# @return [Time] Returns the receive time of the last received token
|
@@ -1,10 +1,14 @@
|
|
1
|
+
require 'debug_printer'
|
1
2
|
module Trophonius
|
2
3
|
class ConnectionManager
|
4
|
+
include DebugPrinter
|
3
5
|
def initialize
|
4
6
|
@connections = {}
|
5
7
|
Trophonius.config.pool_size.times do
|
6
8
|
connection = Connection.new
|
7
9
|
@connections[connection.id] = { connection: connection, queue: [] }
|
10
|
+
|
11
|
+
DebugPrinter.print_debug('CONNECTION CREATED', @connections[connection.id].inspect)
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
@@ -22,6 +26,10 @@ module Trophonius
|
|
22
26
|
nil
|
23
27
|
end
|
24
28
|
|
29
|
+
def disconnect_all
|
30
|
+
@connections.each { |_connection_id, connection| connection[:connection].disconnect }
|
31
|
+
end
|
32
|
+
|
25
33
|
private
|
26
34
|
|
27
35
|
def auth_header_bearer(id)
|
@@ -2,14 +2,15 @@ module Trophonius
|
|
2
2
|
# the RedisManager module is used to create a (single) connection to a redis store.
|
3
3
|
module Trophonius::RedisManager
|
4
4
|
def self.connect
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
return unless Trophonius.config.redis_connection
|
6
|
+
|
7
|
+
redis_url = ENV.fetch('REDIS_URL')
|
8
|
+
options = {}
|
9
|
+
options.merge!(url: redis_url) if redis_url && redis_url != ''
|
10
|
+
options.merge!(ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }) if Trophonius.config.redis_no_verify
|
11
|
+
@redis ||= Redis.new(options)
|
12
|
+
|
13
|
+
nil
|
13
14
|
end
|
14
15
|
|
15
16
|
##
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trophonius
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kempen Automatisering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
101
|
+
rubygems_version: 3.5.5
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Link between Ruby (on Rails) and FileMaker.
|