├── lib ├── scribe │ ├── debug.rb │ └── scribe.rb └── scribe.rb ├── vendor └── gen-rb │ ├── fb303_constants.rb │ ├── scribe_constants.rb │ ├── fb303_types.rb │ ├── scribe_types.rb │ ├── scribe.rb │ └── facebook_service.rb ├── CHANGELOG ├── Manifest ├── test ├── test_helper.rb └── scribe_test.rb ├── conf └── scribe.conf ├── Rakefile ├── README └── LICENSE /lib/scribe/debug.rb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/gen-rb/fb303_constants.rb: -------------------------------------------------------------------------------- 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 'fb303_types' 8 | 9 | -------------------------------------------------------------------------------- /vendor/gen-rb/scribe_constants.rb: -------------------------------------------------------------------------------- 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 'scribe_types' 8 | 9 | -------------------------------------------------------------------------------- /lib/scribe.rb: -------------------------------------------------------------------------------- 1 | 2 | require 'rubygems' 3 | require 'thrift_client' 4 | 5 | HERE = File.expand_path(File.dirname(__FILE__)) 6 | 7 | $LOAD_PATH << "#{HERE}/../vendor/gen-rb" 8 | require "#{HERE}/../vendor/gen-rb/scribe" 9 | 10 | $LOAD_PATH << "#{HERE}" 11 | require 'scribe/scribe' 12 | require 'scribe/debug' if ENV['DEBUG'] 13 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | v0.2.4 Lock to thrift_client 0.6.x 2 | 3 | v0.2.3 Generated thrift 0.5.0 interface to support new thrift_client 0.6.0 4 | 5 | v0.2.2 Refactoring to make dynamic class unloading work better. 6 | 7 | v0.2.1. Set strict_read to false. 8 | 9 | v0.2. Use thrift_client gem. 10 | 11 | v0.1.2. Legacy accessors for log levels. Append newlines by default. 12 | 13 | v0.1. First release. 14 | -------------------------------------------------------------------------------- /Manifest: -------------------------------------------------------------------------------- 1 | CHANGELOG 2 | LICENSE 3 | Manifest 4 | README 5 | Rakefile 6 | conf/scribe.conf 7 | lib/scribe.rb 8 | lib/scribe/debug.rb 9 | lib/scribe/scribe.rb 10 | test/scribe_test.rb 11 | test/test_helper.rb 12 | vendor/gen-rb/facebook_service.rb 13 | vendor/gen-rb/fb303_constants.rb 14 | vendor/gen-rb/fb303_types.rb 15 | vendor/gen-rb/scribe.rb 16 | vendor/gen-rb/scribe_constants.rb 17 | vendor/gen-rb/scribe_types.rb 18 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 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 15 | -------------------------------------------------------------------------------- /vendor/gen-rb/fb303_types.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Autogenerated by Thrift 3 | # 4 | # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | # 6 | 7 | 8 | module Fb_status 9 | DEAD = 0 10 | STARTING = 1 11 | ALIVE = 2 12 | STOPPING = 3 13 | STOPPED = 4 14 | WARNING = 5 15 | VALUE_MAP = {0 => "DEAD", 1 => "STARTING", 2 => "ALIVE", 3 => "STOPPING", 4 => "STOPPED", 5 => "WARNING"} 16 | VALID_VALUES = Set.new([DEAD, STARTING, ALIVE, STOPPING, STOPPED, WARNING]).freeze 17 | end 18 | 19 | -------------------------------------------------------------------------------- /conf/scribe.conf: -------------------------------------------------------------------------------- 1 | ## 2 | ## Sample Scribe configuration 3 | ## 4 | 5 | # This file configures Scribe to listen for messages on port 1463 and write 6 | # them to /tmp/scribetest 7 | 8 | port=1463 9 | max_msg_per_second=2000000 10 | check_interval=3 11 | 12 | # DEFAULT 13 | 14 | category=default 15 | type=buffer 16 | 17 | target_write_size=20480 18 | max_write_interval=1 19 | buffer_send_rate=2 20 | retry_interval=30 21 | retry_interval_range=10 22 | 23 | 24 | type=file 25 | fs_type=std 26 | file_path=/tmp/scribetest 27 | base_filename=thisisoverwritten 28 | max_size=1000000 29 | add_newlines=0 30 | 31 | 32 | 33 | type=file 34 | fs_type=std 35 | file_path=/tmp 36 | base_filename=thisisoverwritten 37 | max_size=3000000 38 | 39 | 40 | -------------------------------------------------------------------------------- /vendor/gen-rb/scribe_types.rb: -------------------------------------------------------------------------------- 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 'fb303_types' 8 | 9 | module ScribeThrift 10 | module ResultCode 11 | OK = 0 12 | TRY_LATER = 1 13 | VALUE_MAP = {0 => "OK", 1 => "TRY_LATER"} 14 | VALID_VALUES = Set.new([OK, TRY_LATER]).freeze 15 | end 16 | 17 | class LogEntry 18 | include ::Thrift::Struct, ::Thrift::Struct_Union 19 | CATEGORY = 1 20 | MESSAGE = 2 21 | 22 | FIELDS = { 23 | CATEGORY => {:type => ::Thrift::Types::STRING, :name => 'category'}, 24 | MESSAGE => {:type => ::Thrift::Types::STRING, :name => 'message'} 25 | } 26 | 27 | def struct_fields; FIELDS; end 28 | 29 | def validate 30 | end 31 | 32 | ::Thrift::Struct.generate_accessors self 33 | end 34 | end -------------------------------------------------------------------------------- /test/scribe_test.rb: -------------------------------------------------------------------------------- 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 30 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | 2 | begin 3 | require 'rubygems' 4 | require 'echoe' 5 | 6 | Echoe.new("scribe") do |p| 7 | p.author = "Evan Weaver" 8 | p.project = "fauna" 9 | p.summary = "A Ruby client for the Scribe distributed log server." 10 | p.rubygems_version = ">= 0.8" 11 | p.dependencies = ['thrift_client ~>0.6', 'rake'] 12 | p.ignore_pattern = /^(vendor\/thrift)/ 13 | p.rdoc_pattern = /^(lib|bin|tasks|ext)|^README|^CHANGELOG|^TODO|^LICENSE|^COPYING$/ 14 | end 15 | rescue LoadError 16 | end 17 | 18 | desc "Start Scribe" 19 | task :scribe do 20 | system("mkdir /tmp/scribetest/") unless File.exist?("/tmp/scribetest/") 21 | system("scribed -c #{File.expand_path(File.dirname(__FILE__))}/conf/scribe.conf &") 22 | end 23 | 24 | desc "Stop Scribe" 25 | task :stop do 26 | system("killall scribed") 27 | end 28 | 29 | desc "Restart Scribe" 30 | task :restart => ["stop", "scribe"] do 31 | end 32 | 33 | # desc "Regenerate thrift bindings for Scribe" # Dev only 34 | task :thrift do 35 | puts "Generating Thrift bindings" 36 | # FIXME 37 | end 38 | -------------------------------------------------------------------------------- /lib/scribe/scribe.rb: -------------------------------------------------------------------------------- 1 | 2 | class Scribe 3 | PROTOCOL_OPTIONS = { :protocol_extra_params => [false] } 4 | 5 | # Created a new client instance. Accepts an optional host and port, default 6 | # category, flag to control whether newlines are added to each line, and 7 | # additional settings to be passed to ThriftClient. 8 | def initialize(servers = "127.0.0.1:1463", category = "Ruby", add_newlines = true, options = {}) 9 | @servers = servers 10 | @category = category 11 | @add_newlines = add_newlines 12 | @client = ThriftClient.new(ScribeThrift::Client, @servers, options.merge(PROTOCOL_OPTIONS)) 13 | end 14 | 15 | # Log a message. Accepts a string and an optional category. 16 | def log(message, category = @category) 17 | raise ArgumentError, "Message must be a string" unless message.is_a?(String) 18 | raise ArgumentError, "Category must be a string" unless category.is_a?(String) 19 | 20 | message << "\n" if @add_newlines 21 | entry = ScribeThrift::LogEntry.new(:message => message, :category => category) 22 | @batch ? @batch << entry : @client.Log(Array(entry)) 23 | end 24 | 25 | # Batch several calls to Scribe#log together. Yields to a block. 26 | def batch 27 | @batch = [] 28 | yield 29 | @client.Log(@batch) 30 | ensure 31 | @batch = nil 32 | end 33 | 34 | alias :debug :log 35 | alias :error :log 36 | alias :fatal :log 37 | alias :info :log 38 | alias :warn :log 39 | end 40 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | scribe 3 | 4 | A Ruby client for the Scribe distributed log server. 5 | 6 | == License 7 | 8 | Copyright 2009 Twitter, Inc. See included LICENSE file. 9 | 10 | The public certificate for this gem is here[http://blog.evanweaver.com/files/evan_weaver-original-public_cert.pem]. 11 | 12 | == Features 13 | 14 | * clean encapsulation of the Thrift API 15 | * Ruby 1.9 compatibility 16 | 17 | The Github source repository is {here}[http://github.com/fauna/scribe/]. Patches and contributions are very welcome. 18 | 19 | == Installation 20 | 21 | You need Ruby 1.8 or 1.9. If you have those, just run: 22 | 23 | sudo gem install scribe 24 | 25 | == Usage 26 | 27 | Now, start IRb and require the library: 28 | 29 | require 'scribe' 30 | 31 | Connect to a server: 32 | 33 | client = Scribe.new('127.0.0.1') 34 | 35 | Log a line: 36 | 37 | client.log("started up") 38 | 39 | Log a line with a category: 40 | 41 | client.log("my app started up", "MyApp") 42 | 43 | Batch a number of log lines and send them all at once: 44 | 45 | client.batch do 46 | client.log("booting") 47 | client.log("loading data") 48 | client.log("success!") 49 | end 50 | 51 | That is all. 52 | 53 | == Reporting problems 54 | 55 | The Github issue tracker is {here}[http://github.com/fauna/scribe/issues]. If you have problems with Scribe itself, please use the {scribe-users mailing list}[http://sourceforge.net/mailarchive/forum.php?forum_name=scribeserver-users]. 56 | 57 | -------------------------------------------------------------------------------- /vendor/gen-rb/scribe.rb: -------------------------------------------------------------------------------- 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 'facebook_service' 9 | require 'scribe_types' 10 | 11 | module ScribeThrift 12 | class Client < FacebookService::Client 13 | include ::Thrift::Client 14 | 15 | def Log(messages) 16 | send_Log(messages) 17 | return recv_Log() 18 | end 19 | 20 | def send_Log(messages) 21 | send_message('Log', Log_args, :messages => messages) 22 | end 23 | 24 | def recv_Log() 25 | result = receive_message(Log_result) 26 | return result.success unless result.success.nil? 27 | raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'Log failed: unknown result') 28 | end 29 | 30 | end 31 | 32 | class Processor < FacebookService::Processor 33 | include ::Thrift::Processor 34 | 35 | def process_Log(seqid, iprot, oprot) 36 | args = read_args(iprot, Log_args) 37 | result = Log_result.new() 38 | result.success = @handler.Log(args.messages) 39 | write_result(result, oprot, 'Log', seqid) 40 | end 41 | 42 | end 43 | 44 | # HELPER FUNCTIONS AND STRUCTURES 45 | 46 | class Log_args 47 | include ::Thrift::Struct, ::Thrift::Struct_Union 48 | MESSAGES = 1 49 | 50 | FIELDS = { 51 | MESSAGES => {:type => ::Thrift::Types::LIST, :name => 'messages', :element => {:type => ::Thrift::Types::STRUCT, :class => ScribeThrift::LogEntry}} 52 | } 53 | 54 | def struct_fields; FIELDS; end 55 | 56 | def validate 57 | end 58 | 59 | ::Thrift::Struct.generate_accessors self 60 | end 61 | 62 | class Log_result 63 | include ::Thrift::Struct, ::Thrift::Struct_Union 64 | SUCCESS = 0 65 | 66 | FIELDS = { 67 | SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success', :enum_class => ScribeThrift::ResultCode} 68 | } 69 | 70 | def struct_fields; FIELDS; end 71 | 72 | def validate 73 | unless @success.nil? || ScribeThrift::ResultCode::VALID_VALUES.include?(@success) 74 | raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field success!') 75 | end 76 | end 77 | 78 | ::Thrift::Struct.generate_accessors self 79 | end 80 | 81 | end 82 | 83 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /vendor/gen-rb/facebook_service.rb: -------------------------------------------------------------------------------- 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, ::Thrift::Struct_Union 292 | 293 | FIELDS = { 294 | 295 | } 296 | 297 | def struct_fields; FIELDS; end 298 | 299 | def validate 300 | end 301 | 302 | ::Thrift::Struct.generate_accessors self 303 | end 304 | 305 | class GetName_result 306 | include ::Thrift::Struct, ::Thrift::Struct_Union 307 | SUCCESS = 0 308 | 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 | ::Thrift::Struct.generate_accessors self 319 | end 320 | 321 | class GetVersion_args 322 | include ::Thrift::Struct, ::Thrift::Struct_Union 323 | 324 | FIELDS = { 325 | 326 | } 327 | 328 | def struct_fields; FIELDS; end 329 | 330 | def validate 331 | end 332 | 333 | ::Thrift::Struct.generate_accessors self 334 | end 335 | 336 | class GetVersion_result 337 | include ::Thrift::Struct, ::Thrift::Struct_Union 338 | SUCCESS = 0 339 | 340 | FIELDS = { 341 | SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'} 342 | } 343 | 344 | def struct_fields; FIELDS; end 345 | 346 | def validate 347 | end 348 | 349 | ::Thrift::Struct.generate_accessors self 350 | end 351 | 352 | class GetStatus_args 353 | include ::Thrift::Struct, ::Thrift::Struct_Union 354 | 355 | FIELDS = { 356 | 357 | } 358 | 359 | def struct_fields; FIELDS; end 360 | 361 | def validate 362 | end 363 | 364 | ::Thrift::Struct.generate_accessors self 365 | end 366 | 367 | class GetStatus_result 368 | include ::Thrift::Struct, ::Thrift::Struct_Union 369 | SUCCESS = 0 370 | 371 | FIELDS = { 372 | SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success', :enum_class => Fb_status} 373 | } 374 | 375 | def struct_fields; FIELDS; end 376 | 377 | def validate 378 | unless @success.nil? || Fb_status::VALID_VALUES.include?(@success) 379 | raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field success!') 380 | end 381 | end 382 | 383 | ::Thrift::Struct.generate_accessors self 384 | end 385 | 386 | class GetStatusDetails_args 387 | include ::Thrift::Struct, ::Thrift::Struct_Union 388 | 389 | FIELDS = { 390 | 391 | } 392 | 393 | def struct_fields; FIELDS; end 394 | 395 | def validate 396 | end 397 | 398 | ::Thrift::Struct.generate_accessors self 399 | end 400 | 401 | class GetStatusDetails_result 402 | include ::Thrift::Struct, ::Thrift::Struct_Union 403 | SUCCESS = 0 404 | 405 | FIELDS = { 406 | SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'} 407 | } 408 | 409 | def struct_fields; FIELDS; end 410 | 411 | def validate 412 | end 413 | 414 | ::Thrift::Struct.generate_accessors self 415 | end 416 | 417 | class GetCounters_args 418 | include ::Thrift::Struct, ::Thrift::Struct_Union 419 | 420 | FIELDS = { 421 | 422 | } 423 | 424 | def struct_fields; FIELDS; end 425 | 426 | def validate 427 | end 428 | 429 | ::Thrift::Struct.generate_accessors self 430 | end 431 | 432 | class GetCounters_result 433 | include ::Thrift::Struct, ::Thrift::Struct_Union 434 | SUCCESS = 0 435 | 436 | FIELDS = { 437 | SUCCESS => {:type => ::Thrift::Types::MAP, :name => 'success', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::I64}} 438 | } 439 | 440 | def struct_fields; FIELDS; end 441 | 442 | def validate 443 | end 444 | 445 | ::Thrift::Struct.generate_accessors self 446 | end 447 | 448 | class GetCounter_args 449 | include ::Thrift::Struct, ::Thrift::Struct_Union 450 | KEY = 1 451 | 452 | FIELDS = { 453 | KEY => {:type => ::Thrift::Types::STRING, :name => 'key'} 454 | } 455 | 456 | def struct_fields; FIELDS; end 457 | 458 | def validate 459 | end 460 | 461 | ::Thrift::Struct.generate_accessors self 462 | end 463 | 464 | class GetCounter_result 465 | include ::Thrift::Struct, ::Thrift::Struct_Union 466 | SUCCESS = 0 467 | 468 | FIELDS = { 469 | SUCCESS => {:type => ::Thrift::Types::I64, :name => 'success'} 470 | } 471 | 472 | def struct_fields; FIELDS; end 473 | 474 | def validate 475 | end 476 | 477 | ::Thrift::Struct.generate_accessors self 478 | end 479 | 480 | class SetOption_args 481 | include ::Thrift::Struct, ::Thrift::Struct_Union 482 | KEY = 1 483 | VALUE = 2 484 | 485 | FIELDS = { 486 | KEY => {:type => ::Thrift::Types::STRING, :name => 'key'}, 487 | VALUE => {:type => ::Thrift::Types::STRING, :name => 'value'} 488 | } 489 | 490 | def struct_fields; FIELDS; end 491 | 492 | def validate 493 | end 494 | 495 | ::Thrift::Struct.generate_accessors self 496 | end 497 | 498 | class SetOption_result 499 | include ::Thrift::Struct, ::Thrift::Struct_Union 500 | 501 | FIELDS = { 502 | 503 | } 504 | 505 | def struct_fields; FIELDS; end 506 | 507 | def validate 508 | end 509 | 510 | ::Thrift::Struct.generate_accessors self 511 | end 512 | 513 | class GetOption_args 514 | include ::Thrift::Struct, ::Thrift::Struct_Union 515 | KEY = 1 516 | 517 | FIELDS = { 518 | KEY => {:type => ::Thrift::Types::STRING, :name => 'key'} 519 | } 520 | 521 | def struct_fields; FIELDS; end 522 | 523 | def validate 524 | end 525 | 526 | ::Thrift::Struct.generate_accessors self 527 | end 528 | 529 | class GetOption_result 530 | include ::Thrift::Struct, ::Thrift::Struct_Union 531 | SUCCESS = 0 532 | 533 | FIELDS = { 534 | SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'} 535 | } 536 | 537 | def struct_fields; FIELDS; end 538 | 539 | def validate 540 | end 541 | 542 | ::Thrift::Struct.generate_accessors self 543 | end 544 | 545 | class GetOptions_args 546 | include ::Thrift::Struct, ::Thrift::Struct_Union 547 | 548 | FIELDS = { 549 | 550 | } 551 | 552 | def struct_fields; FIELDS; end 553 | 554 | def validate 555 | end 556 | 557 | ::Thrift::Struct.generate_accessors self 558 | end 559 | 560 | class GetOptions_result 561 | include ::Thrift::Struct, ::Thrift::Struct_Union 562 | SUCCESS = 0 563 | 564 | FIELDS = { 565 | SUCCESS => {:type => ::Thrift::Types::MAP, :name => 'success', :key => {:type => ::Thrift::Types::STRING}, :value => {:type => ::Thrift::Types::STRING}} 566 | } 567 | 568 | def struct_fields; FIELDS; end 569 | 570 | def validate 571 | end 572 | 573 | ::Thrift::Struct.generate_accessors self 574 | end 575 | 576 | class GetCpuProfile_args 577 | include ::Thrift::Struct, ::Thrift::Struct_Union 578 | PROFILEDURATIONINSEC = 1 579 | 580 | FIELDS = { 581 | PROFILEDURATIONINSEC => {:type => ::Thrift::Types::I32, :name => 'profileDurationInSec'} 582 | } 583 | 584 | def struct_fields; FIELDS; end 585 | 586 | def validate 587 | end 588 | 589 | ::Thrift::Struct.generate_accessors self 590 | end 591 | 592 | class GetCpuProfile_result 593 | include ::Thrift::Struct, ::Thrift::Struct_Union 594 | SUCCESS = 0 595 | 596 | FIELDS = { 597 | SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'} 598 | } 599 | 600 | def struct_fields; FIELDS; end 601 | 602 | def validate 603 | end 604 | 605 | ::Thrift::Struct.generate_accessors self 606 | end 607 | 608 | class AliveSince_args 609 | include ::Thrift::Struct, ::Thrift::Struct_Union 610 | 611 | FIELDS = { 612 | 613 | } 614 | 615 | def struct_fields; FIELDS; end 616 | 617 | def validate 618 | end 619 | 620 | ::Thrift::Struct.generate_accessors self 621 | end 622 | 623 | class AliveSince_result 624 | include ::Thrift::Struct, ::Thrift::Struct_Union 625 | SUCCESS = 0 626 | 627 | FIELDS = { 628 | SUCCESS => {:type => ::Thrift::Types::I64, :name => 'success'} 629 | } 630 | 631 | def struct_fields; FIELDS; end 632 | 633 | def validate 634 | end 635 | 636 | ::Thrift::Struct.generate_accessors self 637 | end 638 | 639 | class Reinitialize_args 640 | include ::Thrift::Struct, ::Thrift::Struct_Union 641 | 642 | FIELDS = { 643 | 644 | } 645 | 646 | def struct_fields; FIELDS; end 647 | 648 | def validate 649 | end 650 | 651 | ::Thrift::Struct.generate_accessors self 652 | end 653 | 654 | class Reinitialize_result 655 | include ::Thrift::Struct, ::Thrift::Struct_Union 656 | 657 | FIELDS = { 658 | 659 | } 660 | 661 | def struct_fields; FIELDS; end 662 | 663 | def validate 664 | end 665 | 666 | ::Thrift::Struct.generate_accessors self 667 | end 668 | 669 | class Shutdown_args 670 | include ::Thrift::Struct, ::Thrift::Struct_Union 671 | 672 | FIELDS = { 673 | 674 | } 675 | 676 | def struct_fields; FIELDS; end 677 | 678 | def validate 679 | end 680 | 681 | ::Thrift::Struct.generate_accessors self 682 | end 683 | 684 | class Shutdown_result 685 | include ::Thrift::Struct, ::Thrift::Struct_Union 686 | 687 | FIELDS = { 688 | 689 | } 690 | 691 | def struct_fields; FIELDS; end 692 | 693 | def validate 694 | end 695 | 696 | ::Thrift::Struct.generate_accessors self 697 | end 698 | 699 | end 700 | 701 | --------------------------------------------------------------------------------