1-- 2-- Licensed to the Apache Software Foundation (ASF) under one 3-- or more contributor license agreements. See the NOTICE file 4-- distributed with this work for additional information 5-- regarding copyright ownership. The ASF licenses this file 6-- to you under the Apache License, Version 2.0 (the 7-- "License"); you may not use this file except in compliance 8-- with the License. You may obtain a copy of the License at 9-- 10-- http://www.apache.org/licenses/LICENSE-2.0 11-- 12-- Unless required by applicable law or agreed to in writing, 13-- software distributed under the License is distributed on an 14-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15-- KIND, either express or implied. See the License for the 16-- specific language governing permissions and limitations 17-- under the License. 18-- 19 20require 'Thrift' 21 22TTransportException = TException:new { 23 UNKNOWN = 0, 24 NOT_OPEN = 1, 25 ALREADY_OPEN = 2, 26 TIMED_OUT = 3, 27 END_OF_FILE = 4, 28 INVALID_FRAME_SIZE = 5, 29 INVALID_TRANSFORM = 6, 30 INVALID_CLIENT_TYPE = 7, 31 errorCode = 0, 32 __type = 'TTransportException' 33} 34 35function TTransportException:__errorCodeToString() 36 if self.errorCode == self.NOT_OPEN then 37 return 'Transport not open' 38 elseif self.errorCode == self.ALREADY_OPEN then 39 return 'Transport already open' 40 elseif self.errorCode == self.TIMED_OUT then 41 return 'Transport timed out' 42 elseif self.errorCode == self.END_OF_FILE then 43 return 'End of file' 44 elseif self.errorCode == self.INVALID_FRAME_SIZE then 45 return 'Invalid frame size' 46 elseif self.errorCode == self.INVALID_TRANSFORM then 47 return 'Invalid transform' 48 elseif self.errorCode == self.INVALID_CLIENT_TYPE then 49 return 'Invalid client type' 50 else 51 return 'Default (unknown)' 52 end 53end 54 55TTransportBase = __TObject:new{ 56 __type = 'TTransportBase' 57} 58 59function TTransportBase:isOpen() end 60function TTransportBase:open() end 61function TTransportBase:close() end 62function TTransportBase:read(len) end 63function TTransportBase:readAll(len) 64 local buf, have, chunk = '', 0 65 while have < len do 66 chunk = self:read(len - have) 67 have = have + string.len(chunk) 68 buf = buf .. chunk 69 70 if string.len(chunk) == 0 then 71 terror(TTransportException:new{ 72 errorCode = TTransportException.END_OF_FILE 73 }) 74 end 75 end 76 return buf 77end 78function TTransportBase:write(buf) end 79function TTransportBase:flush() end 80 81TServerTransportBase = __TObject:new{ 82 __type = 'TServerTransportBase' 83} 84function TServerTransportBase:listen() end 85function TServerTransportBase:accept() end 86function TServerTransportBase:close() end 87 88TTransportFactoryBase = __TObject:new{ 89 __type = 'TTransportFactoryBase' 90} 91function TTransportFactoryBase:getTransport(trans) 92 return trans 93end 94