mirror of https://github.com/grpc/grpc.git
commit
efad2ae674
203 changed files with 6949 additions and 6651 deletions
@ -0,0 +1,16 @@ |
|||||||
|
# Command Line Tools |
||||||
|
|
||||||
|
# Service Packager |
||||||
|
|
||||||
|
The command line tool `bin/service_packager`, when called with the following command line: |
||||||
|
|
||||||
|
```bash |
||||||
|
service_packager proto_file -o output_path -n name -v version [-i input_path...] |
||||||
|
``` |
||||||
|
|
||||||
|
Populates `output_path` with a node package consisting of a `package.json` populated with `name` and `version`, an `index.js`, a `LICENSE` file copied from gRPC, and a `service.json`, which is compiled from `proto_file` and the given `input_path`s. `require('output_path')` returns an object that is equivalent to |
||||||
|
|
||||||
|
```js |
||||||
|
{ client: require('grpc').load('service.json'), |
||||||
|
auth: require('google-auth-library') } |
||||||
|
``` |
@ -0,0 +1,2 @@ |
|||||||
|
#!/usr/bin/env node |
||||||
|
require(__dirname+'/../cli/service_packager.js').main(process.argv.slice(2)); |
@ -0,0 +1,142 @@ |
|||||||
|
/* |
||||||
|
* |
||||||
|
* Copyright 2015, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
'use strict'; |
||||||
|
|
||||||
|
var fs = require('fs'); |
||||||
|
var path = require('path'); |
||||||
|
|
||||||
|
var _ = require('underscore'); |
||||||
|
var async = require('async'); |
||||||
|
var pbjs = require('protobufjs/cli/pbjs'); |
||||||
|
var parseArgs = require('minimist'); |
||||||
|
var Mustache = require('mustache'); |
||||||
|
|
||||||
|
var package_json = require('../package.json'); |
||||||
|
|
||||||
|
var template_path = path.resolve(__dirname, 'service_packager'); |
||||||
|
|
||||||
|
var package_tpl_path = path.join(template_path, 'package.json.template'); |
||||||
|
|
||||||
|
var arg_format = { |
||||||
|
string: ['include', 'out', 'name', 'version'], |
||||||
|
alias: { |
||||||
|
include: 'i', |
||||||
|
out: 'o', |
||||||
|
name: 'n', |
||||||
|
version: 'v' |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
// TODO(mlumish): autogenerate README.md from proto file
|
||||||
|
|
||||||
|
/** |
||||||
|
* Render package.json file from template using provided parameters. |
||||||
|
* @param {Object} params Map of parameter names to values |
||||||
|
* @param {function(Error, string)} callback Callback to pass rendered template |
||||||
|
* text to |
||||||
|
*/ |
||||||
|
function generatePackage(params, callback) { |
||||||
|
fs.readFile(package_tpl_path, {encoding: 'utf-8'}, function(err, template) { |
||||||
|
if (err) { |
||||||
|
callback(err); |
||||||
|
} else { |
||||||
|
var rendered = Mustache.render(template, params); |
||||||
|
callback(null, rendered); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Copy a file |
||||||
|
* @param {string} src_path The filepath to copy from |
||||||
|
* @param {string} dest_path The filepath to copy to |
||||||
|
*/ |
||||||
|
function copyFile(src_path, dest_path) { |
||||||
|
fs.createReadStream(src_path).pipe(fs.createWriteStream(dest_path)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Run the script. Copies the index.js and LICENSE files to the output path, |
||||||
|
* renders the package.json template to the output path, and generates a |
||||||
|
* service.json file from the input proto files using pbjs. The arguments are |
||||||
|
* taken directly from the command line, and handled as follows: |
||||||
|
* -i (--include) : An include path for pbjs (can be dpulicated) |
||||||
|
* -o (--output): The output path |
||||||
|
* -n (--name): The name of the package |
||||||
|
* -v (--version): The package version |
||||||
|
* @param {Array} argv The argument vector |
||||||
|
*/ |
||||||
|
function main(argv) { |
||||||
|
var args = parseArgs(argv, arg_format); |
||||||
|
var out_path = path.resolve(args.out); |
||||||
|
var include_dirs = []; |
||||||
|
if (args.include) { |
||||||
|
include_dirs = _.map(_.flatten([args.include]), function(p) { |
||||||
|
return path.resolve(p); |
||||||
|
}); |
||||||
|
} |
||||||
|
args.grpc_version = package_json.version; |
||||||
|
generatePackage(args, function(err, rendered) { |
||||||
|
if (err) throw err; |
||||||
|
fs.writeFile(path.join(out_path, 'package.json'), rendered, function(err) { |
||||||
|
if (err) throw err; |
||||||
|
}); |
||||||
|
}); |
||||||
|
copyFile(path.join(template_path, 'index.js'), |
||||||
|
path.join(out_path, 'index.js')); |
||||||
|
copyFile(path.join(__dirname, '..', 'LICENSE'), |
||||||
|
path.join(out_path, 'LICENSE')); |
||||||
|
|
||||||
|
var service_stream = fs.createWriteStream(path.join(out_path, |
||||||
|
'service.json')); |
||||||
|
var pbjs_args = _.flatten(['node', 'pbjs', |
||||||
|
args._[0], |
||||||
|
'-legacy', |
||||||
|
_.map(include_dirs, function(dir) { |
||||||
|
return "-path=" + dir; |
||||||
|
})]); |
||||||
|
var old_stdout = process.stdout; |
||||||
|
process.__defineGetter__('stdout', function() { |
||||||
|
return service_stream; |
||||||
|
}); |
||||||
|
var pbjs_status = pbjs.main(pbjs_args); |
||||||
|
process.__defineGetter__('stdout', function() { |
||||||
|
return old_stdout; |
||||||
|
}); |
||||||
|
if (pbjs_status !== pbjs.STATUS_OK) { |
||||||
|
throw new Error('pbjs failed with status code ' + pbjs_status); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
exports.main = main; |
@ -0,0 +1,36 @@ |
|||||||
|
/* |
||||||
|
* |
||||||
|
* Copyright 2015, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
var grpc = require('grpc'); |
||||||
|
exports.client = grpc.load(__dirname + '/service.json', 'json'); |
||||||
|
exports.auth = require('google-auth-library'); |
@ -0,0 +1,17 @@ |
|||||||
|
{ |
||||||
|
"name": "{{{name}}}", |
||||||
|
"version": "{{{version}}}", |
||||||
|
"author": "Google Inc.", |
||||||
|
"description": "Client library for {{{name}}} built on gRPC", |
||||||
|
"license": "Apache-2.0", |
||||||
|
"dependencies": { |
||||||
|
"grpc": "{{{grpc_version}}}", |
||||||
|
"google-auth-library": "^0.9.2" |
||||||
|
}, |
||||||
|
"main": "index.js", |
||||||
|
"files": [ |
||||||
|
"LICENSE", |
||||||
|
"index.js", |
||||||
|
"service.json" |
||||||
|
] |
||||||
|
} |
@ -1,3 +1,47 @@ |
|||||||
gRPC implementation for Objective-C on iOS |
# gRPC for Objective-C |
||||||
|
|
||||||
This is a work in progress. |
## How to generate a client library from a Protocol Buffers definition |
||||||
|
|
||||||
|
First install v3 of the Protocol Buffers compiler (_protoc_), by cloning [its Git repository](https://github.com/google/protobuf) and following these [installation instructions](https://github.com/google/protobuf#c-installation---unix) (the ones titled C++; don't miss the note for Mac users). |
||||||
|
|
||||||
|
Then clone this repository and execute the following commands from the root directory where it was cloned. |
||||||
|
|
||||||
|
Compile the gRPC plugins for _protoc_: |
||||||
|
```sh |
||||||
|
make plugins |
||||||
|
``` |
||||||
|
|
||||||
|
Create a symbolic link to the compiled plugin binary somewhere in your `$PATH`: |
||||||
|
```sh |
||||||
|
ln -s `pwd`/bins/opt/grpc_objective_c_plugin /usr/local/bin/protoc-gen-objcgrpc |
||||||
|
``` |
||||||
|
(Notice that the name of the created link must begin with "protoc-gen-" for _protoc_ to recognize it as a plugin). |
||||||
|
|
||||||
|
If you don't want to create the symbolic link, you can alternatively copy the binary (with the appropriate name). Or you might prefer instead to specify the plugin's path as a flag when invoking _protoc_, in which case no system modification nor renaming is necessary. |
||||||
|
|
||||||
|
Finally, run _protoc_ with the following flags to generate the client library for your `.proto` files: |
||||||
|
|
||||||
|
```sh |
||||||
|
protoc --objc_out=. --objcrpc_out=. *.proto |
||||||
|
``` |
||||||
|
|
||||||
|
This will generate a pair of `.pbobjc.h`/`.pbobjc.m` files for each `.proto` file, with the messages and enums defined in them. And a pair of `.pbrpc.h`/`.pbrpc.m` files for each `.proto` file with services defined. The latter contains the code to make remote calls to the specified API. |
||||||
|
|
||||||
|
## How to integrate a generated gRPC library in your project |
||||||
|
|
||||||
|
### If you use Cocoapods |
||||||
|
|
||||||
|
This is the recommended approach. |
||||||
|
|
||||||
|
You need to create a Podspec file for the generated library. This is simply a matter of copying an example like [this one](https://github.com/grpc/grpc/blob/master/src/objective-c/examples/Sample/RemoteTestClient/RemoteTest.podspec) to the directory where the source files were generated. Update the name and other metadata of the Podspec as suitable. |
||||||
|
|
||||||
|
Once your library has a Podspec, refer to it from your Podfile using `:path` as described [here](https://guides.cocoapods.org/using/the-podfile.html#using-the-files-from-a-folder-local-to-the-machine). |
||||||
|
|
||||||
|
### If you don't use Cocoapods |
||||||
|
|
||||||
|
You need to compile the generated `.pbpbjc.*` files (the enums and messages) without ARC support, and the generated `.pbrpc.*` files (the services) with ARC support. The generated code depends on v0.3+ of the Objective-C gRPC runtime library and v3.0+ of the Objective-C Protobuf runtime library. |
||||||
|
|
||||||
|
These libraries need to be integrated into your project as described in their respective Podspec files: |
||||||
|
|
||||||
|
* [Podspec](https://github.com/grpc/grpc/blob/master/gRPC.podspec) for the Objective-C gRPC runtime library. This can be tedious to configure manually. |
||||||
|
* [Podspec](https://github.com/jcanizales/protobuf/blob/add-podspec/Protobuf.podspec) for the Objective-C Protobuf runtime library. |
||||||
|
@ -0,0 +1,59 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2015, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#import <Foundation/Foundation.h> |
||||||
|
|
||||||
|
#import "GRXWriteable.h" |
||||||
|
#import "GRXWriter.h" |
||||||
|
|
||||||
|
// A buffered pipe is a Writeable that also acts as a Writer (to whichever other writeable is passed
|
||||||
|
// to -startWithWriteable:).
|
||||||
|
// Once it is started, whatever values are written into it (via -writeValue:) will be propagated
|
||||||
|
// immediately, unless flow control prevents it.
|
||||||
|
// If it is throttled and keeps receiving values, as well as if it receives values before being
|
||||||
|
// started, it will buffer them and propagate them in order as soon as its state becomes
|
||||||
|
// GRXWriterStateStarted.
|
||||||
|
// If it receives an error (via -writesFinishedWithError:), it will drop any buffered values and
|
||||||
|
// propagate the error immediately.
|
||||||
|
//
|
||||||
|
// Beware that a pipe of this type can't prevent receiving more values when it is paused (for
|
||||||
|
// example if used to write data to a congested network connection). Because in such situations the
|
||||||
|
// pipe will keep buffering all data written to it, your application could run out of memory and
|
||||||
|
// crash. If you want to react to flow control signals to prevent that, instead of using this class
|
||||||
|
// you can implement an object that conforms to GRXWriter.
|
||||||
|
@interface GRXBufferedPipe : NSObject<GRXWriteable, GRXWriter> |
||||||
|
|
||||||
|
// Convenience constructor.
|
||||||
|
+ (instancetype)pipe; |
||||||
|
|
||||||
|
@end |
@ -0,0 +1,146 @@ |
|||||||
|
/* |
||||||
|
* |
||||||
|
* Copyright 2015, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#import "GRXBufferedPipe.h" |
||||||
|
|
||||||
|
@implementation GRXBufferedPipe { |
||||||
|
id<GRXWriteable> _writeable; |
||||||
|
NSMutableArray *_queue; |
||||||
|
BOOL _inputIsFinished; |
||||||
|
NSError *_errorOrNil; |
||||||
|
} |
||||||
|
|
||||||
|
@synthesize state = _state; |
||||||
|
|
||||||
|
+ (instancetype)pipe { |
||||||
|
return [[self alloc] init]; |
||||||
|
} |
||||||
|
|
||||||
|
- (instancetype)init { |
||||||
|
if (self = [super init]) { |
||||||
|
_queue = [NSMutableArray array]; |
||||||
|
_state = GRXWriterStateNotStarted; |
||||||
|
} |
||||||
|
return self; |
||||||
|
} |
||||||
|
|
||||||
|
- (id)popValue { |
||||||
|
id value = _queue[0]; |
||||||
|
[_queue removeObjectAtIndex:0]; |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
- (void)writeBufferUntilPausedOrStopped { |
||||||
|
while (_state == GRXWriterStateStarted && _queue.count > 0) { |
||||||
|
[_writeable writeValue:[self popValue]]; |
||||||
|
} |
||||||
|
if (_inputIsFinished && _queue.count == 0) { |
||||||
|
// Our writer finished normally while we were paused or not-started-yet. |
||||||
|
[self finishWithError:_errorOrNil]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#pragma mark GRXWriteable implementation |
||||||
|
|
||||||
|
// Returns whether events can be simply propagated to the other end of the pipe. |
||||||
|
- (BOOL)shouldFastForward { |
||||||
|
return _state == GRXWriterStateStarted && _queue.count == 0; |
||||||
|
} |
||||||
|
|
||||||
|
- (void)writeValue:(id)value { |
||||||
|
if (self.shouldFastForward) { |
||||||
|
// Skip the queue. |
||||||
|
[_writeable writeValue:value]; |
||||||
|
} else { |
||||||
|
// Even if we're paused and with enqueued values, we can't excert back-pressure to our writer. |
||||||
|
// So just buffer the new value. |
||||||
|
// We need a copy, so that it doesn't mutate before it's written at the other end of the pipe. |
||||||
|
if ([value respondsToSelector:@selector(copy)]) { |
||||||
|
value = [value copy]; |
||||||
|
} |
||||||
|
[_queue addObject:value]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
- (void)writesFinishedWithError:(NSError *)errorOrNil { |
||||||
|
_inputIsFinished = YES; |
||||||
|
_errorOrNil = errorOrNil; |
||||||
|
if (errorOrNil || self.shouldFastForward) { |
||||||
|
// No need to write pending values. |
||||||
|
[self finishWithError:_errorOrNil]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#pragma mark GRXWriter implementation |
||||||
|
|
||||||
|
- (void)setState:(GRXWriterState)newState { |
||||||
|
// Manual transitions are only allowed from the started or paused states. |
||||||
|
if (_state == GRXWriterStateNotStarted || _state == GRXWriterStateFinished) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
switch (newState) { |
||||||
|
case GRXWriterStateFinished: |
||||||
|
_state = newState; |
||||||
|
_queue = nil; |
||||||
|
// Per GRXWriter's contract, setting the state to Finished manually means one doesn't wish the |
||||||
|
// writeable to be messaged anymore. |
||||||
|
_writeable = nil; |
||||||
|
return; |
||||||
|
case GRXWriterStatePaused: |
||||||
|
_state = newState; |
||||||
|
return; |
||||||
|
case GRXWriterStateStarted: |
||||||
|
if (_state == GRXWriterStatePaused) { |
||||||
|
_state = newState; |
||||||
|
[self writeBufferUntilPausedOrStopped]; |
||||||
|
} |
||||||
|
return; |
||||||
|
case GRXWriterStateNotStarted: |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
- (void)startWithWriteable:(id<GRXWriteable>)writeable { |
||||||
|
_state = GRXWriterStateStarted; |
||||||
|
_writeable = writeable; |
||||||
|
[self writeBufferUntilPausedOrStopped]; |
||||||
|
} |
||||||
|
|
||||||
|
- (void)finishWithError:(NSError *)errorOrNil { |
||||||
|
id<GRXWriteable> writeable = _writeable; |
||||||
|
self.state = GRXWriterStateFinished; |
||||||
|
[writeable writesFinishedWithError:errorOrNil]; |
||||||
|
} |
||||||
|
|
||||||
|
@end |
@ -1,103 +0,0 @@ |
|||||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
||||||
|
|
||||||
#import <ProtocolBuffers/ProtocolBuffers.h> |
|
||||||
|
|
||||||
// @@protoc_insertion_point(imports)
|
|
||||||
|
|
||||||
@class ObjectiveCFileOptions; |
|
||||||
@class ObjectiveCFileOptionsBuilder; |
|
||||||
@class PBDescriptorProto; |
|
||||||
@class PBDescriptorProtoBuilder; |
|
||||||
@class PBDescriptorProtoExtensionRange; |
|
||||||
@class PBDescriptorProtoExtensionRangeBuilder; |
|
||||||
@class PBEnumDescriptorProto; |
|
||||||
@class PBEnumDescriptorProtoBuilder; |
|
||||||
@class PBEnumOptions; |
|
||||||
@class PBEnumOptionsBuilder; |
|
||||||
@class PBEnumValueDescriptorProto; |
|
||||||
@class PBEnumValueDescriptorProtoBuilder; |
|
||||||
@class PBEnumValueOptions; |
|
||||||
@class PBEnumValueOptionsBuilder; |
|
||||||
@class PBFieldDescriptorProto; |
|
||||||
@class PBFieldDescriptorProtoBuilder; |
|
||||||
@class PBFieldOptions; |
|
||||||
@class PBFieldOptionsBuilder; |
|
||||||
@class PBFileDescriptorProto; |
|
||||||
@class PBFileDescriptorProtoBuilder; |
|
||||||
@class PBFileDescriptorSet; |
|
||||||
@class PBFileDescriptorSetBuilder; |
|
||||||
@class PBFileOptions; |
|
||||||
@class PBFileOptionsBuilder; |
|
||||||
@class PBMessageOptions; |
|
||||||
@class PBMessageOptionsBuilder; |
|
||||||
@class PBMethodDescriptorProto; |
|
||||||
@class PBMethodDescriptorProtoBuilder; |
|
||||||
@class PBMethodOptions; |
|
||||||
@class PBMethodOptionsBuilder; |
|
||||||
@class PBOneofDescriptorProto; |
|
||||||
@class PBOneofDescriptorProtoBuilder; |
|
||||||
@class PBServiceDescriptorProto; |
|
||||||
@class PBServiceDescriptorProtoBuilder; |
|
||||||
@class PBServiceOptions; |
|
||||||
@class PBServiceOptionsBuilder; |
|
||||||
@class PBSourceCodeInfo; |
|
||||||
@class PBSourceCodeInfoBuilder; |
|
||||||
@class PBSourceCodeInfoLocation; |
|
||||||
@class PBSourceCodeInfoLocationBuilder; |
|
||||||
@class PBUninterpretedOption; |
|
||||||
@class PBUninterpretedOptionBuilder; |
|
||||||
@class PBUninterpretedOptionNamePart; |
|
||||||
@class PBUninterpretedOptionNamePartBuilder; |
|
||||||
@class RMTEmpty; |
|
||||||
@class RMTEmptyBuilder; |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@interface RMTEmptyRoot : NSObject { |
|
||||||
} |
|
||||||
+ (PBExtensionRegistry*) extensionRegistry; |
|
||||||
+ (void) registerAllExtensions:(PBMutableExtensionRegistry*) registry; |
|
||||||
@end |
|
||||||
|
|
||||||
@interface RMTEmpty : PBGeneratedMessage<GeneratedMessageProtocol> { |
|
||||||
@private |
|
||||||
} |
|
||||||
|
|
||||||
+ (instancetype) defaultInstance; |
|
||||||
- (instancetype) defaultInstance; |
|
||||||
|
|
||||||
- (BOOL) isInitialized; |
|
||||||
- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output; |
|
||||||
- (RMTEmptyBuilder*) builder; |
|
||||||
+ (RMTEmptyBuilder*) builder; |
|
||||||
+ (RMTEmptyBuilder*) builderWithPrototype:(RMTEmpty*) prototype; |
|
||||||
- (RMTEmptyBuilder*) toBuilder; |
|
||||||
|
|
||||||
+ (RMTEmpty*) parseFromData:(NSData*) data; |
|
||||||
+ (RMTEmpty*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry; |
|
||||||
+ (RMTEmpty*) parseFromInputStream:(NSInputStream*) input; |
|
||||||
+ (RMTEmpty*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry; |
|
||||||
+ (RMTEmpty*) parseFromCodedInputStream:(PBCodedInputStream*) input; |
|
||||||
+ (RMTEmpty*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry; |
|
||||||
@end |
|
||||||
|
|
||||||
@interface RMTEmptyBuilder : PBGeneratedMessageBuilder { |
|
||||||
@private |
|
||||||
RMTEmpty* resultEmpty; |
|
||||||
} |
|
||||||
|
|
||||||
- (RMTEmpty*) defaultInstance; |
|
||||||
|
|
||||||
- (RMTEmptyBuilder*) clear; |
|
||||||
- (RMTEmptyBuilder*) clone; |
|
||||||
|
|
||||||
- (RMTEmpty*) build; |
|
||||||
- (RMTEmpty*) buildPartial; |
|
||||||
|
|
||||||
- (RMTEmptyBuilder*) mergeFrom:(RMTEmpty*) other; |
|
||||||
- (RMTEmptyBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input; |
|
||||||
- (RMTEmptyBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry; |
|
||||||
@end |
|
||||||
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(global_scope)
|
|
@ -1,179 +0,0 @@ |
|||||||
// Generated by the protocol buffer compiler. DO NOT EDIT! |
|
||||||
|
|
||||||
#import "Empty.pb.h" |
|
||||||
// @@protoc_insertion_point(imports) |
|
||||||
|
|
||||||
@implementation RMTEmptyRoot |
|
||||||
static PBExtensionRegistry* extensionRegistry = nil; |
|
||||||
+ (PBExtensionRegistry*) extensionRegistry { |
|
||||||
return extensionRegistry; |
|
||||||
} |
|
||||||
|
|
||||||
+ (void) initialize { |
|
||||||
if (self == [RMTEmptyRoot class]) { |
|
||||||
PBMutableExtensionRegistry* registry = [PBMutableExtensionRegistry registry]; |
|
||||||
[self registerAllExtensions:registry]; |
|
||||||
[ObjectivecDescriptorRoot registerAllExtensions:registry]; |
|
||||||
extensionRegistry = registry; |
|
||||||
} |
|
||||||
} |
|
||||||
+ (void) registerAllExtensions:(PBMutableExtensionRegistry*) registry { |
|
||||||
} |
|
||||||
@end |
|
||||||
|
|
||||||
@interface RMTEmpty () |
|
||||||
@end |
|
||||||
|
|
||||||
@implementation RMTEmpty |
|
||||||
|
|
||||||
- (instancetype) init { |
|
||||||
if ((self = [super init])) { |
|
||||||
} |
|
||||||
return self; |
|
||||||
} |
|
||||||
static RMTEmpty* defaultRMTEmptyInstance = nil; |
|
||||||
+ (void) initialize { |
|
||||||
if (self == [RMTEmpty class]) { |
|
||||||
defaultRMTEmptyInstance = [[RMTEmpty alloc] init]; |
|
||||||
} |
|
||||||
} |
|
||||||
+ (instancetype) defaultInstance { |
|
||||||
return defaultRMTEmptyInstance; |
|
||||||
} |
|
||||||
- (instancetype) defaultInstance { |
|
||||||
return defaultRMTEmptyInstance; |
|
||||||
} |
|
||||||
- (BOOL) isInitialized { |
|
||||||
return YES; |
|
||||||
} |
|
||||||
- (void) writeToCodedOutputStream:(PBCodedOutputStream*) output { |
|
||||||
[self.unknownFields writeToCodedOutputStream:output]; |
|
||||||
} |
|
||||||
- (SInt32) serializedSize { |
|
||||||
__block SInt32 size_ = memoizedSerializedSize; |
|
||||||
if (size_ != -1) { |
|
||||||
return size_; |
|
||||||
} |
|
||||||
|
|
||||||
size_ = 0; |
|
||||||
size_ += self.unknownFields.serializedSize; |
|
||||||
memoizedSerializedSize = size_; |
|
||||||
return size_; |
|
||||||
} |
|
||||||
+ (RMTEmpty*) parseFromData:(NSData*) data { |
|
||||||
return (RMTEmpty*)[[[RMTEmpty builder] mergeFromData:data] build]; |
|
||||||
} |
|
||||||
+ (RMTEmpty*) parseFromData:(NSData*) data extensionRegistry:(PBExtensionRegistry*) extensionRegistry { |
|
||||||
return (RMTEmpty*)[[[RMTEmpty builder] mergeFromData:data extensionRegistry:extensionRegistry] build]; |
|
||||||
} |
|
||||||
+ (RMTEmpty*) parseFromInputStream:(NSInputStream*) input { |
|
||||||
return (RMTEmpty*)[[[RMTEmpty builder] mergeFromInputStream:input] build]; |
|
||||||
} |
|
||||||
+ (RMTEmpty*) parseFromInputStream:(NSInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry { |
|
||||||
return (RMTEmpty*)[[[RMTEmpty builder] mergeFromInputStream:input extensionRegistry:extensionRegistry] build]; |
|
||||||
} |
|
||||||
+ (RMTEmpty*) parseFromCodedInputStream:(PBCodedInputStream*) input { |
|
||||||
return (RMTEmpty*)[[[RMTEmpty builder] mergeFromCodedInputStream:input] build]; |
|
||||||
} |
|
||||||
+ (RMTEmpty*) parseFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry { |
|
||||||
return (RMTEmpty*)[[[RMTEmpty builder] mergeFromCodedInputStream:input extensionRegistry:extensionRegistry] build]; |
|
||||||
} |
|
||||||
+ (RMTEmptyBuilder*) builder { |
|
||||||
return [[RMTEmptyBuilder alloc] init]; |
|
||||||
} |
|
||||||
+ (RMTEmptyBuilder*) builderWithPrototype:(RMTEmpty*) prototype { |
|
||||||
return [[RMTEmpty builder] mergeFrom:prototype]; |
|
||||||
} |
|
||||||
- (RMTEmptyBuilder*) builder { |
|
||||||
return [RMTEmpty builder]; |
|
||||||
} |
|
||||||
- (RMTEmptyBuilder*) toBuilder { |
|
||||||
return [RMTEmpty builderWithPrototype:self]; |
|
||||||
} |
|
||||||
- (void) writeDescriptionTo:(NSMutableString*) output withIndent:(NSString*) indent { |
|
||||||
[self.unknownFields writeDescriptionTo:output withIndent:indent]; |
|
||||||
} |
|
||||||
- (BOOL) isEqual:(id)other { |
|
||||||
if (other == self) { |
|
||||||
return YES; |
|
||||||
} |
|
||||||
if (![other isKindOfClass:[RMTEmpty class]]) { |
|
||||||
return NO; |
|
||||||
} |
|
||||||
RMTEmpty *otherMessage = other; |
|
||||||
return |
|
||||||
(self.unknownFields == otherMessage.unknownFields || (self.unknownFields != nil && [self.unknownFields isEqual:otherMessage.unknownFields])); |
|
||||||
} |
|
||||||
- (NSUInteger) hash { |
|
||||||
__block NSUInteger hashCode = 7; |
|
||||||
hashCode = hashCode * 31 + [self.unknownFields hash]; |
|
||||||
return hashCode; |
|
||||||
} |
|
||||||
@end |
|
||||||
|
|
||||||
@interface RMTEmptyBuilder() |
|
||||||
@property (strong) RMTEmpty* resultEmpty; |
|
||||||
@end |
|
||||||
|
|
||||||
@implementation RMTEmptyBuilder |
|
||||||
@synthesize resultEmpty; |
|
||||||
- (instancetype) init { |
|
||||||
if ((self = [super init])) { |
|
||||||
self.resultEmpty = [[RMTEmpty alloc] init]; |
|
||||||
} |
|
||||||
return self; |
|
||||||
} |
|
||||||
- (PBGeneratedMessage*) internalGetResult { |
|
||||||
return resultEmpty; |
|
||||||
} |
|
||||||
- (RMTEmptyBuilder*) clear { |
|
||||||
self.resultEmpty = [[RMTEmpty alloc] init]; |
|
||||||
return self; |
|
||||||
} |
|
||||||
- (RMTEmptyBuilder*) clone { |
|
||||||
return [RMTEmpty builderWithPrototype:resultEmpty]; |
|
||||||
} |
|
||||||
- (RMTEmpty*) defaultInstance { |
|
||||||
return [RMTEmpty defaultInstance]; |
|
||||||
} |
|
||||||
- (RMTEmpty*) build { |
|
||||||
[self checkInitialized]; |
|
||||||
return [self buildPartial]; |
|
||||||
} |
|
||||||
- (RMTEmpty*) buildPartial { |
|
||||||
RMTEmpty* returnMe = resultEmpty; |
|
||||||
self.resultEmpty = nil; |
|
||||||
return returnMe; |
|
||||||
} |
|
||||||
- (RMTEmptyBuilder*) mergeFrom:(RMTEmpty*) other { |
|
||||||
if (other == [RMTEmpty defaultInstance]) { |
|
||||||
return self; |
|
||||||
} |
|
||||||
[self mergeUnknownFields:other.unknownFields]; |
|
||||||
return self; |
|
||||||
} |
|
||||||
- (RMTEmptyBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input { |
|
||||||
return [self mergeFromCodedInputStream:input extensionRegistry:[PBExtensionRegistry emptyRegistry]]; |
|
||||||
} |
|
||||||
- (RMTEmptyBuilder*) mergeFromCodedInputStream:(PBCodedInputStream*) input extensionRegistry:(PBExtensionRegistry*) extensionRegistry { |
|
||||||
PBUnknownFieldSetBuilder* unknownFields = [PBUnknownFieldSet builderWithUnknownFields:self.unknownFields]; |
|
||||||
while (YES) { |
|
||||||
SInt32 tag = [input readTag]; |
|
||||||
switch (tag) { |
|
||||||
case 0: |
|
||||||
[self setUnknownFields:[unknownFields build]]; |
|
||||||
return self; |
|
||||||
default: { |
|
||||||
if (![self parseUnknownField:input unknownFields:unknownFields extensionRegistry:extensionRegistry tag:tag]) { |
|
||||||
[self setUnknownFields:[unknownFields build]]; |
|
||||||
return self; |
|
||||||
} |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@end |
|
||||||
|
|
||||||
|
|
||||||
// @@protoc_insertion_point(global_scope) |
|
@ -0,0 +1,33 @@ |
|||||||
|
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||||
|
// source: empty.proto
|
||||||
|
|
||||||
|
#import "GPBProtocolBuffers.h" |
||||||
|
|
||||||
|
#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != 30000 |
||||||
|
#error This file was generated by a different version of protoc-gen-objc which is incompatible with your Protocol Buffer sources. |
||||||
|
#endif |
||||||
|
|
||||||
|
CF_EXTERN_C_BEGIN |
||||||
|
|
||||||
|
@class RMTEmpty; |
||||||
|
|
||||||
|
|
||||||
|
#pragma mark - RMTEmptyRoot |
||||||
|
|
||||||
|
@interface RMTEmptyRoot : GPBRootObject |
||||||
|
@end |
||||||
|
|
||||||
|
#pragma mark - RMTEmpty |
||||||
|
|
||||||
|
// An empty message that you can re-use to avoid defining duplicated empty
|
||||||
|
// messages in your project. A typical example is to use it as argument or the
|
||||||
|
// return value of a service API. For instance:
|
||||||
|
//
|
||||||
|
// service Foo {
|
||||||
|
// rpc Bar (grpc.testing.Empty) returns (grpc.testing.Empty) { };
|
||||||
|
// };
|
||||||
|
@interface RMTEmpty : GPBMessage |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
CF_EXTERN_C_END |
@ -0,0 +1,59 @@ |
|||||||
|
// Generated by the protocol buffer compiler. DO NOT EDIT! |
||||||
|
// source: empty.proto |
||||||
|
|
||||||
|
#import "GPBProtocolBuffers_RuntimeSupport.h" |
||||||
|
|
||||||
|
#import "Empty.pbobjc.h" |
||||||
|
|
||||||
|
#pragma mark - RMTEmptyRoot |
||||||
|
|
||||||
|
@implementation RMTEmptyRoot |
||||||
|
|
||||||
|
@end |
||||||
|
|
||||||
|
static GPBFileDescriptor *RMTEmptyRoot_FileDescriptor(void) { |
||||||
|
// This is called by +initialize so there is no need to worry |
||||||
|
// about thread safety of the singleton. |
||||||
|
static GPBFileDescriptor *descriptor = NULL; |
||||||
|
if (!descriptor) { |
||||||
|
descriptor = [[GPBFileDescriptor alloc] initWithPackage:@"grpc.testing" |
||||||
|
syntax:GPBFileSyntaxProto3]; |
||||||
|
} |
||||||
|
return descriptor; |
||||||
|
} |
||||||
|
|
||||||
|
#pragma mark - RMTEmpty |
||||||
|
|
||||||
|
@implementation RMTEmpty |
||||||
|
|
||||||
|
|
||||||
|
typedef struct RMTEmpty_Storage { |
||||||
|
uint32_t _has_storage_[0]; |
||||||
|
} RMTEmpty_Storage; |
||||||
|
|
||||||
|
// This method is threadsafe because it is initially called |
||||||
|
// in +initialize for each subclass. |
||||||
|
+ (GPBDescriptor *)descriptor { |
||||||
|
static GPBDescriptor *descriptor = NULL; |
||||||
|
if (!descriptor) { |
||||||
|
static GPBMessageFieldDescription fields[] = { |
||||||
|
}; |
||||||
|
descriptor = [GPBDescriptor allocDescriptorForClass:[RMTEmpty class] |
||||||
|
rootClass:[RMTEmptyRoot class] |
||||||
|
file:RMTEmptyRoot_FileDescriptor() |
||||||
|
fields:fields |
||||||
|
fieldCount:sizeof(fields) / sizeof(GPBMessageFieldDescription) |
||||||
|
oneofs:NULL |
||||||
|
oneofCount:0 |
||||||
|
enums:NULL |
||||||
|
enumCount:0 |
||||||
|
ranges:NULL |
||||||
|
rangeCount:0 |
||||||
|
storageSize:sizeof(RMTEmpty_Storage) |
||||||
|
wireFormat:NO]; |
||||||
|
} |
||||||
|
return descriptor; |
||||||
|
} |
||||||
|
|
||||||
|
@end |
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue