agoo 2.12.1 → 2.14.1

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.
data/ext/agoo/rserver.h CHANGED
@@ -7,10 +7,18 @@
7
7
 
8
8
  #define MAX_WORKERS 32
9
9
 
10
+ typedef struct _rUse {
11
+ struct _rUse *next;
12
+ VALUE clas;
13
+ VALUE *argv;
14
+ int argc;
15
+ } *RUse;
16
+
10
17
  typedef struct _rServer {
11
18
  int worker_cnt;
12
19
  int worker_pids[MAX_WORKERS];
13
20
  VALUE *eval_threads; // Qnil terminated
21
+ RUse uses;
14
22
  } *RServer;
15
23
 
16
24
  extern struct _rServer the_rserver;
data/ext/agoo/server.c CHANGED
@@ -160,8 +160,8 @@ listen_loop(void *x) {
160
160
  //fcntl(client_sock, F_SETFL, FNDELAY);
161
161
  setsockopt(client_sock, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval));
162
162
  setsockopt(client_sock, IPPROTO_TCP, TCP_NODELAY, &optval, sizeof(optval));
163
- agoo_log_cat(&agoo_con_cat, "Server with pid %d accepted connection %llu on %s [%d]",
164
- getpid(), (unsigned long long)cnt, b->id, con->sock);
163
+ agoo_log_cat(&agoo_con_cat, "Server with pid %d accepted connection %llu on %s [%d] from %s",
164
+ getpid(), (unsigned long long)cnt, b->id, con->sock, con->remote);
165
165
 
166
166
  con_cnt = atomic_fetch_add(&agoo_server.con_cnt, 1);
