Subversion Repositories SmartDukaan

Rev

Rev 30 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
30 ashish 1
# encoding: ascii-8bit
2
# 
3
# Licensed to the Apache Software Foundation (ASF) under one
4
# or more contributor license agreements. See the NOTICE file
5
# distributed with this work for additional information
6
# regarding copyright ownership. The ASF licenses this file
7
# to you under the Apache License, Version 2.0 (the
8
# "License"); you may not use this file except in compliance
9
# with the License. You may obtain a copy of the License at
10
# 
11
#   http://www.apache.org/licenses/LICENSE-2.0
12
# 
13
# Unless required by applicable law or agreed to in writing,
14
# software distributed under the License is distributed on an
15
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
# KIND, either express or implied. See the License for the
17
# specific language governing permissions and limitations
18
# under the License.
19
# 
20
 
21
module Thrift
22
  class TransportException < Exception
23
    UNKNOWN = 0
24
    NOT_OPEN = 1
25
    ALREADY_OPEN = 2
26
    TIMED_OUT = 3
27
    END_OF_FILE = 4
28
 
29
    attr_reader :type
30
 
31
    def initialize(type=UNKNOWN, message=nil)
32
      super(message)
33
      @type = type
34
    end
35
  end
36
 
37
  class BaseTransport
38
    def open?; end
39
 
40
    def open; end
41
 
42
    def close; end
43
 
44
    def read(sz)
45
      raise NotImplementedError
46
    end
47
 
48
    def read_all(size)
49
      buf = ''
50
 
51
      while (buf.length < size)
52
        chunk = read(size - buf.length)
53
        buf << chunk
54
      end
55
 
56
      buf
57
    end
58
 
59
    def write(buf); end
60
    alias_method :<<, :write
61
 
62
    def flush; end
63
  end
64
 
65
  class BaseTransportFactory
66
    def get_transport(trans)
67
      return trans
68
    end
69
  end
70
end