#
# Autogenerated by Thrift
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#

require 'thrift'
require 'zipkin_types'

    module Zipkin
      module ZipkinCollector
        class Client
          include ::Thrift::Client

          def Log(messages)
            send_Log(messages)
            return recv_Log()
          end

          def send_Log(messages)
            send_message('Log', Log_args, :messages => messages)
          end

          def recv_Log()
            result = receive_message(Log_result)
            return result.success unless result.success.nil?
            raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'Log failed: unknown result')
          end

          def getSampleRate()
            send_getSampleRate()
            return recv_getSampleRate()
          end

          def send_getSampleRate()
            send_message('getSampleRate', GetSampleRate_args)
          end

          def recv_getSampleRate()
            result = receive_message(GetSampleRate_result)
            return result.success unless result.success.nil?
            raise result.qe unless result.qe.nil?
            raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getSampleRate failed: unknown result')
          end

          def setSampleRate(sample_rate)
            send_setSampleRate(sample_rate)
            recv_setSampleRate()
          end

          def send_setSampleRate(sample_rate)
            send_message('setSampleRate', SetSampleRate_args, :sample_rate => sample_rate)
          end

          def recv_setSampleRate()
            result = receive_message(SetSampleRate_result)
            raise result.qe unless result.qe.nil?
            return
          end

          def getStorageRequestRate()
            send_getStorageRequestRate()
            return recv_getStorageRequestRate()
          end

          def send_getStorageRequestRate()
            send_message('getStorageRequestRate', GetStorageRequestRate_args)
          end

          def recv_getStorageRequestRate()
            result = receive_message(GetStorageRequestRate_result)
            return result.success unless result.success.nil?
            raise result.e unless result.e.nil?
            raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getStorageRequestRate failed: unknown result')
          end

          def setStorageRequestRate(storage_request_rate)
            send_setStorageRequestRate(storage_request_rate)
            recv_setStorageRequestRate()
          end

          def send_setStorageRequestRate(storage_request_rate)
            send_message('setStorageRequestRate', SetStorageRequestRate_args, :storage_request_rate => storage_request_rate)
          end

          def recv_setStorageRequestRate()
            result = receive_message(SetStorageRequestRate_result)
            raise result.e unless result.e.nil?
            return
          end

        end

        class Processor
          include ::Thrift::Processor

          def process_Log(seqid, iprot, oprot)
            args = read_args(iprot, Log_args)
            result = Log_result.new()
            result.success = @handler.Log(args.messages)
            write_result(result, oprot, 'Log', seqid)
          end

          def process_getSampleRate(seqid, iprot, oprot)
            args = read_args(iprot, GetSampleRate_args)
            result = GetSampleRate_result.new()
            begin
              result.success = @handler.getSampleRate()
            rescue Zipkin::AdjustableRateException => qe
              result.qe = qe
            end
            write_result(result, oprot, 'getSampleRate', seqid)
          end

          def process_setSampleRate(seqid, iprot, oprot)
            args = read_args(iprot, SetSampleRate_args)
            result = SetSampleRate_result.new()
            begin
              @handler.setSampleRate(args.sample_rate)
            rescue Zipkin::AdjustableRateException => qe
              result.qe = qe
            end
            write_result(result, oprot, 'setSampleRate', seqid)
          end

          def process_getStorageRequestRate(seqid, iprot, oprot)
            args = read_args(iprot, GetStorageRequestRate_args)
            result = GetStorageRequestRate_result.new()
            begin
              result.success = @handler.getStorageRequestRate()
            rescue Zipkin::AdjustableRateException => e
              result.e = e
            end
            write_result(result, oprot, 'getStorageRequestRate', seqid)
          end

          def process_setStorageRequestRate(seqid, iprot, oprot)
            args = read_args(iprot, SetStorageRequestRate_args)
            result = SetStorageRequestRate_result.new()
            begin
              @handler.setStorageRequestRate(args.storage_request_rate)
            rescue Zipkin::AdjustableRateException => e
              result.e = e
            end
            write_result(result, oprot, 'setStorageRequestRate', seqid)
          end

        end

        # HELPER FUNCTIONS AND STRUCTURES

        class Log_args
          include ::Thrift::Struct, ::Thrift::Struct_Union
          MESSAGES = 1

          FIELDS = {
            MESSAGES => {:type => ::Thrift::Types::LIST, :name => 'messages', :element => {:type => ::Thrift::Types::STRUCT, :class => Zipkin::LogEntry}}
          }

          def struct_fields; FIELDS; end

          def validate
          end

          ::Thrift::Struct.generate_accessors self
        end

        class Log_result
          include ::Thrift::Struct, ::Thrift::Struct_Union
          SUCCESS = 0

          FIELDS = {
            SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success', :enum_class => Zipkin::ResultCode}
          }

          def struct_fields; FIELDS; end

          def validate
            unless @success.nil? || Zipkin::ResultCode::VALID_VALUES.include?(@success)
              raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field success!')
            end
          end

          ::Thrift::Struct.generate_accessors self
        end

        class GetSampleRate_args
          include ::Thrift::Struct, ::Thrift::Struct_Union

          FIELDS = {

          }

          def struct_fields; FIELDS; end

          def validate
          end

          ::Thrift::Struct.generate_accessors self
        end

        class GetSampleRate_result
          include ::Thrift::Struct, ::Thrift::Struct_Union
          SUCCESS = 0
          QE = 1

          FIELDS = {
            SUCCESS => {:type => ::Thrift::Types::DOUBLE, :name => 'success'},
            QE => {:type => ::Thrift::Types::STRUCT, :name => 'qe', :class => Zipkin::AdjustableRateException}
          }

          def struct_fields; FIELDS; end

          def validate
          end

          ::Thrift::Struct.generate_accessors self
        end

        class SetSampleRate_args
          include ::Thrift::Struct, ::Thrift::Struct_Union
          SAMPLE_RATE = 1

          FIELDS = {
            SAMPLE_RATE => {:type => ::Thrift::Types::DOUBLE, :name => 'sample_rate'}
          }

          def struct_fields; FIELDS; end

          def validate
          end

          ::Thrift::Struct.generate_accessors self
        end

        class SetSampleRate_result
          include ::Thrift::Struct, ::Thrift::Struct_Union
          QE = 1

          FIELDS = {
            QE => {:type => ::Thrift::Types::STRUCT, :name => 'qe', :class => Zipkin::AdjustableRateException}
          }

          def struct_fields; FIELDS; end

          def validate
          end

          ::Thrift::Struct.generate_accessors self
        end

        class GetStorageRequestRate_args
          include ::Thrift::Struct, ::Thrift::Struct_Union

          FIELDS = {

          }

          def struct_fields; FIELDS; end

          def validate
          end

          ::Thrift::Struct.generate_accessors self
        end

        class GetStorageRequestRate_result
          include ::Thrift::Struct, ::Thrift::Struct_Union
          SUCCESS = 0
          E = 1

          FIELDS = {
            SUCCESS => {:type => ::Thrift::Types::DOUBLE, :name => 'success'},
            E => {:type => ::Thrift::Types::STRUCT, :name => 'e', :class => Zipkin::AdjustableRateException}
          }

          def struct_fields; FIELDS; end

          def validate
          end

          ::Thrift::Struct.generate_accessors self
        end

        class SetStorageRequestRate_args
          include ::Thrift::Struct, ::Thrift::Struct_Union
          STORAGE_REQUEST_RATE = 1

          FIELDS = {
            STORAGE_REQUEST_RATE => {:type => ::Thrift::Types::DOUBLE, :name => 'storage_request_rate'}
          }

          def struct_fields; FIELDS; end

          def validate
          end

          ::Thrift::Struct.generate_accessors self
        end

        class SetStorageRequestRate_result
          include ::Thrift::Struct, ::Thrift::Struct_Union
          E = 1

          FIELDS = {
            E => {:type => ::Thrift::Types::STRUCT, :name => 'e', :class => Zipkin::AdjustableRateException}
          }

          def struct_fields; FIELDS; end

          def validate
          end

          ::Thrift::Struct.generate_accessors self
        end

      end

    end
