media_service_MovieIdService.lua 11.6 KB
Newer Older
Yu Gan's avatar
Yu Gan committed
1 2 3 4 5 6 7
--
-- Autogenerated by Thrift
--
-- DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
-- @generated
--

8

9 10 11 12 13 14 15 16 17 18 19
local Thrift = require 'Thrift'
local TType = Thrift.TType
local TMessageType = Thrift.TMessageType
local __TObject = Thrift.__TObject
local TApplicationException = Thrift.TApplicationException
local __TClient = Thrift.__TClient
local __TProcessor = Thrift.__TProcessor
local ttype = Thrift.ttype
local ttable_size = Thrift.ttable_size
local media_service_ttypes = require 'media_service_ttypes'
local ServiceException = media_service_ttypes.ServiceException
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164

MovieIdServiceClient = __TObject.new(__TClient, {
  __type = 'MovieIdServiceClient'
})

function MovieIdServiceClient:UploadMovieId(req_id, title, rating, carrier)
  self:send_UploadMovieId(req_id, title, rating, carrier)
  return self:recv_UploadMovieId(req_id, title, rating, carrier)
end

function MovieIdServiceClient:send_UploadMovieId(req_id, title, rating, carrier)
  self.oprot:writeMessageBegin('UploadMovieId', TMessageType.CALL, self._seqid)
  local args = UploadMovieId_args:new{}
  args.req_id = req_id
  args.title = title
  args.rating = rating
  args.carrier = carrier
  args:write(self.oprot)
  self.oprot:writeMessageEnd()
  self.oprot.trans:flush()
end

function MovieIdServiceClient:recv_UploadMovieId(req_id, title, rating, carrier)
  local fname, mtype, rseqid = self.iprot:readMessageBegin()
  if mtype == TMessageType.EXCEPTION then
    local x = TApplicationException:new{}
    x:read(self.iprot)
    self.iprot:readMessageEnd()
    error(x)
  end
  local result = UploadMovieId_result:new{}
  result:read(self.iprot)
  self.iprot:readMessageEnd()
  if result.success ~= nil then
    return result.success
  elseif result.se then
    error(result.se)
  end
  error(TApplicationException:new{errorCode = TApplicationException.MISSING_RESULT})
end

function MovieIdServiceClient:RegisterMovieId(req_id, title, movie_id, carrier)
  self:send_RegisterMovieId(req_id, title, movie_id, carrier)
  return self:recv_RegisterMovieId(req_id, title, movie_id, carrier)
end

function MovieIdServiceClient:send_RegisterMovieId(req_id, title, movie_id, carrier)
  self.oprot:writeMessageBegin('RegisterMovieId', TMessageType.CALL, self._seqid)
  local args = RegisterMovieId_args:new{}
  args.req_id = req_id
  args.title = title
  args.movie_id = movie_id
  args.carrier = carrier
  args:write(self.oprot)
  self.oprot:writeMessageEnd()
  self.oprot.trans:flush()
end

function MovieIdServiceClient:recv_RegisterMovieId(req_id, title, movie_id, carrier)
  local fname, mtype, rseqid = self.iprot:readMessageBegin()
  if mtype == TMessageType.EXCEPTION then
    local x = TApplicationException:new{}
    x:read(self.iprot)
    self.iprot:readMessageEnd()
    error(x)
  end
  local result = RegisterMovieId_result:new{}
  result:read(self.iprot)
  self.iprot:readMessageEnd()
  if result.success ~= nil then
    return result.success
  elseif result.se then
    error(result.se)
  end
  error(TApplicationException:new{errorCode = TApplicationException.MISSING_RESULT})
end
MovieIdServiceIface = __TObject:new{
  __type = 'MovieIdServiceIface'
}


MovieIdServiceProcessor = __TObject.new(__TProcessor
, {
 __type = 'MovieIdServiceProcessor'
})

function MovieIdServiceProcessor:process(iprot, oprot, server_ctx)
  local name, mtype, seqid = iprot:readMessageBegin()
  local func_name = 'process_' .. name
  if not self[func_name] or ttype(self[func_name]) ~= 'function' then
    iprot:skip(TType.STRUCT)
    iprot:readMessageEnd()
    x = TApplicationException:new{
      errorCode = TApplicationException.UNKNOWN_METHOD
    }
    oprot:writeMessageBegin(name, TMessageType.EXCEPTION, seqid)
    x:write(oprot)
    oprot:writeMessageEnd()
    oprot.trans:flush()
  else
    self[func_name](self, seqid, iprot, oprot, server_ctx)
  end
end

function MovieIdServiceProcessor:process_UploadMovieId(seqid, iprot, oprot, server_ctx)
  local args = UploadMovieId_args:new{}
  local reply_type = TMessageType.REPLY
  args:read(iprot)
  iprot:readMessageEnd()
  local result = UploadMovieId_result:new{}
  local status, res = pcall(self.handler.UploadMovieId, self.handler, args.req_id, args.title, args.rating, args.carrier)
  if not status then
    reply_type = TMessageType.EXCEPTION
    result = TApplicationException:new{message = res}
  elseif ttype(res) == 'ServiceException' then
    result.se = res
  else
    result.success = res
  end
  oprot:writeMessageBegin('UploadMovieId', reply_type, seqid)
  result:write(oprot)
  oprot:writeMessageEnd()
  oprot.trans:flush()
