qravan 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitattributes +2 -0
- data/.gitignore +61 -0
- data/.rspec +3 -0
- data/.rspec_status +4 -0
- data/.rubocop.yml +13 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +143 -0
- data/LICENSE +5 -0
- data/README.md +191 -0
- data/Rakefile +39 -0
- data/assets/images/qravan.png +0 -0
- data/assets/images/qravan_repo.png +0 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/config.ru +46 -0
- data/examples/queries.md +114 -0
- data/exe/qravan +7 -0
- data/ext/qravan/extconf.rb +5 -0
- data/ext/qravan/qravan.c +9 -0
- data/ext/qravan/qravan.h +6 -0
- data/falcon.rb +12 -0
- data/lib/qravan/async_loader.rb +33 -0
- data/lib/qravan/cargo.rb +80 -0
- data/lib/qravan/credentials/request.rb +54 -0
- data/lib/qravan/credentials/response.rb +41 -0
- data/lib/qravan/credentials/signature.rb +30 -0
- data/lib/qravan/credentials/system.rb +33 -0
- data/lib/qravan/credentials.rb +29 -0
- data/lib/qravan/model.rb +20 -0
- data/lib/qravan/qravan.bundle +0 -0
- data/lib/qravan/query/request.rb +40 -0
- data/lib/qravan/query/response.rb +26 -0
- data/lib/qravan/query.rb +30 -0
- data/lib/qravan/resource/resource.rb +35 -0
- data/lib/qravan/source/db.rb +35 -0
- data/lib/qravan/source/rest.rb +36 -0
- data/lib/qravan/source.rb +27 -0
- data/lib/qravan/version.rb +35 -0
- data/lib/qravan.rb +25 -0
- data/logs/db.log +2660 -0
- data/models/base/1.0/model.yaml +32 -0
- data/models/base/current +1 -0
- data/models/current/.keep +0 -0
- data/models/current/model.yaml +158 -0
- data/models/vehicles/1.0/model.yaml +126 -0
- data/qravan.gemspec +48 -0
- data/sources/base/1.0/source.yaml +9 -0
- data/sources/base/current +1 -0
- data/sources/postgres/1.0/source.yaml +10 -0
- data/sources/postgres/current +1 -0
- data/sources/prostore/1.0/source.yaml +13 -0
- data/sources/prostore/current +1 -0
- metadata +296 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8e949467a3511cd09097521ddbb22bc800ced21d5f04f5672083d816943919ce
|
4
|
+
data.tar.gz: 65388d22cdb49a14bd4a487ff3c2e098312cfc60f0e924211da49a01c21bc3d0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0e2674928b9507a6a57192cc552b2d8aa77ecea25e3738bfe1a6984ca05036c4f0a3122a9668d87fa1ece5f2e4e8d18919a87acb648d647c589760e6f87c8b47
|
7
|
+
data.tar.gz: 8a24081627122c14559d1f14007471b8d87e055165f1cc41f3d63524e21697819ee880cc3b9abea1441a0480f66d8a2cfa025ceec18c331c2acab39abb16c529
|
data/.gitattributes
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
# Gemfile.lock
|
49
|
+
# .ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
56
|
+
# .rubocop-https?--*
|
57
|
+
.idea
|
58
|
+
.idea/*
|
59
|
+
logs/*
|
60
|
+
logs/db.log
|
61
|
+
|
data/.rspec
ADDED
data/.rspec_status
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
qravan (0.1.0)
|
5
|
+
async (~> 1.30.1)
|
6
|
+
async-http (~> 0.59.2)
|
7
|
+
async-io (~> 1.34.1)
|
8
|
+
async-sequel (~> 0.1.0)
|
9
|
+
falcon (~> 0.42.3)
|
10
|
+
logger (>= 1.5.3)
|
11
|
+
rack (~> 3.0.2)
|
12
|
+
rack-unreloader (>= 1.8)
|
13
|
+
rake (~> 13.0)
|
14
|
+
redis (~> 5.0.5)
|
15
|
+
rspec (~> 3.0)
|
16
|
+
rubocop (~> 1.7)
|
17
|
+
sequel (>= 5.62)
|
18
|
+
sequel_pg (>= 1.8)
|
19
|
+
|
20
|
+
GEM
|
21
|
+
remote: https://rubygems.org/
|
22
|
+
specs:
|
23
|
+
ast (2.4.2)
|
24
|
+
async (1.30.3)
|
25
|
+
console (~> 1.10)
|
26
|
+
nio4r (~> 2.3)
|
27
|
+
timers (~> 4.1)
|
28
|
+
async-container (0.16.12)
|
29
|
+
async
|
30
|
+
async-io
|
31
|
+
async-http (0.59.4)
|
32
|
+
async (>= 1.25)
|
33
|
+
async-io (>= 1.28)
|
34
|
+
async-pool (>= 0.2)
|
35
|
+
protocol-http (~> 0.23.1)
|
36
|
+
protocol-http1 (~> 0.14.0)
|
37
|
+
protocol-http2 (~> 0.14.0)
|
38
|
+
traces (>= 0.8.0)
|
39
|
+
async-http-cache (0.4.3)
|
40
|
+
async-http (~> 0.56)
|
41
|
+
async-io (1.34.1)
|
42
|
+
async
|
43
|
+
async-pool (0.3.12)
|
44
|
+
async (>= 1.25)
|
45
|
+
async-sequel (0.1.0)
|
46
|
+
sequel
|
47
|
+
build-environment (1.13.0)
|
48
|
+
connection_pool (2.3.0)
|
49
|
+
console (1.16.2)
|
50
|
+
fiber-local
|
51
|
+
diff-lcs (1.5.0)
|
52
|
+
falcon (0.42.3)
|
53
|
+
async
|
54
|
+
async-container (~> 0.16.0)
|
55
|
+
async-http (~> 0.57)
|
56
|
+
async-http-cache (~> 0.4.0)
|
57
|
+
async-io (~> 1.22)
|
58
|
+
build-environment (~> 1.13)
|
59
|
+
bundler
|
60
|
+
localhost (~> 1.1)
|
61
|
+
openssl (~> 3.0)
|
62
|
+
process-metrics (~> 0.2.0)
|
63
|
+
protocol-rack (~> 0.1)
|
64
|
+
samovar (~> 2.1)
|
65
|
+
fiber-local (1.0.0)
|
66
|
+
json (2.6.3)
|
67
|
+
localhost (1.1.9)
|
68
|
+
logger (1.5.3)
|
69
|
+
mapping (1.1.1)
|
70
|
+
nio4r (2.5.8)
|
71
|
+
openssl (3.1.0)
|
72
|
+
parallel (1.22.1)
|
73
|
+
parser (3.2.0.0)
|
74
|
+
ast (~> 2.4.1)
|
75
|
+
pg (1.4.5)
|
76
|
+
process-metrics (0.2.1)
|
77
|
+
console (~> 1.8)
|
78
|
+
samovar (~> 2.1)
|
79
|
+
protocol-hpack (1.4.2)
|
80
|
+
protocol-http (0.23.12)
|
81
|
+
protocol-http1 (0.14.6)
|
82
|
+
protocol-http (~> 0.22)
|
83
|
+
protocol-http2 (0.14.2)
|
84
|
+
protocol-hpack (~> 1.4)
|
85
|
+
protocol-http (~> 0.18)
|
86
|
+
protocol-rack (0.2.4)
|
87
|
+
protocol-http (~> 0.23)
|
88
|
+
rack (>= 1.0)
|
89
|
+
rack (3.0.3)
|
90
|
+
rack-unreloader (2.0.0)
|
91
|
+
rainbow (3.1.1)
|
92
|
+
rake (13.0.6)
|
93
|
+
redis (5.0.5)
|
94
|
+
redis-client (>= 0.9.0)
|
95
|
+
redis-client (0.11.2)
|
96
|
+
connection_pool
|
97
|
+
regexp_parser (2.6.1)
|
98
|
+
rexml (3.2.5)
|
99
|
+
rspec (3.12.0)
|
100
|
+
rspec-core (~> 3.12.0)
|
101
|
+
rspec-expectations (~> 3.12.0)
|
102
|
+
rspec-mocks (~> 3.12.0)
|
103
|
+
rspec-core (3.12.0)
|
104
|
+
rspec-support (~> 3.12.0)
|
105
|
+
rspec-expectations (3.12.1)
|
106
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
107
|
+
rspec-support (~> 3.12.0)
|
108
|
+
rspec-mocks (3.12.1)
|
109
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
110
|
+
rspec-support (~> 3.12.0)
|
111
|
+
rspec-support (3.12.0)
|
112
|
+
rubocop (1.42.0)
|
113
|
+
json (~> 2.3)
|
114
|
+
parallel (~> 1.10)
|
115
|
+
parser (>= 3.1.2.1)
|
116
|
+
rainbow (>= 2.2.2, < 4.0)
|
117
|
+
regexp_parser (>= 1.8, < 3.0)
|
118
|
+
rexml (>= 3.2.5, < 4.0)
|
119
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
120
|
+
ruby-progressbar (~> 1.7)
|
121
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
122
|
+
rubocop-ast (1.24.1)
|
123
|
+
parser (>= 3.1.1.0)
|
124
|
+
ruby-progressbar (1.11.0)
|
125
|
+
samovar (2.1.4)
|
126
|
+
console (~> 1.0)
|
127
|
+
mapping (~> 1.0)
|
128
|
+
sequel (5.64.0)
|
129
|
+
sequel_pg (1.17.1)
|
130
|
+
pg (>= 0.18.0, != 1.2.0)
|
131
|
+
sequel (>= 4.38.0)
|
132
|
+
timers (4.3.5)
|
133
|
+
traces (0.8.0)
|
134
|
+
unicode-display_width (2.4.2)
|
135
|
+
|
136
|
+
PLATFORMS
|
137
|
+
x86_64-darwin-19
|
138
|
+
|
139
|
+
DEPENDENCIES
|
140
|
+
qravan!
|
141
|
+
|
142
|
+
BUNDLED WITH
|
143
|
+
2.2.22
|
data/LICENSE
ADDED
data/README.md
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
# Qravan
|
2
|
+
Qravan — сервер для быстрого создания API обмена данными, консолидирующий различные источники с SQL-интерфейсами.
|
3
|
+
|
4
|
+
![](assets/images/qravan.png)
|
5
|
+
## Установка
|
6
|
+
|
7
|
+
Добавить строку ниже в свой Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'qravan'
|
11
|
+
```
|
12
|
+
|
13
|
+
Потом выполнить:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Или установить просто как Gem (предпочтительно):
|
18
|
+
|
19
|
+
$ gem install qravan
|
20
|
+
|
21
|
+
## Запуск
|
22
|
+
Запустить сервер Qravan:
|
23
|
+
|
24
|
+
$ qravan
|
25
|
+
|
26
|
+
Сервер станет доступен по адресу `http://localhost:3300/`
|
27
|
+
|
28
|
+
## Методы сервера
|
29
|
+
Сервер содержит следующие методы:
|
30
|
+
1. GET /ping — проверить запусщенность сервера (ответ PONG!)
|
31
|
+
2. GET /models — список загруженных моделей
|
32
|
+
3. GET /sources — список загруженных источников
|
33
|
+
4. POST /data — выполнить запрос
|
34
|
+
|
35
|
+
|
36
|
+
## Настройка моделей данных и ресурсов
|
37
|
+
### Модели
|
38
|
+
Модели данных описываются в соответствии со спецификацией в формате
|
39
|
+
YAML в папке `models/[model_name]/[model_version x.x]/model.yaml`
|
40
|
+
|
41
|
+
Версионирование моделей должно осуществляться в двухразрядном формате.
|
42
|
+
По-умолчанию сервер запускает модель по симлинку с `current`.
|
43
|
+
|
44
|
+
### Ресурсы
|
45
|
+
Источники описывются также в соответствии со спецификацией в формате
|
46
|
+
YAML в папке `sources/[source_name]/[source_version x.x]/source.yaml`
|
47
|
+
|
48
|
+
Версионирование источников должно осуществляться в двухразрядном формате.
|
49
|
+
По-умолчанию сервер запускает источники по симлинку с `current`.
|
50
|
+
|
51
|
+
```
|
52
|
+
qravan
|
53
|
+
│ README.md
|
54
|
+
│ credentials.yaml
|
55
|
+
│
|
56
|
+
└─models
|
57
|
+
│ └─base
|
58
|
+
│ │ │ current
|
59
|
+
│ │ └─1.0
|
60
|
+
│ │ │ model.yaml
|
61
|
+
│ │
|
62
|
+
│ └─vehicles
|
63
|
+
│ │ current
|
64
|
+
│ └─1.0
|
65
|
+
│ │ └─ model.yaml
|
66
|
+
│ └─2.0
|
67
|
+
│ └─ model.yaml
|
68
|
+
│
|
69
|
+
└─sources
|
70
|
+
│ └─vehicles
|
71
|
+
│ │ current
|
72
|
+
│ └─1.0
|
73
|
+
│ │ └─ source.yaml
|
74
|
+
│ └─2.0
|
75
|
+
│ └─ source.yaml
|
76
|
+
```
|
77
|
+
## Пример использования
|
78
|
+
|
79
|
+
Запрос объединенных данных о владельце автомобиля из Prostore и Postgres:
|
80
|
+
```json
|
81
|
+
{
|
82
|
+
"query":{
|
83
|
+
"driver":{
|
84
|
+
"conditions":{
|
85
|
+
"DriverLicenseSerNum":"abc",
|
86
|
+
"norm_DriverLicenseSerNum":"5"
|
87
|
+
},
|
88
|
+
"attributes":[
|
89
|
+
"DriverLastname",
|
90
|
+
"DriverFirstname",
|
91
|
+
"DriverMiddlename",
|
92
|
+
"Driverlicenseid"
|
93
|
+
]
|
94
|
+
},
|
95
|
+
"driver_license":{
|
96
|
+
"conditions":{
|
97
|
+
"DriverLicenseSerNum":"abc",
|
98
|
+
"norm_DriverLicenseSerNum":"3"
|
99
|
+
},
|
100
|
+
"attributes":[
|
101
|
+
"DriverLastname",
|
102
|
+
"DriverFirstname",
|
103
|
+
"DriverMiddlename",
|
104
|
+
"Driverlicenseid"
|
105
|
+
]
|
106
|
+
}
|
107
|
+
},
|
108
|
+
"credentials":{
|
109
|
+
"system":{
|
110
|
+
"mnemonic":"117bed7f-1c07-4079-a446-1161588db4e5",
|
111
|
+
"instance_id":"ccb4a88f-f44b-43e7-8a97-3e45c8345e90",
|
112
|
+
"user_id":"5ed38461-0907-486a-930a-7b443482932c"
|
113
|
+
},
|
114
|
+
"request":{
|
115
|
+
"id":"df5a0073-c6be-4d8c-8eb2-9b2f4188a429",
|
116
|
+
"sub_id":"0cdb59ce-224b-4118-8da1-c5ea08a5d955",
|
117
|
+
"name":"driver_data",
|
118
|
+
"purpose_id":"ed1170f1-3caa-4985-aa38-c9c5a190b770",
|
119
|
+
"audit":"false",
|
120
|
+
"audit_id":"fc1048fe-323d-4eeb-92df-5710b3d1d100",
|
121
|
+
"audit_token":"39e47aac-45d2-44c1-8c26-2d9b28b1703b"
|
122
|
+
},
|
123
|
+
"signature":{
|
124
|
+
"digest": null,
|
125
|
+
"signature": null
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}
|
129
|
+
```
|
130
|
+
|
131
|
+
Ответ для данного запроса будет иметь вид:
|
132
|
+
```json
|
133
|
+
{
|
134
|
+
"response": [
|
135
|
+
{
|
136
|
+
"driver": [
|
137
|
+
[
|
138
|
+
{
|
139
|
+
"driverlastname": "Сидоров",
|
140
|
+
"driverfirstname": "Олег",
|
141
|
+
"drivermiddlename": "Львович",
|
142
|
+
"driverlicenseid": 2222
|
143
|
+
}
|
144
|
+
],
|
145
|
+
{
|
146
|
+
"time": "REST Duration: 0.053709s "
|
147
|
+
}
|
148
|
+
]
|
149
|
+
},
|
150
|
+
{
|
151
|
+
"driver_license": [
|
152
|
+
{
|
153
|
+
"driverlastname": "Петречук",
|
154
|
+
"driverfirstname": "Петр",
|
155
|
+
"drivermiddlename": "Петрович",
|
156
|
+
"driverlicenseid": 2
|
157
|
+
},
|
158
|
+
{
|
159
|
+
"time": "DB Duration: 0.010184s"
|
160
|
+
}
|
161
|
+
]
|
162
|
+
}
|
163
|
+
],
|
164
|
+
"credentials": {
|
165
|
+
"response": {
|
166
|
+
"id": "c11ba197-ae96-4a6a-bc11-a3464d54496c",
|
167
|
+
"sub_id": "50bcef8c-ef6e-4c6e-a893-4b42641919be",
|
168
|
+
"started_at": "2023-01-19 00:34:39 +0300",
|
169
|
+
"finished_at": "2023-01-19 00:34:39 +0300"
|
170
|
+
},
|
171
|
+
"system": {
|
172
|
+
"mnemonic": "117bed7f-1c07-4079-a446-1161588db4e5",
|
173
|
+
"instance_id": "ccb4a88f-f44b-43e7-8a97-3e45c8345e90",
|
174
|
+
"user_id": "5ed38461-0907-486a-930a-7b443482932c"
|
175
|
+
},
|
176
|
+
"request": {
|
177
|
+
"id": "df5a0073-c6be-4d8c-8eb2-9b2f4188a429",
|
178
|
+
"sub_id": "0cdb59ce-224b-4118-8da1-c5ea08a5d955",
|
179
|
+
"name": "driver_data",
|
180
|
+
"purpose_id": "ed1170f1-3caa-4985-aa38-c9c5a190b770",
|
181
|
+
"audit": "false",
|
182
|
+
"audit_id": "fc1048fe-323d-4eeb-92df-5710b3d1d100",
|
183
|
+
"audit_token": "39e47aac-45d2-44c1-8c26-2d9b28b1703b"
|
184
|
+
},
|
185
|
+
"signature": {
|
186
|
+
"digest": null,
|
187
|
+
"signature": null
|
188
|
+
}
|
189
|
+
}
|
190
|
+
}
|
191
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
require "rubocop/rake_task"
|
9
|
+
|
10
|
+
RuboCop::RakeTask.new
|
11
|
+
|
12
|
+
require "rake/extensiontask"
|
13
|
+
|
14
|
+
task build: :compile
|
15
|
+
|
16
|
+
Rake::ExtensionTask.new("qravan") do |ext|
|
17
|
+
ext.lib_dir = "lib/qravan"
|
18
|
+
end
|
19
|
+
|
20
|
+
task default: %i[clobber compile spec clean install] # rubocop
|
21
|
+
|
22
|
+
GEM_NAME = "qravan"
|
23
|
+
GEM_VERSION = "0.1.0"
|
24
|
+
|
25
|
+
task :build do
|
26
|
+
system "gem build #{GEM_NAME}.gemspec"
|
27
|
+
end
|
28
|
+
|
29
|
+
task install: :build do
|
30
|
+
system "gem install #{GEM_NAME}-#{GEM_VERSION}.gem"
|
31
|
+
end
|
32
|
+
|
33
|
+
task publish: :build do
|
34
|
+
system "gem push #{GEM_NAME}-#{GEM_VERSION}.gem"
|
35
|
+
end
|
36
|
+
|
37
|
+
task :clean do
|
38
|
+
system "rm *.gem"
|
39
|
+
end
|
Binary file
|
Binary file
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "qravan"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/config.ru
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file is used by Rack-based servers to start the application.
|
4
|
+
# use Rack::Deflater
|
5
|
+
|
6
|
+
require "bundler/setup"
|
7
|
+
require "qravan"
|
8
|
+
|
9
|
+
Console.logger.info Qravan::BANNER
|
10
|
+
Qravan::CARGO = Qravan::Cargo.new
|
11
|
+
|
12
|
+
qravan = Rack::Builder.new do
|
13
|
+
|
14
|
+
# use Rack::ShowExceptions
|
15
|
+
use Rack::Logger
|
16
|
+
|
17
|
+
map "/data" do
|
18
|
+
use Rack::Lint
|
19
|
+
run Qravan::Query.freeze.new(Qravan::CARGO)
|
20
|
+
end
|
21
|
+
|
22
|
+
map "/model" do
|
23
|
+
use Rack::Lint
|
24
|
+
run Qravan::Model.freeze.new(Qravan::CARGO)
|
25
|
+
end
|
26
|
+
|
27
|
+
map "/spec" do
|
28
|
+
use Rack::Lint
|
29
|
+
run Qravan::Spec.new
|
30
|
+
end
|
31
|
+
|
32
|
+
map "/sources" do
|
33
|
+
use Rack::Lint
|
34
|
+
run Qravan::Source.freeze.new(Qravan::CARGO)
|
35
|
+
end
|
36
|
+
|
37
|
+
map "/ping" do
|
38
|
+
use Rack::Lint
|
39
|
+
run do |env|
|
40
|
+
[200, {}, ["PONG!"]]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
run qravan
|
data/examples/queries.md
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
# Примеры запросов Qravan
|
2
|
+
|
3
|
+
Запрос объединенных данных о владельце автомобиля из Prostore и Postgres:
|
4
|
+
```json
|
5
|
+
{
|
6
|
+
"query":{
|
7
|
+
"driverlicense":{
|
8
|
+
"conditions":{
|
9
|
+
"DriverLicenseSerNum":"abc",
|
10
|
+
"norm_DriverLicenseSerNum":"5"
|
11
|
+
},
|
12
|
+
"attributes":[
|
13
|
+
"DriverLastname",
|
14
|
+
"DriverFirstname",
|
15
|
+
"DriverMiddlename",
|
16
|
+
"Driverlicenseid"
|
17
|
+
],
|
18
|
+
"source": "prostore"
|
19
|
+
},
|
20
|
+
"driverlicense_new":{
|
21
|
+
"conditions":{
|
22
|
+
"DriverLicenseSerNum":"abc",
|
23
|
+
"norm_DriverLicenseSerNum":"3"
|
24
|
+
},
|
25
|
+
"attributes":[
|
26
|
+
"DriverLastname",
|
27
|
+
"DriverFirstname",
|
28
|
+
"DriverMiddlename",
|
29
|
+
"Driverlicenseid"
|
30
|
+
],
|
31
|
+
"source": "postgres"
|
32
|
+
}
|
33
|
+
},
|
34
|
+
"credentials":{
|
35
|
+
"system":{
|
36
|
+
"mnemonic":"117bed7f-1c07-4079-a446-1161588db4e5",
|
37
|
+
"instance_id":"ccb4a88f-f44b-43e7-8a97-3e45c8345e90",
|
38
|
+
"user_id":"5ed38461-0907-486a-930a-7b443482932c"
|
39
|
+
},
|
40
|
+
"request":{
|
41
|
+
"id":"df5a0073-c6be-4d8c-8eb2-9b2f4188a429",
|
42
|
+
"sub_id":"0cdb59ce-224b-4118-8da1-c5ea08a5d955",
|
43
|
+
"name":"driver_data",
|
44
|
+
"purpose_id":"ed1170f1-3caa-4985-aa38-c9c5a190b770",
|
45
|
+
"audit":"false",
|
46
|
+
"audit_id":"fc1048fe-323d-4eeb-92df-5710b3d1d100",
|
47
|
+
"audit_token":"39e47aac-45d2-44c1-8c26-2d9b28b1703b"
|
48
|
+
},
|
49
|
+
"signature":{
|
50
|
+
"digest": null,
|
51
|
+
"signature": null
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
```
|
56
|
+
|
57
|
+
Ответ для данного запроса будет иметь вид:
|
58
|
+
```json
|
59
|
+
{
|
60
|
+
"response": [
|
61
|
+
{
|
62
|
+
"driverlicense": [
|
63
|
+
[
|
64
|
+
{
|
65
|
+
"driverlastname": "Петров",
|
66
|
+
"driverfirstname": "Иван",
|
67
|
+
"drivermiddlename": "Иванович",
|
68
|
+
"driverlicenseid": 1111
|
69
|
+
}
|
70
|
+
],
|
71
|
+
{
|
72
|
+
"time": "Duration: 0.052415s for 1 (RPS: 19 r/s)"
|
73
|
+
}
|
74
|
+
]
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"driverlicense_new": [
|
78
|
+
{
|
79
|
+
"driverlastname": "Евгеничук",
|
80
|
+
"driverfirstname": "Евгений",
|
81
|
+
"drivermiddlename": "Олегович",
|
82
|
+
"driverlicenseid": 333
|
83
|
+
}
|
84
|
+
]
|
85
|
+
}
|
86
|
+
],
|
87
|
+
"credentials": {
|
88
|
+
"response": {
|
89
|
+
"id": null,
|
90
|
+
"sub_id": null,
|
91
|
+
"started_at": null,
|
92
|
+
"finished_at": null
|
93
|
+
},
|
94
|
+
"system": {
|
95
|
+
"mnemonic": "117bed7f-1c07-4079-a446-1161588db4e5",
|
96
|
+
"instance_id": "ccb4a88f-f44b-43e7-8a97-3e45c8345e90",
|
97
|
+
"user_id": "5ed38461-0907-486a-930a-7b443482932c"
|
98
|
+
},
|
99
|
+
"request": {
|
100
|
+
"id": "df5a0073-c6be-4d8c-8eb2-9b2f4188a429",
|
101
|
+
"sub_id": "0cdb59ce-224b-4118-8da1-c5ea08a5d955",
|
102
|
+
"name": "driver_data",
|
103
|
+
"purpose_id": "ed1170f1-3caa-4985-aa38-c9c5a190b770",
|
104
|
+
"audit": "false",
|
105
|
+
"audit_id": "fc1048fe-323d-4eeb-92df-5710b3d1d100",
|
106
|
+
"audit_token": "39e47aac-45d2-44c1-8c26-2d9b28b1703b"
|
107
|
+
},
|
108
|
+
"signature": {
|
109
|
+
"digest": null,
|
110
|
+
"signature": null
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
114
|
+
```
|
data/exe/qravan
ADDED