inigorb 0.28.1 → 0.28.5

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: a8dd4aa6b5a222647cdeaca8bc0a812fff7ca4afa6402c3da8a182d5b87a1db1
4
- data.tar.gz: 79e2b7554361eb3e170d63b7c07afa2d58870322b3790452b3ede1120b46732f
3
+ metadata.gz: 1e8a004dcd749886d4a48645b606cccc589a9b32c3ea93e4bf2b677f1f8c7320
4
+ data.tar.gz: 83de71d1d30614bc1894f21b3527918e50dbd7422cc6849a4a379c5e0cfebe10
5
5
  SHA512:
6
- metadata.gz: cec390d985f84492c6a72f2232382f6f8a93043b9c067f3d30d71f7896bcaf12c6ec47b91afab59c8e1dbd4ac78d84d141a5ba1ce982e865a0012f9b0d00cfd3
7
- data.tar.gz: a2a42ca4d67b9e6ad518cf2d748dd09a8123815c3c327aaf382cc8e3bbfee5f6cb9454c8e3a66c80392f5c63dad0d4276cadeeda552f695071e8a23e845fc9ff
6
+ metadata.gz: 912b7eb024b8a6e2b7bfd4d08af08351e1074d8c7eda03189c5078b89d3594f5b39770327c088e238dd5aff3b2d02059b539938fbb2992544a961ba90de1f489
7
+ data.tar.gz: 7b1b3b1469079cb3482a6fb74df3d6d0834d42c51cb3be6789e638a767b88c336fd2e93e4580d469309e634b6da1abaf260942f7bfe492e902a352d7b22105ef
@@ -3,6 +3,18 @@ require 'ffi'
3
3
  module Inigo
4
4
  extend FFI::Library
5
5
 
6
+ class Config < FFI::Struct
7
+ layout :debug, :bool,
8
+ :name, :pointer,
9
+ :service, :pointer,
10
+ :token, :pointer,
11
+ :schema, :pointer,
12
+ :runtime, :pointer,
13
+ :egress_url, :pointer,
14
+ :gateway, :u_int64_t,
15
+ :disable_response_data, :bool
16
+ end
17
+
6
18
  def self.get_arch(system_name)
7
19
  machine = RbConfig::CONFIG['target_cpu'].downcase
8
20
  if system_name == 'darwin'
@@ -37,55 +49,45 @@ module Inigo
37
49
  '.so'
38
50
  end
39
51
 
40
- system_name = RbConfig::CONFIG['host_os']
41
-
42
- supported_systems = /(linux|darwin|mingw|mswin|cygwin)/
43
-
44
- unless supported_systems.match?(system_name)
45
- raise RuntimeError, "Only Windows, macOS (darwin), and Linux systems are supported. RUBY_PLATFORM: #{RUBY_PLATFORM}, RUBY_ENGINE: #{RUBY_ENGINE}, HOST_OS: #{system_name}"
46
- end
47
-
48
- system_name = 'windows' if system_name =~ /(mingw|mswin|cygwin)/
49
- system_name = 'darwin' if system_name =~ /darwin/i
50
- system_name = 'linux' if system_name =~ /linux/i
51
-
52
- filename = "inigo-#{system_name}-#{get_arch(system_name)}#{get_ext(system_name)}"
53
-
54
- begin
55
- ffi_lib File.join(File.dirname(__FILE__), filename)
56
-
57
- class Config < FFI::Struct
58
- layout :debug, :bool,
59
- :name, :pointer,
60
- :service, :pointer,
61
- :token, :pointer,
62
- :schema, :pointer,
63
- :runtime, :pointer,
64
- :egress_url, :pointer,
65
- :gateway, :u_int64_t,
66
- :disable_response_data, :bool
52
+ def self.load
53
+ system_name = RbConfig::CONFIG['host_os']
54
+
55
+ supported_systems = /(linux|darwin|mingw|mswin|cygwin)/
56
+
57
+ unless supported_systems.match?(system_name)
58
+ raise RuntimeError, "Only Windows, macOS (darwin), and Linux systems are supported. RUBY_PLATFORM: #{RUBY_PLATFORM}, RUBY_ENGINE: #{RUBY_ENGINE}, HOST_OS: #{system_name}"
67
59
  end
