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


9 10 11 12 13 14 15 16 17 18 19 20
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
local Review = media_service_ttypes.Review
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 165 166 167

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

function MovieReviewServiceClient:UploadMovieReview(req_id, movie_id, review_id, timestamp, carrier)
  self:send_UploadMovieReview(req_id, movie_id, review_id, timestamp, carrier)
  return self:recv_UploadMovieReview(req_id, movie_id, review_id, timestamp, carrier)
end

function MovieReviewServiceClient:send_UploadMovieReview(req_id, movie_id, review_id, timestamp, carrier)
  self.oprot:writeMessageBegin('UploadMovieReview', TMessageType.CALL, self._seqid)
  local args = UploadMovieReview_args:new{}
  args.req_id = req_id
  args.movie_id = movie_id
  args.review_id = review_id
  args.timestamp = timestamp
  args.carrier = carrier
  args:write(self.oprot)
  self.oprot:writeMessageEnd()
  self.oprot.trans:flush()
end

function MovieReviewServiceClient:recv_UploadMovieReview(req_id, movie_id, review_id, timestamp, 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 = UploadMovieReview_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 MovieReviewServiceClient:ReadMovieReviews(req_id, movie_id, start, stop, carrier)
  self:send_ReadMovieReviews(req_id, movie_id, start, stop, carrier)
  return self:recv_ReadMovieReviews(req_id, movie_id, start, stop, carrier)
end

function MovieReviewServiceClient:send_ReadMovieReviews(req_id, movie_id, start, stop, carrier)
  self.oprot:writeMessageBegin('ReadMovieReviews', TMessageType.CALL, self._seqid)
  local args = ReadMovieReviews_args:new{}
  args.req_id = req_id
  args.movie_id = movie_id
  args.start = start
  args.stop = stop
  args.carrier = carrier
  args:write(self.oprot)
  self.oprot:writeMessageEnd()
  self.oprot.trans:flush()
end

function MovieReviewServiceClient:recv_ReadMovieReviews(req_id, movie_id, start, stop, 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 = ReadMovieReviews_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
MovieReviewServiceIface = __TObject:new{
  __type = 'MovieReviewServiceIface'
}


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

function MovieReviewServiceProcessor: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 MovieReviewServiceProcessor:process_UploadMovieReview(seqid, iprot, oprot, server_ctx)
  local args = UploadMovieReview_args:new{}
  local reply_type = TMessageType.REPLY
  args:read(iprot)
  iprot:readMessageEnd()
  local result = UploadMovieReview_result:new{}
  local status, res = pcall(self.handler.UploadMovieReview, self.handler, args.req_id, args.movie_id, args.review_id, args.timestamp, 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('UploadMovieReview', reply_type, seqid)
  result:write(oprot)
  oprot:writeMessageEnd()
  oprot.trans:flush()
end

function MovieReviewServiceProcessor:process_ReadMovieReviews(seqid, iprot, oprot, server_ctx)
  local args = ReadMovieReviews_args:new{}
  local reply_type = TMessageType.REPLY
  args:read(iprot)
  iprot:readMessageEnd()
  local result = ReadMovieReviews_result:new{}
  local status, res = pcall(self.handler.ReadMovieReviews, self.handler, args.req_id, args.movie_id, args.start, args.stop, 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('ReadMovieReviews', reply_type, seqid)
  result:write(oprot)
  oprot:writeMessageEnd()
  oprot.trans:flush()
end
Yu Gan's avatar
Yu Gan committed
168 169 170

-- HELPER FUNCTIONS AND STRUCTURES

171
UploadMovieReview_args = __TObject:new{
Yu Gan's avatar
Yu Gan committed
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 202 203 204 205 206 207 208 209 210 211
  req_id,
  movie_id,
  review_id,
  timestamp,
  carrier
}

function UploadMovieReview_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.movie_id = iprot:readString()
      else
        iprot:skip(ftype)
      end
    elseif fid == 3 then
      if ftype == TType.I64 then
        self.review_id = iprot:readI64()
      else
        iprot:skip(ftype)
      end
    elseif fid == 4 then
      if ftype == TType.I64 then
        self.timestamp = iprot:readI64()
      else
        iprot:skip(ftype)
      end
    elseif fid == 5 then
      if ftype == TType.MAP then
        self.carrier = {}
212 213 214 215 216
        local _ktype191, _vtype192, _size190 = iprot:readMapBegin() 
        for _i=1,_size190 do
          local _key194 = iprot:readString()
          local _val195 = iprot:readString()
          self.carrier[_key194] = _val195
Yu Gan's avatar
Yu Gan committed
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
        end
        iprot:readMapEnd()
      else
        iprot:skip(ftype)
      end
    else
      iprot:skip(ftype)
    end
    iprot:readFieldEnd()
  end
  iprot:readStructEnd()
end

function UploadMovieReview_args:write(oprot)
  oprot:writeStructBegin('UploadMovieReview_args')
  if self.req_id ~= nil then
    oprot:writeFieldBegin('req_id', TType.I64, 1)
    oprot:writeI64(self.req_id)
    oprot:writeFieldEnd()
  end
  if self.movie_id ~= nil then
    oprot:writeFieldBegin('movie_id', TType.STRING, 2)
    oprot:writeString(self.movie_id)
    oprot:writeFieldEnd()
  end
  if self.review_id ~= nil then
    oprot:writeFieldBegin('review_id', TType.I64, 3)
    oprot:writeI64(self.review_id)
    oprot:writeFieldEnd()
  end
  if self.timestamp ~= nil then
    oprot:writeFieldBegin('timestamp', TType.I64, 4)
    oprot:writeI64(self.timestamp)
    oprot:writeFieldEnd()
  end
  if self.carrier ~= nil then
    oprot:writeFieldBegin('carrier', TType.MAP, 5)
    oprot:writeMapBegin(TType.STRING, TType.STRING, ttable_size(self.carrier))
255 256 257
    for kiter196,viter197 in pairs(self.carrier) do
      oprot:writeString(kiter196)
      oprot:writeString(viter197)
Yu Gan's avatar
Yu Gan committed
258 259 260 261 262 263 264 265
    end
    oprot:writeMapEnd()
    oprot:writeFieldEnd()
  end
  oprot:writeFieldStop()
  oprot:writeStructEnd()
end

266 267
UploadMovieReview_result = __TObject:new{
  success,
Yu Gan's avatar
Yu Gan committed
268 269 270 271 272 273 274 275 276
  se
}

function UploadMovieReview_result:read(iprot)
  iprot:readStructBegin()
  while true do
    local fname, ftype, fid = iprot:readFieldBegin()
    if ftype == TType.STOP then
      break
277 278 279 280 281 282 283
    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
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
    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 UploadMovieReview_result:write(oprot)
  oprot:writeStructBegin('UploadMovieReview_result')
301 302 303 304 305
  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
306 307 308 309 310 311 312 313 314
  if self.se ~= nil then
    oprot:writeFieldBegin('se', TType.STRUCT, 1)
    self.se:write(oprot)
    oprot:writeFieldEnd()
  end
  oprot:writeFieldStop()
  oprot:writeStructEnd()
end

315
ReadMovieReviews_args = __TObject:new{
Yu Gan's avatar
Yu Gan committed
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
  req_id,
  movie_id,
  start,
  stop,
  carrier
}

function ReadMovieReviews_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.movie_id = iprot:readString()
      else
        iprot:skip(ftype)
      end
    elseif fid == 3 then
      if ftype == TType.I32 then
        self.start = iprot:readI32()
      else
        iprot:skip(ftype)
      end
    elseif fid == 4 then
      if ftype == TType.I32 then
        self.stop = iprot:readI32()
      else
        iprot:skip(ftype)
      end
    elseif fid == 5 then
      if ftype == TType.MAP then
        self.carrier = {}
356 357 358 359 360
        local _ktype199, _vtype200, _size198 = iprot:readMapBegin() 
        for _i=1,_size198 do
          local _key202 = iprot:readString()
          local _val203 = iprot:readString()
          self.carrier[_key202] = _val203
Yu Gan's avatar
Yu Gan committed
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
        end
        iprot:readMapEnd()
      else
        iprot:skip(ftype)
      end
    else
      iprot:skip(ftype)
    end
    iprot:readFieldEnd()
  end
  iprot:readStructEnd()
end

function ReadMovieReviews_args:write(oprot)
  oprot:writeStructBegin('ReadMovieReviews_args')
  if self.req_id ~= nil then
    oprot:writeFieldBegin('req_id', TType.I64, 1)
    oprot:writeI64(self.req_id)
    oprot:writeFieldEnd()
  end
  if self.movie_id ~= nil then
    oprot:writeFieldBegin('movie_id', TType.STRING, 2)
    oprot:writeString(self.movie_id)
    oprot:writeFieldEnd()
  end
  if self.start ~= nil then
    oprot:writeFieldBegin('start', TType.I32, 3)
    oprot:writeI32(self.start)
    oprot:writeFieldEnd()
  end
  if self.stop ~= nil then
    oprot:writeFieldBegin('stop', TType.I32, 4)
    oprot:writeI32(self.stop)
    oprot:writeFieldEnd()
  end
  if self.carrier ~= nil then
    oprot:writeFieldBegin('carrier', TType.MAP, 5)
    oprot:writeMapBegin(TType.STRING, TType.STRING, ttable_size(self.carrier))
399 400 401
    for kiter204,viter205 in pairs(self.carrier) do
      oprot:writeString(kiter204)
      oprot:writeString(viter205)
Yu Gan's avatar
Yu Gan committed
402 403 404 405 406 407 408 409
    end
    oprot:writeMapEnd()
    oprot:writeFieldEnd()
  end
  oprot:writeFieldStop()
  oprot:writeStructEnd()
end

410
ReadMovieReviews_result = __TObject:new{
Yu Gan's avatar
Yu Gan committed
411 412 413 414 415 416 417 418 419 420 421
  success,
  se
}

function ReadMovieReviews_result:read(iprot)
  iprot:readStructBegin()
  while true do
    local fname, ftype, fid = iprot:readFieldBegin()
    if ftype == TType.STOP then
      break
    elseif fid == 0 then
422 423 424
      if ftype == TType.STRUCT then
        self.success = ReviewListRpcResponse:new{}
        self.success:read(iprot)
Yu Gan's avatar
Yu Gan committed
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445
      else
        iprot:skip(ftype)
      end
    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 ReadMovieReviews_result:write(oprot)
  oprot:writeStructBegin('ReadMovieReviews_result')
  if self.success ~= nil then
446 447
    oprot:writeFieldBegin('success', TType.STRUCT, 0)
    self.success:write(oprot)
Yu Gan's avatar
Yu Gan committed
448 449 450 451 452 453 454 455 456
    oprot:writeFieldEnd()
  end
  if self.se ~= nil then
    oprot:writeFieldBegin('se', TType.STRUCT, 1)
    self.se:write(oprot)
    oprot:writeFieldEnd()
  end
  oprot:writeFieldStop()
  oprot:writeStructEnd()
457 458 459
end

return MovieReviewServiceClient