167
167
  if (agoo_server.loop_max > agoo_server.loop_cnt && agoo_server.loop_cnt * LOOP_UP < con_cnt) {
data/ext/agoo/websocket.c CHANGED
@@ -189,6 +189,7 @@ agoo_ws_create_req(agooCon c, long mlen) {
189
189
  c->req->method = (AGOO_WS_OP_BIN == op) ? AGOO_ON_BIN : AGOO_ON_MSG;
190
190
  c->req->upgrade = AGOO_UP_NONE;
191
191
  c->req->up = c->up;
192
+ memcpy(c->req->remote, c->remote, sizeof(c->remote));
192
193
  c->req->res = NULL;
193
194
  if (c->up->on_msg) {
194
195
  c->req->hook = agoo_hook_create(AGOO_NONE, NULL, c->up->ctx, PUSH_HOOK, &agoo_server.eval_queue);
data/lib/agoo.rb CHANGED
@@ -4,6 +4,7 @@ end
4
4
 
5
5
  require 'stringio' # needed for Ruby 2.7
6
6
  require 'agoo/version'
7
+ require 'agoo/graphql'
7
8
  require 'rack/handler/agoo'
8
9
  require 'agoo/agoo' # C extension
9
10
 
@@ -0,0 +1,9 @@
1
+
2
+ module Agoo
3
+ class GraphQL
4
+ end
5
+ end
6
+
7
+ require 'agoo/graphql/arg'
8
+ require 'agoo/graphql/field'
9
+ require 'agoo/graphql/type'
@@ -0,0 +1,13 @@
1
+
2
+ module Agoo
3
+ class GraphQL
4
+
5
+ class Arg
6
+ attr_accessor :name
7
+ attr_accessor :description
8
+ attr_accessor :type_name
9
+ attr_accessor :default_value
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+
2
+ module Agoo
3
+ class GraphQL
4
+
5
+ class Field
6
+ attr_accessor :name
7
+ attr_accessor :description
8
+ attr_accessor :type_name
9
+ attr_accessor :args
10
+ attr_accessor :default_value
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+
2
+ module Agoo
3
+ class GraphQL
4
+
5
+ class Type
6
+ attr_accessor :name
7
+ attr_accessor :description
8
+ attr_accessor :fields
9
+ end
10
+
11
+ end
12
+ end
data/lib/agoo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Agoo
3
3
  # Agoo version.
4
- VERSION = '2.12.1'
4
+ VERSION = '2.14.1'
5
5
  end
@@ -82,7 +82,7 @@ class BaseHandlerTest < Minitest::Test
82
82
  GC.start
83
83
  Agoo::shutdown
84
84
  }
85
-
85
+
86
86
  def test_eval
87
87
  uri = URI('http://localhost:6470/tellme?a=1')
88
88
  req = Net::HTTP::Get.new(uri)
@@ -132,13 +132,13 @@ class BaseHandlerTest < Minitest::Test
132
132
  req['Accept-Encoding'] = '*'
133
133
  req['Accept'] = 'application/json'
134
134
  req['User-Agent'] = 'Ruby'
135
-
135
+
136
136
  res = Net::HTTP.start(uri.hostname, uri.port) { |h|
137
137
  h.request(req)
138
138
  }
139
139
  assert_equal(Net::HTTPNoContent, res.class)
140
140
  end
141
-
141
+
142
142
  def test_put
143
143
  uri = URI('http://localhost:6470/makeme')
144
144
  req = Net::HTTP::Put.new(uri)
@@ -147,7 +147,7 @@ class BaseHandlerTest < Minitest::Test
147
147
  req['Accept'] = 'application/json'
148
148
  req['User-Agent'] = 'Ruby'
149
149
  req.body = 'hello'
150
-
150
+
151
151
  res = Net::HTTP.start(uri.hostname, uri.port) { |h|
152
152
  h.request(req)
153
153
  }
data/test/graphql_test.rb CHANGED
@@ -79,6 +79,7 @@ end
79
79
  $songs_sdl = %^
80
80
  type Query @ruby(class: "Query") {
81
81
  artist(name: String!): Artist
82
+ artists: [Artist!]
82
83
  }
83
84
 
84
85
  type Mutation {
@@ -120,26 +121,30 @@ type Song {
120
121
  ^
121
122
 
122
123
  class Query
123
- attr_reader :artists
124
+ attr_reader :artistHash
124
125
 
125
126
  def initialize(artists)
126
- @artists = artists
127
+ @artistHash = artists
127
128
  end
128
129
 
129
130
  def artist(args)
130
- @artists[args['name']]
131
+ @artistHash[args['name']]
132
+ end
133
+
134
+ def artists(args)
135
+ @artistHash.values
131
136
  end
132
137
  end
133
138
 
134
139
  class Mutation
135
- attr_reader :artists
140
+ attr_reader :artistHash
136
141
 
137
142
  def initialize(artists)
138
- @artists = artists
143
+ @artistHash = artists
139
144
  end
140
145
 
141
146
  def like(args)
142
- artist = @artists[args['artist']]
147
+ artist = @artistHash[args['artist']]
143
148
  artist.like
144
149
  artist
145
150
  end
@@ -187,6 +192,7 @@ type Mutation @ruby(class: "Mutation") {
187
192
 
188
193
  type Query @ruby(class: "Query") {
189
194
  artist(name: String!): Artist
195
+ artists: [Artist!]
190
196
  }
191
197
 
192
198
  type Song @ruby(class: "Song") {
@@ -452,6 +458,30 @@ fragment basic on Artist {
452
458
  post_test(uri, body, 'application/graphql', expect)
453
459
  end
454
460
 
461
+ def test_post_json_fragment
462
+ uri = URI('http://localhost:6472/graphql?indent=2')
463
+ body = %^{
464
+ "query": "fragment basic on Artist {name origin} query list($filter: String) {artists {...basic}}",
465
+ "operationName": "list",
466
+ "variables": {"filters": {}}
467
+ }^
468
+ expect = %^{
469
+ "data":{
470
+ "artists":[
471
+ {
472
+ "name":"Fazerdaze",
473
+ "origin":[
474
+ "Morningside",
475
+ "Auckland",
476
+ "New Zealand"
477
+ ]
478
+ }
479
+ ]
480
+ }
481
+ }^
482
+ post_test(uri, body, 'application/json', expect)
483
+ end
484
+
455
485
  def test_post_inline
456
486
  uri = URI('http://localhost:6472/graphql?indent=2')
457
487
  body = %^
@@ -105,6 +105,7 @@ size=big
105
105
  "PATH_INFO" => "/tellme",
106
106
  "QUERY_STRING" => "a=1",
107
107
  "REQUEST_METHOD" => "GET",
108
+ "REMOTE_ADDR" => "127.0.0.1",
108
109
  "SCRIPT_NAME" => "",
109
110
  "SERVER_NAME" => "localhost",
110
111
  "SERVER_PORT" => "6467",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.12.1
4
+ version: 2.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-17 00:00:00.000000000 Z
11
+ date: 2021-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -34,6 +34,7 @@ description: A fast HTTP server supporting rack.
34
34
  email: peter@ohler.com
35
35
  executables:
36
36
  - agoo
37
+ - agoo_stubs
37
38
  extensions:
38
39
  - ext/agoo/extconf.rb
39
40
  extra_rdoc_files:
@@ -45,6 +46,7 @@ files:
45
46
  - LICENSE
46
47
  - README.md
47
48
  - bin/agoo
49
+ - bin/agoo_stubs
48
50
  - ext/agoo/agoo.c
49
51
  - ext/agoo/atomic.h
50
52
  - ext/agoo/base64.c
@@ -142,6 +144,10 @@ files:
142
144
  - ext/agoo/websocket.c
143
145
  - ext/agoo/websocket.h
144
146
  - lib/agoo.rb
147
+ - lib/agoo/graphql.rb
148
+ - lib/agoo/graphql/arg.rb
149
+ - lib/agoo/graphql/field.rb
150
+ - lib/agoo/graphql/type.rb
145
151
  - lib/agoo/version.rb
146
152
  - lib/rack/handler/agoo.rb
147
153
  - test/base_handler_test.rb
@@ -157,7 +163,7 @@ homepage: https://github.com/ohler55/agoo
157
163
  licenses:
158
164
  - MIT
159
165
  metadata: {}
160
- post_install_message:
166
+ post_install_message:
161
167
  rdoc_options:
162
168
  - "-t"
163
169
  - Agoo
@@ -183,17 +189,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
189
  version: '0'
184
190
  requirements:
185
191
  - Linux or macOS
186
- rubygems_version: 3.1.2
187
- signing_key:
192
+ rubygems_version: 3.2.3
193
+ signing_key:
188
194
  specification_version: 4
189
195
  summary: An HTTP server
190
196
  test_files:
191
- - test/graphql_test.rb
192
- - test/hijack_test.rb
193
- - test/rack_handler_test.rb
194
197
  - test/base_handler_test.rb
195
- - test/log_test.rb
198
+ - test/bind_test.rb
196
199
  - test/domain_test.rb
197
200
  - test/early_hints_test.rb
198
- - test/bind_test.rb
201
+ - test/graphql_test.rb
202
+ - test/hijack_test.rb
203
+ - test/log_test.rb
204
+ - test/rack_handler_test.rb
199
205
  - test/static_test.rb