60
+
61
+ system_name = 'windows' if system_name =~ /(mingw|mswin|cygwin)/
62
+ system_name = 'darwin' if system_name =~ /darwin/i
63
+ system_name = 'linux' if system_name =~ /linux/i
64
+
65
+ filename = "inigo-#{system_name}-#{get_arch(system_name)}#{get_ext(system_name)}"
68
66
 
69
- attach_function :create, [:u_int64_t], :u_int64_t
70
- attach_function :process_request, [
71
- :u_int64_t, # instance
72
- :pointer, :int, # header
73
- :pointer, :int, # input
74
- :pointer, :pointer, # output
75
- :pointer, :pointer # status
76
- ], :u_int64_t
77
- attach_function :process_response, [
78
- :u_int64_t, # instance
79
- :u_int64_t, # request handler
80
- :pointer, :int, # input
81
- :pointer, :pointer # output
82
- ], :void
83
- attach_function :get_version, [], :string
84
- attach_function :disposeHandle, [:u_int64_t], :void
85
- attach_function :disposeMemory, [:pointer], :void
86
- attach_function :check_lasterror, [], :string
87
- attach_function :copy_querydata, [:u_int64_t], :u_int64_t
88
- rescue LoadError => e
89
- raise ::RuntimeError, "Unable to open Inigo shared library.\n\nPlease get in touch with us for support:\nemail: support@inigo.io\nslack: https://slack.inigo.io\n\nPlease share the below info with us:\nerror: #{e.to_s}\nuname: #{RbConfig::CONFIG['host_os']}\narch: #{RbConfig::CONFIG['host_cpu']}"
90
- end
67
+ begin
68
+ ffi_lib File.join(File.dirname(__FILE__), filename)
69
+
70
+ attach_function :create, [:u_int64_t], :u_int64_t
71
+ attach_function :process_request, [
72
+ :u_int64_t, # instance
73
+ :pointer, :int, # header
74
+ :pointer, :int, # input
75
+ :pointer, :pointer, # output
76
+ :pointer, :pointer # status
77
+ ], :u_int64_t
78
+ attach_function :process_response, [
79
+ :u_int64_t, # instance
80
+ :u_int64_t, # request handler
81
+ :pointer, :int, # input
82
+ :pointer, :pointer # output
83
+ ], :void
84
+ attach_function :get_version, [], :string
85
+ attach_function :disposeHandle, [:u_int64_t], :void
86
+ attach_function :disposeMemory, [:pointer], :void
87
+ attach_function :check_lasterror, [], :string
88
+ attach_function :copy_querydata, [:u_int64_t], :u_int64_t
89
+ rescue LoadError => e
90
+ raise ::RuntimeError, "Unable to open Inigo shared library.\n\nPlease get in touch with us for support:\nemail: support@inigo.io\nslack: https://slack.inigo.io\n\nPlease share the below info with us:\nerror: #{e.to_s}\nuname: #{RbConfig::CONFIG['host_os']}\narch: #{RbConfig::CONFIG['host_cpu']}"
91
+ end
92
+ end
91
93
  end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -79,12 +79,14 @@ module Inigo
79
79
 
80
80
  q = Query.new(self.class.instance, JSON.dump(gReq))
81
81
 
82
- incoming_request = query.context['request']
82
+ headers_obj = query.context[:headers] if query.context[:headers]
83
+ headers_obj = query.context['request'].headers if headers_obj == nil && query.context['request']
84
+ headers_obj = query.context[:request].headers if headers_obj == nil && query.context[:request]
83
85
  if is_subscription