end

function MovieIdServiceProcessor:process_RegisterMovieId(seqid, iprot, oprot, server_ctx)
  local args = RegisterMovieId_args:new{}
  local reply_type = TMessageType.REPLY
  args:read(iprot)
  iprot:readMessageEnd()
  local result = RegisterMovieId_result:new{}
  local status, res = pcall(self.handler.RegisterMovieId, self.handler, args.req_id, args.title, args.movie_id, args.carrier)
  if not status then
    reply_type = TMessageType.EXCEPTION
    result = TApplicationException:new{message = res}
  elseif ttype(res) == 'ServiceException' then
    result.se = res
  else
    result.success = res
  end
  oprot:writeMessageBegin('RegisterMovieId', reply_type, seqid)
  result:write(oprot)
  oprot:writeMessageEnd()
  oprot.trans:flush()
end
Yu Gan's avatar
Yu Gan committed
165 166 167

-- HELPER FUNCTIONS AND STRUCTURES

168
UploadMovieId_args = __TObject:new{
Yu Gan's avatar
Yu Gan committed
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
  req_id,
  title,
  rating,
  carrier
}

function UploadMovieId_args:read(iprot)
  iprot:readStructBegin()
  while true do
    local fname, ftype, fid = iprot:readFieldBegin()
    if ftype == TType.STOP then
      break
    elseif fid == 1 then
      if ftype == TType.I64 then
        self.req_id = iprot:readI64()
      else
        iprot:skip(ftype)
      end
    elseif fid == 2 then
      if ftype == TType.STRING then
        self.title = iprot:readString()
      else
        iprot:skip(ftype)
      end
    elseif fid == 3 then
      if ftype == TType.I32 then
        self.rating = iprot:readI32()
      else
        iprot:skip(ftype)
      end
    elseif fid == 4 then
      if ftype == TType.MAP then
        self.carrier = {}
202 203 204 205 206
        local _ktype57, _vtype58, _size56 = iprot:readMapBegin() 
        for _i=1,_size56 do
          local _key60 = iprot:readString()
          local _val61 = iprot:readString()
          self.carrier[_key60] = _val61
Yu Gan's avatar
Yu Gan committed
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
        end
        iprot:readMapEnd()
      else
        iprot:skip(ftype)
      end
    else
      iprot:skip(ftype)
    end
    iprot:readFieldEnd()
  end
  iprot:readStructEnd()
end

function UploadMovieId_args:write(oprot)
  oprot:writeStructBegin('UploadMovieId_args')
  if self.req_id ~= nil then
    oprot:writeFieldBegin('req_id', TType.I64, 1)
    oprot:writeI64(self.req_id)
    oprot:writeFieldEnd()
  end
  if self.title ~= nil then
    oprot:writeFieldBegin('title', TType.STRING, 2)
    oprot:writeString(self.title)
    oprot:writeFieldEnd()
  end
  if self.rating ~= nil then
    oprot:writeFieldBegin('rating', TType.I32, 3)
    oprot:writeI32(self.rating)
    oprot:writeFieldEnd()
  end
  if self.carrier ~= nil then
    oprot:writeFieldBegin('carrier', TType.MAP, 4)
    oprot:writeMapBegin(TType.STRING, TType.STRING, ttable_size(self.carrier))
240 241 242
    for kiter62,viter63 in pairs(self.carrier) do
      oprot:writeString(kiter62)
      oprot:writeString(viter63)
Yu Gan's avatar
Yu Gan committed
243 244 245 246 247 248 249 250
    end
    oprot:writeMapEnd()
    oprot:writeFieldEnd()
  end
  oprot:writeFieldStop()
  oprot:writeStructEnd()
end

251 252
UploadMovieId_result = __TObject:new{
  success,
Yu Gan's avatar
Yu Gan committed
253 254 255 256 257 258 259 260 261
  se
}

function UploadMovieId_result:read(iprot)
  iprot:readStructBegin()
  while true do
    local fname, ftype, fid = iprot:readFieldBegin()
    if ftype == TType.STOP then
      break
262 263 264 265 266 267 268
    elseif fid == 0 then
      if ftype == TType.STRUCT then
        self.success = BaseRpcResponse:new{}
        self.success:read(iprot)
      else
        iprot:skip(ftype)
      end
Yu Gan's avatar
Yu Gan committed
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
    elseif fid == 1 then
      if ftype == TType.STRUCT then
        self.se = ServiceException:new{}
        self.se:read(iprot)
      else
        iprot:skip(ftype)
      end
    else
      iprot:skip(ftype)
    end
    iprot:readFieldEnd()
  end
  iprot:readStructEnd()
end

function UploadMovieId_result:write(oprot)
  oprot:writeStructBegin('UploadMovieId_result')
286 287 288 289 290
  if self.success ~= nil then
    oprot:writeFieldBegin('success', TType.STRUCT, 0)
    self.success:write(oprot)
    oprot:writeFieldEnd()
  end
Yu Gan's avatar
Yu Gan committed
291 292 293 294 295 296 297 298 299
  if self.se ~= nil then
    oprot:writeFieldBegin('se', TType.STRUCT, 1)
    self.se:write(oprot)
    oprot:writeFieldEnd()
  end
  oprot:writeFieldStop()
  oprot:writeStructEnd()
end

300
RegisterMovieId_args = __TObject:new{
Yu Gan's avatar
Yu Gan committed
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
  req_id,
  title,
  movie_id,
  carrier
}

function RegisterMovieId_args:read(iprot)
  iprot:readStructBegin()
  while true do
    local fname, ftype, fid = iprot:readFieldBegin()
    if ftype == TType.STOP then
      break
    elseif fid == 1 then
      if ftype == TType.I64 then
        self.req_id = iprot:readI64()
      else
        iprot:skip(ftype)
      end
    elseif fid == 2 then
      if ftype == TType.STRING then
        self.title = iprot:readString()
      else
        iprot:skip(ftype)
      end
    elseif fid == 3 then
      if ftype == TType.STRING then
        self.movie_id = iprot:readString()
      else
        iprot:skip(ftype)
      end
    elseif fid == 4 then
      if ftype == TType.MAP then
        self.carrier = {}
334 335 336 337 338
        local _ktype65, _vtype66, _size64 = iprot:readMapBegin() 
        for _i=1,_size64 do
          local _key68 = iprot:readString()
          local _val69 = iprot:readString()
          self.carrier[_key68] = _val69
Yu Gan's avatar
Yu Gan committed
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
        end
        iprot:readMapEnd()
      else
        iprot:skip(ftype)
      end
    else
      iprot:skip(ftype)
    end
    iprot:readFieldEnd()
  end
  iprot:readStructEnd()
end

function RegisterMovieId_args:write(oprot)
  oprot:writeStructBegin('RegisterMovieId_args')
  if self.req_id ~= nil then
    oprot:writeFieldBegin('req_id', TType.I64, 1)
    oprot:writeI64(self.req_id)
    oprot:writeFieldEnd()
  end
  if self.title ~= nil then
    oprot:writeFieldBegin('title', TType.STRING, 2)
    oprot:writeString(self.title)
    oprot:writeFieldEnd()
  end
  if self.movie_id ~= nil then
    oprot:writeFieldBegin('movie_id', TType.STRING, 3)
    oprot:writeString(self.movie_id)
    oprot:writeFieldEnd()
  end
  if self.carrier ~= nil then
    oprot:writeFieldBegin('carrier', TType.MAP, 4)
    oprot:writeMapBegin(TType.STRING, TType.STRING, ttable_size(self.carrier))
372 373 374
    for kiter70,viter71 in pairs(self.carrier) do
      oprot:writeString(kiter70)
      oprot:writeString(viter71)
Yu Gan's avatar
Yu Gan committed
375 376 377 378 379 380 381 382
    end
    oprot:writeMapEnd()
    oprot:writeFieldEnd()
  end
  oprot:writeFieldStop()
  oprot:writeStructEnd()
end

383 384
RegisterMovieId_result = __TObject:new{
  success,
Yu Gan's avatar
Yu Gan committed
385 386 387 388 389 390 391 392 393
  se
}

function RegisterMovieId_result:read(iprot)
  iprot:readStructBegin()
  while true do
    local fname, ftype, fid = iprot:readFieldBegin()
    if ftype == TType.STOP then
      break
394 395 396 397 398 399 400
    elseif fid == 0 then
      if ftype == TType.STRUCT then
        self.success = BaseRpcResponse:new{}
        self.success:read(iprot)
      else
        iprot:skip(ftype)
      end
Yu Gan's avatar
Yu Gan committed
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
    elseif fid == 1 then
      if ftype == TType.STRUCT then
        self.se = ServiceException:new{}
        self.se:read(iprot)
      else
        iprot:skip(ftype)
      end
    else
      iprot:skip(ftype)
    end
    iprot:readFieldEnd()
  end
  iprot:readStructEnd()
end

function RegisterMovieId_result:write(oprot)
  oprot:writeStructBegin('RegisterMovieId_result')
418 419 420 421 422
  if self.success ~= nil then
    oprot:writeFieldBegin('success', TType.STRUCT, 0)
    self.success:write(oprot)
    oprot:writeFieldEnd()
  end
Yu Gan's avatar
Yu Gan committed
423 424 425 426 427 428 429
  if self.se ~= nil then
    oprot:writeFieldBegin('se', TType.STRUCT, 1)
    self.se:write(oprot)
    oprot:writeFieldEnd()
  end
  oprot:writeFieldStop()
  oprot:writeStructEnd()
430 431 432
end

return MovieIdServiceClient