agoo 2.7.0 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of agoo might be problematic. Click here for more details.

data/ext/agoo/server.c CHANGED
@@ -27,12 +27,12 @@ struct _agooServer agoo_server = {false};
27
27
  int
28
28
  agoo_server_setup(agooErr err) {
29
29
  long i;
30
-
30
+
31
31
  memset(&agoo_server, 0, sizeof(struct _agooServer));
32
32
  pthread_mutex_init(&agoo_server.up_lock, 0);
33
33
  agoo_server.up_list = NULL;
34
34
  agoo_server.max_push_pending = 32;
35
-
35
+
36
36
  if (AGOO_ERR_OK != agoo_pages_init(err) ||
37
37
  AGOO_ERR_OK != agoo_queue_multi_init(err, &agoo_server.con_queue, 1024, false, true) ||
38
38
  AGOO_ERR_OK != agoo_queue_multi_init(err, &agoo_server.eval_queue, 1024, true, true)) {
@@ -150,7 +150,7 @@ agoo_server_start(agooErr err, const char *app_name, const char *version) {
150
150
  double giveup;
151
151
  int xcnt = 0;
152
152
  int stat;
153
-
153
+
154
154
  if (0 != (stat = pthread_create(&agoo_server.listen_thread, NULL, listen_loop, NULL))) {
155
155
  return agoo_err_set(err, stat, "Failed to create server listener thread. %s", strerror(stat));
156
156
  }
@@ -177,7 +177,7 @@ agoo_server_start(agooErr err, const char *app_name, const char *version) {
177
177
  }
178
178
  if (agoo_info_cat.on) {
179
179
  agooBind b;
180
-
180
+
181
181
  for (b = agoo_server.binds; NULL != b; b = b->next) {
182
182
  agoo_log_cat(&agoo_info_cat, "%s %s with pid %d is listening on %s.", app_name, version, getpid(), b->id);
183
183
  }
@@ -208,7 +208,7 @@ agoo_server_shutdown(const char *app_name, void (*stop)()) {
208
208
  agoo_server.inited = false;
209
209
  if (agoo_server.active) {
210
210
  double giveup = dtime() + 1.0;
211
-
211
+
212
212
  agoo_server.active = false;
213
213
  pthread_detach(agoo_server.listen_thread);
214
214
  for (loop = agoo_server.con_loops; NULL != loop; loop = loop->next) {
data/ext/agoo/text.c CHANGED
@@ -59,14 +59,16 @@ agoo_text_create(const char *str, int len) {
59
59
 
60
60
  agooText
61
61
  agoo_text_dup(agooText t0) {
62
- agooText t = (agooText)AGOO_MALLOC(sizeof(struct _agooText) - AGOO_TEXT_MIN_SIZE + t0->alen + 1);
63
-
64
- if (NULL != t) {
65
- t->len = t0->len;
66
- t->alen = t0->alen;
67
- t->bin = false;
68
- atomic_init(&t->ref_cnt, 0);
69
- memcpy(t->text, t0->text, t0->len + 1);
62
+ agooText t = NULL;
63
+
64
+ if (NULL != t0) {
65
+ if (NULL != (t = (agooText)AGOO_MALLOC(sizeof(struct _agooText) - AGOO_TEXT_MIN_SIZE + t0->alen + 1))) {
66
+ t->len = t0->len;
67
+ t->alen = t0->alen;
68
+ t->bin = false;
69
+ atomic_init(&t->ref_cnt, 0);
70
+ memcpy(t->text, t0->text, t0->len + 1);
71
+ }
70
72
  }
71
73
  return t;
72
74
  }
@@ -99,6 +101,9 @@ agoo_text_release(agooText t) {
99
101
 
100
102
  agooText
101
103
  agoo_text_append(agooText t, const char *s, int len) {
104
+ if (NULL == t) {
105
+ return NULL;
106
+ }
102
107
  if (0 >= len) {
103
108
  len = (int)strlen(s);
104
109
  }
@@ -120,6 +125,9 @@ agoo_text_append(agooText t, const char *s, int len) {
120
125
 
121
126
  agooText
122
127
  agoo_text_append_char(agooText t, const char c) {
128
+ if (NULL == t) {
129
+ return NULL;
130
+ }
123
131
  if (t->alen <= t->len + 1) {
124
132
  long new_len = t->alen + 1 + t->alen / 2;
125
133
  size_t size = sizeof(struct _agooText) - AGOO_TEXT_MIN_SIZE + new_len + 1;
@@ -138,6 +146,9 @@ agoo_text_append_char(agooText t, const char c) {
138
146
 
139
147
  agooText
140
148
  agoo_text_prepend(agooText t, const char *s, int len) {
149
+ if (NULL == t) {
150
+ return NULL;
151
+ }
141
152
  if (0 >= len) {
142
153
  len = (int)strlen(s);
143
154
  }
@@ -160,7 +171,10 @@ agoo_text_prepend(agooText t, const char *s, int len) {
160
171
  agooText
161
172
  agoo_text_append_json(agooText t, const char *s, int len) {
162
173
  size_t jlen;
163
-
174
+
175
+ if (NULL == t) {
176
+ return NULL;
177
+ }
164
178
  if (0 >= len) {
165
179
  len = (int)strlen(s);
166
180
  }
data/lib/agoo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Agoo
3
3
  # Agoo version.
4
- VERSION = '2.7.0'
4
+ VERSION = '2.8.0'
5
5
  end
data/test/graphql_test.rb CHANGED
@@ -18,7 +18,7 @@ class Artist
18
18
  attr_reader :songs
19
19
  attr_reader :origin
20
20
  attr_reader :likes
21
-
21
+
22
22
  def initialize(name, origin)
23
23
  @name = name
24
24
  @songs = []
@@ -65,7 +65,7 @@ class Song
65
65
  attr_reader :duration # integer
66
66
  attr_reader :release # time
67
67
  attr_reader :genre # string
68
-
68
+
69
69
  def initialize(name, artist, duration, release)
70
70
  @name = name
71
71
  @artist = artist
@@ -99,7 +99,6 @@ type Song @ruby(class: "Song") {
99
99
  artist: Artist
100
100
  duration: Int
101
101
  genre: Genre
102
- release: Time
103
102
  }
104
103
 
105
104
  enum Genre {
@@ -109,6 +108,16 @@ enum Genre {
109
108
  }
110
109
  ^
111
110
 
111
+ $extend_sdl = %^
112
+ extend enum Genre {
113
+ JAZZ
114
+ }
115
+
116
+ type Song {
117
+ release: Time
118
+ }
119
+ ^
120
+
112
121
  class Query
113
122
  attr_reader :artists
114
123
 
@@ -139,7 +148,7 @@ class Schema
139
148
  attr_reader :query
140
149
  attr_reader :mutation
141
150
  attr_reader :subscription
142
-
151
+
143
152
  def initialize()
144
153
  # Set up some data for testing.
145
154
  artist = Artist.new('Fazerdaze', ['Morningside', 'Auckland', 'New Zealand'])
@@ -156,11 +165,10 @@ end
156
165
 
157
166
  class GraphQLTest < Minitest::Test
158
167
  @@server_started = false
159
-
160
- SCHEMA_EXPECT = %^type schema @ruby(class: "Schema") {
168
+
169
+ SCHEMA_EXPECT = %^schema @ruby(class: "Schema") {
161
170
  query: Query
162
171
  mutation: Mutation
163
- subscription: Subscription
164
172
  }
165
173
 
166
174
  type Artist @ruby(class: "Artist") {
@@ -172,7 +180,7 @@ type Artist @ruby(class: "Artist") {
172
180
  likes: Int
173
181
  }
174
182
 
175
- type Mutation {
183
+ type Mutation @ruby(class: "Mutation") {
176
184
  like(artist: String!): Artist
177
185
  }
178
186
 
@@ -188,13 +196,11 @@ type Song @ruby(class: "Song") {
188
196
  release: Time
189
197
  }
190
198
 
191
- type Subscription {
192
- }
193
-
194
199
  enum Genre {
195
200
  POP
196
201
  ROCK
197
202
  INDIE
203
+ JAZZ
198
204
  }
199
205
 
200
206
  directive @ruby(class: String!) on SCHEMA | OBJECT
@@ -218,11 +224,11 @@ directive @ruby(class: String!) on SCHEMA | OBJECT
218
224
 
219
225
  Agoo::GraphQL.schema(Schema.new) {
220
226
  Agoo::GraphQL.load($songs_sdl)
227
+ Agoo::GraphQL.load($extend_sdl)
221
228
  }
222
-
223
229
  @@server_started = true
224
230
  end
225
-
231
+
226
232
  def setup
227
233
  if @@server_started == false
228
234
  start_server
@@ -239,7 +245,7 @@ directive @ruby(class: String!) on SCHEMA | OBJECT
239
245
  # TBD introspection
240
246
 
241
247
  ##################################
242
-
248
+
243
249
  def test_load
244
250
  content = Agoo::GraphQL.sdl_dump(with_descriptions: false, all: false)
245
251
  content.force_encoding('UTF-8')
@@ -278,7 +284,7 @@ directive @ruby(class: String!) on SCHEMA | OBJECT
278
284
  assert_equal('application/json', res['Content-Type'])
279
285
  assert_equal(expect, content)
280
286
  end
281
-
287
+
282
288
  def test_variable_query
283
289
  uri = URI('http://localhost:6472/graphql?query={artist(name:"Fazerdaze"){name}}&indent=2')
284
290
  expect = %^{
@@ -290,7 +296,7 @@ directive @ruby(class: String!) on SCHEMA | OBJECT
290
296
  }^
291
297
  req_test(uri, expect)
292
298
  end
293
-
299
+
294
300
  def test_alias_query
295
301
  uri = URI('http://localhost:6472/graphql?query=query withVar($name:String="Fazerdaze"){artist(name:$name){name}}&indent=2')
296
302
  expect = %^{
@@ -302,7 +308,7 @@ directive @ruby(class: String!) on SCHEMA | OBJECT
302
308
  }^
303
309
  req_test(uri, expect)
304
310
  end
305
-
311
+
306
312
  def test_parse_error
307
313
  uri = URI('http://localhost:6472/graphql?query=nonsense')
308
314
  expect = %^{
@@ -316,7 +322,7 @@ directive @ruby(class: String!) on SCHEMA | OBJECT
316
322
  ^
317
323
  req_test(uri, expect, 'errors.0.timestamp')
318
324
  end
319
-
325
+
320
326
  def test_json_vars_query
321
327
  #uri = URI('http://localhost:6472/graphql?query={artist(name:$name){name}}&indent=2&variables={"name":"Fazerdaze"}')
322
328
  uri = URI('http://localhost:6472/graphql?query={artist(name:"Fazerdaze"){name}}&indent=2&variables={"name":"Fazerdaze"}')
@@ -329,7 +335,7 @@ directive @ruby(class: String!) on SCHEMA | OBJECT
329
335
  }^
330
336
  req_test(uri, expect)
331
337
  end
332
-
338
+
333
339
  def test_list_query
334
340
  uri = URI('http://localhost:6472/graphql?query=query withVar($name:String="Fazerdaze"){artist(name:$name){name,songs{name}}}&indent=2')
335
341
  expect = %^{
@@ -656,7 +662,7 @@ query skippy($boo: Boolean = true){
656
662
  }^
657
663
  req_test(uri, expect)
658
664
  end
659
-
665
+
660
666
  def test_intro_of_type
661
667
  uri = URI('http://localhost:6472/graphql?query={__type(name:"[__Type!]"){name,ofType{name}}}&indent=2')
662
668
  expect = %^{
@@ -793,7 +799,7 @@ query skippy($boo: Boolean = true){
793
799
  }^
794
800
  req_test(uri, expect)
795
801
  end
796
-
802
+
797
803
  def test_intro_schema_types
798
804
  uri = URI('http://localhost:6472/graphql?query={__schema{types{name}}}&indent=2')
799
805
  expect = %^{
@@ -806,9 +812,6 @@ query skippy($boo: Boolean = true){
806
812
  {
807
813
  "name":"Int"
808
814
  },
809
- {
810
- "name":"Subscription"
811
- },
812
815
  {
813
816
  "name":"I64"
814
817
  },
@@ -842,6 +845,9 @@ query skippy($boo: Boolean = true){
842
845
  {
843
846
  "name":"Song"
844
847
  },
848
+ {
849
+ "name":"ID"
850
+ },
845
851
  {
846
852
  "name":"Artist"
847
853
  },
@@ -886,7 +892,7 @@ query skippy($boo: Boolean = true){
886
892
  }^
887
893
  req_test(uri, expect)
888
894
  end
889
-
895
+
890
896
  def test_intro_schema_directives
891
897
  uri = URI('http://localhost:6472/graphql?query={__schema{directives{name,locations,args{name}}}}&indent=2')
892
898
  expect = %^{
@@ -949,7 +955,7 @@ query skippy($boo: Boolean = true){
949
955
  }^
950
956
  req_test(uri, expect)
951
957
  end
952
-
958
+
953
959
  def test_mutation
954
960
  uri = URI('http://localhost:6472/graphql?indent=2')
955
961
  body = %^
@@ -988,7 +994,7 @@ mutation {
988
994
  end
989
995
  end
990
996
  end
991
-
997
+
992
998
  def req_test(uri, expect, ignore=nil)
993
999
  req = Net::HTTP::Get.new(uri)
994
1000
  res = Net::HTTP.start(uri.hostname, uri.port) { |h|
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.7.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-29 00:00:00.000000000 Z
11
+ date: 2019-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj