inigorb 0.28.2 → 0.29.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/inigorb/ffimod.rb +51 -49
- data/lib/inigorb/inigo-darwin-amd64.dylib +0 -0
- data/lib/inigorb/inigo-darwin-arm64.dylib +0 -0
- data/lib/inigorb/inigo-linux-amd64.so +0 -0
- data/lib/inigorb/inigo-linux-arm64.so +0 -0
- data/lib/inigorb/inigo-windows-amd64.dll +0 -0
- data/lib/inigorb/inigo-windows-arm64.dll +0 -0
- data/lib/inigorb/tracer.rb +8 -6
- data/lib/inigorb.rb +1 -0
- data/lib/puma/plugin/inigo.rb +52 -0
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95f45240011a5b320118e7f21be391276e034a3965498002a90d33ac7b5ea431
|
4
|
+
data.tar.gz: 112db5e1c3113b1d9176970d34af384124c59c8b92896a0080c4fc54b4d4f26f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d98c191b7cde27f099de02aa01866c2f2d193b327b648edb7f969e642894778af0144901cf1ca0f6d36b0169f6e944de17549c84faedf4eb2be509338ca651f5
|
7
|
+
data.tar.gz: d993ea9aba9685c122a218c35b58b88034090b0b3e5cc3cb124b4e2dbcae7ddd688a542e8998379c8840dc552c2f856fc94338a6003f7721d3bd3b2bef4c0bbe
|
data/lib/inigorb/ffimod.rb
CHANGED
@@ -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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
data/lib/inigorb/tracer.rb
CHANGED
@@ -79,12 +79,14 @@ module Inigo
|
|
79
79
|
|
80
80
|
q = Query.new(self.class.instance, JSON.dump(gReq))
|
81
81
|
|
82
|
-
|
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
|
-
|
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(
|
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(
|
233
|
+
def headers(headers_obj)
|
232
234
|
headers = {}
|
233
235
|
|
234
|
-
|
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
@@ -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.
|
4
|
+
version: 0.29.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Inigo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-08 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
|