Sha256: 26019f6cb1bb2c36a4d834bdb66765521dd7adde67392df9685decbb4b51572c

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 KB

Contents

module Greeter
  class Handler
    def greeting(name)
      "hello there #{name}!"
    end
  end

  class Server
    def initialize(port)
      @port = port
      handler = Greeter::Handler.new
      processor = Greeter::Processor.new(handler)
      transport = Thrift::ServerSocket.new("127.0.0.1", port)
      transportFactory = Thrift::FramedTransportFactory.new()
      @server = Thrift::SimpleServer.new(processor, transport, transportFactory)
    end

    def serve
      @server.serve()
    end
  end

  # client:
  # trans = Thrift::HTTPClientTransport.new("http://127.0.0.1:9292/greeter")
  # prot = Thrift::BinaryProtocol.new(trans)
  # c = Greeter::Client.new(prot)
  class HTTPServer
    def initialize(uri)
      uri = URI.parse(uri)
      handler = Greeter::Handler.new
      processor = Greeter::Processor.new(handler)
      path = uri.path[1..-1]
      @server = Thrift::MongrelHTTPServer.new(processor, :port => uri.port, :ip => uri.host, :path => path)
    end

    def serve
      @server.serve()
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
fl-thrift_client-0.4.2 test/greeter/server.rb
thrift_client-0.4.5 test/greeter/server.rb
thrift_client-0.4.4 test/greeter/server.rb
thrift_client-0.4.3 test/greeter/server.rb
thrift_client-0.4.2 test/greeter/server.rb
thrift_client-0.4.1 test/greeter/server.rb
thrift_client-0.4.0 test/greeter/server.rb