scribe 0.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.
@@ -0,0 +1,29 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2
+
3
+ class ScribeTest < Test::Unit::TestCase
4
+ def setup
5
+ @scribe = Scribe.new
6
+ end
7
+
8
+ def test_logging
9
+ @scribe.log("test_logging")
10
+ assert_equal "test_logging", last_line("Ruby")
11
+ @scribe.log("test_logging with category", "Test")
12
+ assert_equal "test_logging with category", last_line("Test")
13
+ end
14
+
15
+ def test_batch
16
+ @scribe.log("test_batch 1")
17
+ @scribe.batch do
18
+ @scribe.log("test_batch 2")
19
+ @scribe.log("test_batch 3")
20
+ assert_not_equal "test_batch 3", last_line("Ruby")
21
+ end
22
+ assert_equal "test_batch 3", last_line("Ruby")
23
+ end
24
+
25
+ def last_line(category)
26
+ sleep(3)
27
+ `tail -n1 /tmp/scribetest/#{category}/#{category}_current`.chomp
28
+ end
29
+ end
@@ -0,0 +1,14 @@
1
+
2
+ require 'test/unit'
3
+ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/scribe"
4
+ begin; require 'ruby-debug'; rescue LoadError; end
5
+
6
+ begin
7
+ @test_client = Scribe.new
8
+ rescue Thrift::TransportException => e
9
+ #FIXME Make server automatically start if not running
10
+ if e.message =~ /Could not connect/
11
+ puts "*** Please start the Scribe server by running 'rake scribe'. ***"
12
+ exit 1
13
+ end
14
+ end
@@ -0,0 +1,688 @@
1
+ #
2
+ # Autogenerated by Thrift
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require 'fb303_types'
9
+
10
+ module FacebookService
11
+ class Client
12
+ include ::Thrift::Client
13
+
14
+ def getName()
15
+ send_getName()
16
+ return recv_getName()
17
+ end
18
+
19
+ def send_getName()
20
+ send_message('getName', GetName_args)
21
+ end
22
+
23
+ def recv_getName()
24
+ result = receive_message(GetName_result)
25
+ return result.success unless result.success.nil?
26
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getName failed: unknown result')
27
+ end
28
+
29
+ def getVersion()
30
+ send_getVersion()
31
+ return recv_getVersion()
32
+ end
33
+
34
+ def send_getVersion()
35
+ send_message('getVersion', GetVersion_args)
36
+ end
37
+
38
+ def recv_getVersion()
39
+ result = receive_message(GetVersion_result)
40
+ return result.success unless result.success.nil?
41
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getVersion failed: unknown result')
42
+ end
43
+
44
+ def getStatus()
45
+ send_getStatus()
46
+ return recv_getStatus()
47
+ end
48
+
49
+ def send_getStatus()
50
+ send_message('getStatus', GetStatus_args)
51
+ end
52
+
53
+ def recv_getStatus()
54
+ result = receive_message(GetStatus_result)
55
+ return result.success unless result.success.nil?
56
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getStatus failed: unknown result')
57
+ end
58
+
59
+ def getStatusDetails()
60
+ send_getStatusDetails()
61
+ return recv_getStatusDetails()
62
+ end
63
+
64
+ def send_getStatusDetails()
65
+ send_message('getStatusDetails', GetStatusDetails_args)
66
+ end
67
+
68
+ def recv_getStatusDetails()
69
+ result = receive_message(GetStatusDetails_result)
70
+ return result.success unless result.success.nil?
71
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getStatusDetails failed: unknown result')
72
+ end
73
+
74
+ def getCounters()
75
+ send_getCounters()
76
+ return recv_getCounters()
77
+ end
78
+
79
+ def send_getCounters()
80
+ send_message('getCounters', GetCounters_args)
81
+ end
82
+
83
+ def recv_getCounters()
84
+ result = receive_message(GetCounters_result)
85
+ return result.success unless result.success.nil?
86
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getCounters failed: unknown result')
87
+ end
88
+
89
+ def getCounter(key)
90
+ send_getCounter(key)
91
+ return recv_getCounter()
92
+ end
93
+
94
+ def send_getCounter(key)
95
+ send_message('getCounter', GetCounter_args, :key => key)
96
+ end
97
+
98
+ def recv_getCounter()
99
+ result = receive_message(GetCounter_result)
100
+ return result.success unless result.success.nil?
101
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getCounter failed: unknown result')
102
+ end
103
+
104
+ def setOption(key, value)
105
+ send_setOption(key, value)
106
+ recv_setOption()
107
+ end
108
+
109
+ def send_setOption(key, value)
110
+ send_message('setOption', SetOption_args, :key => key, :value => value)
111
+ end
112
+
113
+ def recv_setOption()
114
+ result = receive_message(SetOption_result)
115
+ return
116
+ end
117
+
118
+ def getOption(key)
119
+ send_getOption(key)
120
+ return recv_getOption()
121
+ end
122
+
123
+ def send_getOption(key)
124
+ send_message('getOption', GetOption_args, :key => key)
125
+ end
126
+
127
+ def recv_getOption()
128
+ result = receive_message(GetOption_result)
129
+ return result.success unless result.success.nil?
130
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getOption failed: unknown result')
131
+ end
132
+
133
+ def getOptions()
134
+ send_getOptions()
135
+ return recv_getOptions()
136
+ end
137
+
138
+ def send_getOptions()
139
+ send_message('getOptions', GetOptions_args)
140
+ end
141
+
142
+ def recv_getOptions()
143
+ result = receive_message(GetOptions_result)
144
+ return result.success unless result.success.nil?
145
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getOptions failed: unknown result')
146
+ end
147
+
148
+ def getCpuProfile(profileDurationInSec)
149
+ send_getCpuProfile(profileDurationInSec)
150
+ return recv_getCpuProfile()
151
+ end
152
+
153
+ def send_getCpuProfile(profileDurationInSec)
154
+ send_message('getCpuProfile', GetCpuProfile_args, :profileDurationInSec => profileDurationInSec)
155
+ end
156
+
157
+ def recv_getCpuProfile()
158
+ result = receive_message(GetCpuProfile_result)
159
+ return result.success unless result.success.nil?
160
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getCpuProfile failed: unknown result')
161
+ end
162
+
163
+ def aliveSince()
164
+ send_aliveSince()
165
+ return recv_aliveSince()
166
+ end
167
+
168
+ def send_aliveSince()
169
+ send_message('aliveSince', AliveSince_args)
170
+ end
171
+
172
+ def recv_aliveSince()
173
+ result = receive_message(AliveSince_result)
174
+ return result.success unless result.success.nil?
175
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'aliveSince failed: unknown result')
176
+ end
177
+
178
+ def reinitialize()
179
+ send_reinitialize()
180
+ end
181
+
182
+ def send_reinitialize()
183
+ send_message('reinitialize', Reinitialize_args)
184
+ end
185
+ def shutdown()
186
+ send_shutdown()
187
+ end
188
+
189
+ def send_shutdown()
190
+ send_message('shutdown', Shutdown_args)
191
+ end
192
+ end
193
+
194
+ class Processor
195
+ include ::Thrift::Processor
196
+
197
+ def process_getName(seqid, iprot, oprot)
198
+ args = read_args(iprot, GetName_args)
199
+ result = GetName_result.new()
200
+ result.success = @handler.getName()
201
+ write_result(result, oprot, 'getName', seqid)
202
+ end
203
+
204
+ def process_getVersion(seqid, iprot, oprot)
205
+ args = read_args(iprot, GetVersion_args)
206
+ result = GetVersion_result.new()
207
+ result.success = @handler.getVersion()
208
+ write_result(result, oprot, 'getVersion', seqid)
209
+ end
210
+
211
+ def process_getStatus(seqid, iprot, oprot)
212
+ args = read_args(iprot, GetStatus_args)
213
+ result = GetStatus_result.new()
214
+ result.success = @handler.getStatus()
215
+ write_result(result, oprot, 'getStatus', seqid)
216
+ end
217
+
218
+ def process_getStatusDetails(seqid, iprot, oprot)
219
+ args = read_args(iprot, GetStatusDetails_args)
220
+ result = GetStatusDetails_result.new()
221
+ result.success = @handler.getStatusDetails()
222
+ write_result(result, oprot, 'getStatusDetails', seqid)
223
+ end
224
+
225
+ def process_getCounters(seqid, iprot, oprot)
226
+ args = read_args(iprot, GetCounters_args)
227
+ result = GetCounters_result.new()
228
+ result.success = @handler.getCounters()
229
+ write_result(result, oprot, 'getCounters', seqid)
230
+ end
231
+
232
+ def process_getCounter(seqid, iprot, oprot)
233
+ args = read_args(iprot, GetCounter_args)
234
+ result = GetCounter_result.new()
235
+ result.success = @handler.getCounter(args.key)
236
+ write_result(result, oprot, 'getCounter', seqid)
237
+ end
238
+
239
+ def process_setOption(seqid, iprot, oprot)
240
+ args = read_args(iprot, SetOption_args)
241
+ result = SetOption_result.new()
242
+ @handler.setOption(args.key, args.value)
243
+ write_result(result, oprot, 'setOption', seqid)
244
+ end
245
+
246
+ def process_getOption(seqid, iprot, oprot)
247
+ args = read_args(iprot, GetOption_args)
248
+ result = GetOption_result.new()
249
+ result.success = @handler.getOption(args.key)
250
+ write_result(result, oprot, 'getOption', seqid)
251
+ end
252
+
253
+ def process_getOptions(seqid, iprot, oprot)
254
+ args = read_args(iprot, GetOptions_args)
255
+ result = GetOptions_result.new()
256
+ result.success = @handler.getOptions()
257
+ write_result(result, oprot, 'getOptions', seqid)
258
+ end
259
+
260
+ def process_getCpuProfile(seqid, iprot, oprot)
261
+ args = read_args(iprot, GetCpuProfile_args)
262
+ result = GetCpuProfile_result.new()
263
+ result.success = @handler.getCpuProfile(args.profileDurationInSec)
264
+ write_result(result, oprot, 'getCpuProfile', seqid)
265
+ end
266
+
267
+ def process_aliveSince(seqid, iprot, oprot)
268
+ args = read_args(iprot, AliveSince_args)
269
+ result = AliveSince_result.new()
270
+ result.success = @handler.aliveSince()
271
+ write_result(result, oprot, 'aliveSince', seqid)
272
+ end
273
+
274
+ def process_reinitialize(seqid, iprot, oprot)
275
+ args = read_args(iprot, Reinitialize_args)
276
+ @handler.reinitialize()
277
+ return
278
+ end
279
+
280
+ def process_shutdown(seqid, iprot, oprot)
281
+ args = read_args(iprot, Shutdown_args)
282
+ @handler.shutdown()
283
+ return
284
+ end
285
+
286
+ end
287
+
288
+ # HELPER FUNCTIONS AND STRUCTURES
289
+
290
+ class GetName_args
291
+ include ::Thrift::Struct
292
+
293
+ FIELDS = {
294
+
295
+ }
296
+
297
+ def struct_fields; FIELDS; end
298
+
299
+ def validate
300
+ end
301
+
302
+ end
303
+
304
+ class GetName_result
305
+ include ::Thrift::Struct
306
+ SUCCESS = 0
307
+
308
+ ::Thrift::Struct.field_accessor self, :success
309
+ FIELDS = {
310
+ SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'}
311
+ }
312
+
313
+ def struct_fields; FIELDS; end
314
+
315
+ def validate
316
+ end
317
+
318
+ end
319
+
320
+ class GetVersion_args
321
+ include ::Thrift::Struct
322
+
323
+ FIELDS = {
324
+
325
+ }
326
+
327
+ def struct_fields; FIELDS; end
328
+
329
+ def validate
330
+ end
331
+
332
+ end
333
+
334
+ class GetVersion_result
335
+ include ::Thrift::Struct
336
+ SUCCESS = 0
337
+
338
+ ::Thrift::Struct.field_accessor self, :success
339
+ FIELDS = {
340
+ SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'}
341
+ }
342
+
343
+ def struct_fields; FIELDS; end
344
+
345
+ def validate
346
+ end
347
+
348
+ end
349
+
350
+ class GetStatus_args
351
+ include ::Thrift::Struct
352
+
353
+ FIELDS = {
354
+
355
+ }
356
+
357
+ def struct_fields; FIELDS; end
358
+
359
+ def validate
360
+ end
361
+
362
+ end
363
+
364
+ class GetStatus_result
365
+ include ::Thrift::Struct
366
+ SUCCESS = 0
367
+
368
+ ::Thrift::Struct.field_accessor self, :success
369
+ FIELDS = {
370
+ SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success', :enum_class => Fb_status}
371
+ }
372
+
373
+ def struct_fields; FIELDS; end
374
+
375
+ def validate
376
+ unless @success.nil? || Fb_status::VALID_VALUES.include?(@success)
377
+ raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field success!')
378
+ end
379
+ end
380
+
381
+ end
382
+
383
+ class GetStatusDetails_args
384
+ include ::Thrift::Struct
385
+
386
+ FIELDS = {
387
+
388
+ }
389
+
390
+ def struct_fields; FIELDS; end
391
+
392
+ def validate
393
+ end
394
+
395
+ end
396
+
397
+ class GetStatusDetails_result
398
+ include ::Thrift::Struct
399
+ SUCCESS = 0
400
+
401
+ ::Thrift::Struct.field_accessor self, :success
402
+ FIELDS = {
403
+ SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'}
404
+ }
405
+
406
+ def struct_fields; FIELDS; end
407
+
408
+ def validate
409
+ end
410
+
411
+ end
412
+
413
+ class GetCounters_args
414
+ include ::Thrift::Struct
415
+
416
+ FIELDS = {
417
+
418
+ }
419
+
420
+ def struct_fields; FIELDS; end
421
+
422
+ def validate
423
+ end
424
+
425
+ end
426
+
427
+ class GetCounters_result
428
+ include ::Thrift::Struct
429
+ SUCCESS = 0
430
+
431
+ ::Thrift::Struct.field_accessor self, :success
432
+ FIELDS = {
433
+ SUCCESS => {:type => ::Thrift::Types::MAP, :name => 'success', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::I64}}
434
+ }
435
+
436
+ def struct_fields; FIELDS; end
437
+
438
+ def validate
439
+ end
440
+
441
+ end
442
+
443
+ class GetCounter_args
444
+ include ::Thrift::Struct
445
+ KEY = 1
446
+
447
+ ::Thrift::Struct.field_accessor self, :key
448
+ FIELDS = {
449
+ KEY => {:type => ::Thrift::Types::STRING, :name => 'key'}
450
+ }
451
+
452
+ def struct_fields; FIELDS; end
453
+
454
+ def validate
455
+ end
456
+
457
+ end
458
+
459
+ class GetCounter_result
460
+ include ::Thrift::Struct
461
+ SUCCESS = 0
462
+
463
+ ::Thrift::Struct.field_accessor self, :success
464
+ FIELDS = {
465
+ SUCCESS => {:type => ::Thrift::Types::I64, :name => 'success'}
466
+ }
467
+
468
+ def struct_fields; FIELDS; end
469
+
470
+ def validate
471
+ end
472
+
473
+ end
474
+
475
+ class SetOption_args
476
+ include ::Thrift::Struct
477
+ KEY = 1
478
+ VALUE = 2
479
+
480
+ ::Thrift::Struct.field_accessor self, :key, :value
481
+ FIELDS = {
482
+ KEY => {:type => ::Thrift::Types::STRING, :name => 'key'},
483
+ VALUE => {:type => ::Thrift::Types::STRING, :name => 'value'}
484
+ }
485
+
486
+ def struct_fields; FIELDS; end
487
+
488
+ def validate
489
+ end
490
+
491
+ end
492
+
493
+ class SetOption_result
494
+ include ::Thrift::Struct
495
+
496
+ FIELDS = {
497
+
498
+ }
499
+
500
+ def struct_fields; FIELDS; end
501
+
502
+ def validate
503
+ end
504
+
505
+ end
506
+
507
+ class GetOption_args
508
+ include ::Thrift::Struct
509
+ KEY = 1
510
+
511
+ ::Thrift::Struct.field_accessor self, :key
512
+ FIELDS = {
513
+ KEY => {:type => ::Thrift::Types::STRING, :name => 'key'}
514
+ }
515
+
516
+ def struct_fields; FIELDS; end
517
+
518
+ def validate
519
+ end
520
+
521
+ end
522
+
523
+ class GetOption_result
524
+ include ::Thrift::Struct
525
+ SUCCESS = 0
526
+
527
+ ::Thrift::Struct.field_accessor self, :success
528
+ FIELDS = {
529
+ SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'}
530
+ }
531
+
532
+ def struct_fields; FIELDS; end
533
+
534
+ def validate
535
+ end
536
+
537
+ end
538
+
539
+ class GetOptions_args
540
+ include ::Thrift::Struct
541
+
542
+ FIELDS = {
543
+
544
+ }
545
+
546
+ def struct_fields; FIELDS; end
547
+
548
+ def validate
549
+ end
550
+
551
+ end
552
+
553
+ class GetOptions_result
554
+ include ::Thrift::Struct
555
+ SUCCESS = 0
556
+
557
+ ::Thrift::Struct.field_accessor self, :success
558
+ FIELDS = {
559
+ SUCCESS => {:type => ::Thrift::Types::MAP, :name => 'success', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}}
560
+ }
561
+
562
+ def struct_fields; FIELDS; end
563
+
564
+ def validate
565
+ end
566
+
567
+ end
568
+
569
+ class GetCpuProfile_args
570
+ include ::Thrift::Struct
571
+ PROFILEDURATIONINSEC = 1
572
+
573
+ ::Thrift::Struct.field_accessor self, :profileDurationInSec
574
+ FIELDS = {
575
+ PROFILEDURATIONINSEC => {:type => ::Thrift::Types::I32, :name => 'profileDurationInSec'}
576
+ }
577
+
578
+ def struct_fields; FIELDS; end
579
+
580
+ def validate
581
+ end
582
+
583
+ end
584
+
585
+ class GetCpuProfile_result
586
+ include ::Thrift::Struct
587
+ SUCCESS = 0
588
+
589
+ ::Thrift::Struct.field_accessor self, :success
590
+ FIELDS = {
591
+ SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'}
592
+ }
593
+
594
+ def struct_fields; FIELDS; end
595
+
596
+ def validate
597
+ end
598
+
599
+ end
600
+
601
+ class AliveSince_args
602
+ include ::Thrift::Struct
603
+
604
+ FIELDS = {
605
+
606
+ }
607
+
608
+ def struct_fields; FIELDS; end
609
+
610
+ def validate
611
+ end
612
+
613
+ end
614
+
615
+ class AliveSince_result
616
+ include ::Thrift::Struct
617
+ SUCCESS = 0
618
+
619
+ ::Thrift::Struct.field_accessor self, :success
620
+ FIELDS = {
621
+ SUCCESS => {:type => ::Thrift::Types::I64, :name => 'success'}
622
+ }
623
+
624
+ def struct_fields; FIELDS; end
625
+
626
+ def validate
627
+ end
628
+
629
+ end
630
+
631
+ class Reinitialize_args
632
+ include ::Thrift::Struct
633
+
634
+ FIELDS = {
635
+
636
+ }
637
+
638
+ def struct_fields; FIELDS; end
639
+
640
+ def validate
641
+ end
642
+
643
+ end
644
+
645
+ class Reinitialize_result
646
+ include ::Thrift::Struct
647
+
648
+ FIELDS = {
649
+
650
+ }
651
+
652
+ def struct_fields; FIELDS; end
653
+
654
+ def validate
655
+ end
656
+
657
+ end
658
+
659
+ class Shutdown_args
660
+ include ::Thrift::Struct
661
+
662
+ FIELDS = {
663
+
664
+ }
665
+
666
+ def struct_fields; FIELDS; end
667
+
668
+ def validate
669
+ end
670
+
671
+ end
672
+
673
+ class Shutdown_result
674
+ include ::Thrift::Struct
675
+
676
+ FIELDS = {
677
+
678
+ }
679
+
680
+ def struct_fields; FIELDS; end
681
+
682
+ def validate
683
+ end
684
+
685
+ end
686
+
687
+ end
688
+