84
- incoming_request = ActionDispatch::Request.new(query.context[:channel].connection.env)
86
+ headers_obj = ActionDispatch::Http::Headers.from_hash(query.context[:channel].connection.env)
85
87
  end
86
88
 
87
- resp, req = q.process_request(headers(incoming_request))
89
+ resp, req = q.process_request(headers(headers_obj))
88
90
 
89
91
  # Introspection or blocked query
90
92
  if resp.any?
@@ -201,11 +203,11 @@ module Inigo
201
203
  settings = ENV.select { |k, v| k.start_with?('INIGO') }
202
204
 
203
205
  if settings.fetch("INIGO_ENABLE", "").to_s.downcase == "false"
204
- @@initialized = true #not to get to this method ever again
205
206
  puts 'Inigo is disabled. Skipping middleware.'
206
207
  return
207
208
  end
208
209
 
210
+ Inigo::load
209
211
  config = Inigo::Config.new
210
212
 
211
213
  config[:disable_response_data] = false
@@ -228,10 +230,10 @@ module Inigo
228
230
  end
229
231
  end
230
232
 
231
- def headers(request)
233
+ def headers(headers_obj)
232
234
  headers = {}
233
235
 
234
- request.env.each do |key, value|
236
+ headers_obj.env.each do |key, value|
235
237
  if key.start_with?('HTTP_')
236
238
  header_name = key[5..].split('_').map(&:capitalize).join('-')
237
239
  headers[header_name] = value.split(',').map(&:strip)
data/lib/inigorb.rb CHANGED
@@ -211,6 +211,7 @@ module Inigo
211
211
  return
212
212
  end
213
213
 
214
+ Inigo::load
214
215
  config = Inigo::Config.new
215
216
  config[:disable_response_data] = false
216
217
  config[:name] = FFI::MemoryPointer.from_string("inigo-rb".to_s.encode('UTF-8'))
@@ -0,0 +1,52 @@
1
+ require 'puma'
2
+ require 'puma/plugin'
3
+
4
+ module Puma
5
+ class Plugin
6
+ module InigoPlugin
7
+ class Error < StandardError; end
8
+
9
+ class << self
10
+ attr_writer :config
11
+
12
+ def config
13
+ @config ||= Config.new
14
+ end
15
+
16
+ def configure
17
+ yield(config)
18
+ end
19
+ end
20
+
21
+ # Contents of actual Puma Plugin
22
+ #
23
+ module PluginInstanceMethods
24
+ def start(launcher)
25
+ launcher.events.on_booted do
26
+ if launcher.options[:workers] == 0
27
+ Inigo::Tracer.initialize_tracer(Puma::Plugin::InigoPlugin.config.schema_class.to_definition)
28
+ end
29
+ end
30
+ end
31
+
32
+ def config(c)
33
+ c.on_worker_boot do
34
+ Inigo::Tracer.initialize_tracer(Puma::Plugin::InigoPlugin.config.schema_class.to_definition)
35
+ end
36
+ end
37
+ end
38
+
39
+ class Config
40
+ attr_accessor :schema_class
41
+
42
+ def initialize
43
+ @schema_class = nil
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ Puma::Plugin.create do
51
+ include Puma::Plugin::InigoPlugin::PluginInstanceMethods
52
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inigorb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.1
4
+ version: 0.28.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Inigo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-04 00:00:00.000000000 Z
11
+ date: 2023-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -70,6 +70,26 @@ dependencies:
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: 2.0.24
73
+ - !ruby/object:Gem::Dependency
74
+ name: puma
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '5.0'
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '5.0'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '5.0'
73
93
  description:
74
94
  email: eitan@inigo.io
75
95
  executables: []
@@ -87,6 +107,7 @@ files:
87
107
  - lib/inigorb/inigo-windows-arm64.dll
88
108
  - lib/inigorb/query.rb
89
109
  - lib/inigorb/tracer.rb
110
+ - lib/puma/plugin/inigo.rb
90
111
  homepage: https://inigo.io
91
112
  licenses:
92
113
  - MIT