OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library memcache_service; |
| 6 |
| 7 import 'dart:async'; |
| 8 |
| 9 import 'package:protobuf/protobuf.dart'; |
| 10 |
| 11 import '../../api/errors.dart'; |
| 12 import 'rpc/rpc_service.dart'; |
| 13 import 'internal/memcache_service.pb.dart'; |
| 14 |
| 15 class MemcacheServiceClientRPCStub { |
| 16 final RPCService _rpcService; |
| 17 final String _ticket; |
| 18 |
| 19 MemcacheServiceClientRPCStub(this._rpcService, this._ticket); |
| 20 |
| 21 Future<MemcacheGetResponse> Get(MemcacheGetRequest request) { |
| 22 return _rpcService.call('memcache', 'Get', request.writeToBuffer(), ticket:
_ticket) |
| 23 .then((List<int> response) { |
| 24 try { |
| 25 return new MemcacheGetResponse.fromBuffer(response); |
| 26 } on InvalidProtocolBufferException catch (error) { |
| 27 throw ProtocolError.INVALID_RESPONSE; |
| 28 } |
| 29 }); |
| 30 } |
| 31 |
| 32 Future<MemcacheSetResponse> Set(MemcacheSetRequest request) { |
| 33 return _rpcService.call('memcache', 'Set', request.writeToBuffer(), ticket:
_ticket) |
| 34 .then((List<int> response) { |
| 35 try { |
| 36 return new MemcacheSetResponse.fromBuffer(response); |
| 37 } on InvalidProtocolBufferException catch (error) { |
| 38 throw ProtocolError.INVALID_RESPONSE; |
| 39 } |
| 40 }); |
| 41 } |
| 42 |
| 43 Future<MemcacheDeleteResponse> Delete(MemcacheDeleteRequest request) { |
| 44 return _rpcService.call('memcache', 'Delete', request.writeToBuffer(), ticke
t: _ticket) |
| 45 .then((List<int> response) { |
| 46 try { |
| 47 return new MemcacheDeleteResponse.fromBuffer(response); |
| 48 } on InvalidProtocolBufferException catch (error) { |
| 49 throw ProtocolError.INVALID_RESPONSE; |
| 50 } |
| 51 }); |
| 52 } |
| 53 |
| 54 Future<MemcacheIncrementResponse> Increment(MemcacheIncrementRequest request)
{ |
| 55 return _rpcService.call('memcache', 'Increment', request.writeToBuffer(), ti
cket: _ticket) |
| 56 .then((List<int> response) { |
| 57 try { |
| 58 return new MemcacheIncrementResponse.fromBuffer(response); |
| 59 } on InvalidProtocolBufferException catch (error) { |
| 60 throw ProtocolError.INVALID_RESPONSE; |
| 61 } |
| 62 }); |
| 63 } |
| 64 |
| 65 Future<MemcacheBatchIncrementResponse> BatchIncrement( |
| 66 MemcacheBatchIncrementRequest request) { |
| 67 return _rpcService.call('memcache', 'BatchIncrement', request.writeToBuffer(
), ticket: _ticket) |
| 68 .then((List<int> response) { |
| 69 try { |
| 70 return new MemcacheBatchIncrementResponse.fromBuffer(response); |
| 71 } on InvalidProtocolBufferException catch (error) { |
| 72 throw ProtocolError.INVALID_RESPONSE; |
| 73 } |
| 74 }); |
| 75 } |
| 76 |
| 77 Future<MemcacheFlushResponse> FlushAll(MemcacheFlushRequest request) { |
| 78 return _rpcService.call('memcache', 'FlushAll', request.writeToBuffer(), tic
ket: _ticket) |
| 79 .then((List<int> response) { |
| 80 try { |
| 81 return new MemcacheFlushResponse.fromBuffer(response); |
| 82 } on InvalidProtocolBufferException catch (error) { |
| 83 throw ProtocolError.INVALID_RESPONSE; |
| 84 } |
| 85 }); |
| 86 } |
| 87 |
| 88 Future<MemcacheStatsResponse> Stats(MemcacheStatsRequest request) { |
| 89 return _rpcService.call('memcache', 'Stats', request.writeToBuffer(), ticket
: _ticket) |
| 90 .then((List<int> response) { |
| 91 try { |
| 92 return new MemcacheStatsResponse.fromBuffer(response); |
| 93 } on InvalidProtocolBufferException catch (error) { |
| 94 throw ProtocolError.INVALID_RESPONSE; |
| 95 } |
| 96 }); |
| 97 } |
| 98 |
| 99 Future<MemcacheGrabTailResponse> GrabTail(MemcacheGrabTailRequest request) { |
| 100 return _rpcService.call('memcache', 'GrabTail', request.writeToBuffer(), tic
ket: _ticket) |
| 101 .then((List<int> response) { |
| 102 try { |
| 103 return new MemcacheGrabTailResponse.fromBuffer(response); |
| 104 } on InvalidProtocolBufferException catch (error) { |
| 105 throw ProtocolError.INVALID_RESPONSE; |
| 106 } |
| 107 }); |
| 108 } |
| 109 } |
OLD | NEW |