Skip to content

Commit

Permalink
Merge github.com:grpc/grpc into better-profile
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Nov 21, 2015
2 parents 860f484 + ceb7318 commit d653b39
Show file tree
Hide file tree
Showing 294 changed files with 14,448 additions and 2,416 deletions.
441 changes: 434 additions & 7 deletions Makefile

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,12 @@
"src/node/ext/node_grpc.cc",
"src/node/ext/server.cc",
"src/node/ext/server_credentials.cc",
"src/node/ext/timeval.cc"
"src/node/ext/timeval.cc",
],
"dependencies": [
"grpc"
"grpc",
"gpr",
]
}
},
]
}
52 changes: 51 additions & 1 deletion build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ settings:
'#': The public version number of the library.
version:
major: 0
minor: 11
minor: 12
micro: 0
build: 0
filegroups:
Expand Down Expand Up @@ -1887,6 +1887,20 @@ targets:
- mac
- linux
- posix
- name: metrics_client
build: test
run: false
language: c++
headers:
- test/cpp/util/metrics_server.h
src:
- test/proto/metrics.proto
- test/cpp/interop/metrics_client.cc
deps:
- grpc++
- grpc
- gpr
- grpc++_test_config
- name: mock_test
build: test
language: c++
Expand Down Expand Up @@ -2127,13 +2141,16 @@ targets:
- test/cpp/interop/client_helper.h
- test/cpp/interop/interop_client.h
- test/cpp/interop/stress_interop_client.h
- test/cpp/util/metrics_server.h
src:
- test/proto/empty.proto
- test/proto/messages.proto
- test/proto/metrics.proto
- test/proto/test.proto
- test/cpp/interop/interop_client.cc
- test/cpp/interop/stress_interop_client.cc
- test/cpp/interop/stress_test.cc
- test/cpp/util/metrics_server.cc
deps:
- grpc++_test_util
- grpc_test_util
Expand Down Expand Up @@ -2224,3 +2241,36 @@ vspackages:
props: false
redist: false
version: 1.7.0.1
node_modules:
- deps:
- grpc
- gpr
headers:
- src/node/ext/byte_buffer.h
- src/node/ext/call.h
- src/node/ext/call_credentials.h
- src/node/ext/channel.h
- src/node/ext/channel_credentials.h
- src/node/ext/completion_queue_async_worker.h
- src/node/ext/server.h
- src/node/ext/server_credentials.h
- src/node/ext/timeval.h
js:
- src/node/index.js
- src/node/src/client.js
- src/node/src/common.js
- src/node/src/credentials.js
- src/node/src/metadata.js
- src/node/src/server.js
name: grpc_node
src:
- src/node/ext/byte_buffer.cc
- src/node/ext/call.cc
- src/node/ext/call_credentials.cc
- src/node/ext/channel.cc
- src/node/ext/channel_credentials.cc
- src/node/ext/completion_queue_async_worker.cc
- src/node/ext/node_grpc.cc
- src/node/ext/server.cc
- src/node/ext/server_credentials.cc
- src/node/ext/timeval.cc
20 changes: 19 additions & 1 deletion doc/PROTOCOL-HTTP2.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ Request-Headers are delivered as HTTP2 headers in HEADERS + CONTINUATION frames.
* **Message-Type** → "grpc-message-type" {_type name for message schema_}
* **Custom-Metadata** → Binary-Header / ASCII-Header
* **Binary-Header** → {Header-Name "-bin" } {_base64 encoded value_}
* **ASCII-Header** → Header-Name {_value_}
* **ASCII-Header** → Header-Name ASCII-Value
* **Header-Name** → 1\*( %x30-39 / %x61-7A / "\_" / "-") ; 0-9 a-z \_ -
* **ASCII-Value** → 1\*( %x20-%x7E ) ; space and printable ASCII


HTTP2 requires that reserved headers, ones starting with ":" appear before all other headers. Additionally implementations should send **Timeout** immediately after the reserved headers and they should send the **Call-Definition** headers before sending **Custom-Metadata**.
Expand All @@ -56,6 +57,23 @@ If **Timeout** is omitted a server should assume an infinite timeout. Client imp

Note that HTTP2 does not allow arbitrary octet sequences for header values so binary header values must be encoded using Base64 as per https://tools.ietf.org/html/rfc4648#section-4. Implementations MUST accept padded and un-padded values and should emit un-padded values. Applications define binary headers by having their names end with "-bin". Runtime libraries use this suffix to detect binary headers and properly apply base64 encoding & decoding as headers are sent and received.

**Custom-Metadata** header order is not guaranteed to be preserved except for
values with duplicate header names. Duplicate header names may have their values
joined with "," as the delimiter and be considered semantically equivalent.
Implementations must split **Binary-Header**s on "," before decoding the
Base64-encoded values.

**ASCII-Value** should not have leading or trailing whitespace. If it contains
leading or trailing whitespace, it may be stripped. The **ASCII-Value**
character range defined is more strict than HTTP. Implementations must not error
due to receiving an invalid **ASCII-Value** that's a valid **field-value** in
HTTP, but the precise behavior is not strictly defined: they may throw the value
away or accept the value. If accepted, care must be taken to make sure that the
application is permitted to echo the value back as metadata. For example, if the
metadata is provided to the application as a list in a request, the application
should not trigger an error by providing that same list as the metadata in the
response.

Servers may limit the size of **Request-Headers**, with a default of 8 KiB
suggested. Implementations are encouraged to compute total header size like
HTTP/2's `SETTINGS_MAX_HEADER_LIST_SIZE`: the sum of all header fields, for each
Expand Down
8 changes: 4 additions & 4 deletions doc/grpc-auth-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ authenticate the server and encrypt all data.
```cpp
SslCredentialsOptions ssl_opts; // Options to override SSL params, empty by default
// Create the credentials object by providing service account key in constructor
std::unique_ptr<Credentials> creds = CredentialsFactory::SslCredentials(ssl_opts);
std::shared_ptr<ChannelCredentials> creds = SslCredentials(ssl_opts);
// Create a channel using the credentials created in the previous step
std::shared_ptr<ChannelInterface> channel = CreateChannel(server_name, creds, channel_args);
std::shared_ptr<Channel> channel = CreateChannel(server_name, creds);
// Create a stub on the channel
std::unique_ptr<Greeter::Stub> stub(Greeter::NewStub(channel));
// Make actual RPC calls on the stub.
Expand All @@ -55,9 +55,9 @@ passed to the factory method.
gRPC applications can use a simple API to create a credential that works in various deployment scenarios.
```cpp
std::unique_ptr<Credentials> creds = CredentialsFactory::GoogleDefaultCredentials();
std::shared_ptr<ChannelCredentials> creds = GoogleDefaultCredentials();
// Create a channel, stub and make RPC calls (same as in the previous example)
std::shared_ptr<ChannelInterface> channel = CreateChannel(server_name, creds, channel_args);
std::shared_ptr<Channel> channel = CreateChannel(server_name, creds);
std::unique_ptr<Greeter::Stub> stub(Greeter::NewStub(channel));
grpc::Status s = stub->sayHello(&context, *request, response);
```
Expand Down
2 changes: 1 addition & 1 deletion doc/interop-test-descriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Interoperability Test Case Descriptions
Client and server use
[test.proto](https://github.com/grpc/grpc/blob/master/test/proto/test.proto)
and the [gRPC over HTTP/2 v2
protocol](doc/PROTOCOL-HTTP2.md).
protocol](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md).

Client
------
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/cpptutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ To call service methods, we first need to create a *stub*.
First we need to create a gRPC *channel* for our stub, specifying the server address and port we want to connect to without SSL:

```cpp
grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials());
grpc::CreateChannel("localhost:50051", grpc::InsecureChannelCredentials());
```
Now we can use the channel to create our stub using the `NewStub` method provided in the `RouteGuide` class we generated from our .proto.
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/helloworld/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ $ protoc -I ../../protos/ --cpp_out=. ../../protos/helloworld.proto
arguments as follows

```
auto channel = CreateChannel("localhost:50051", InsecureCredentials());
auto channel = CreateChannel("localhost:50051", InsecureChannelCredentials());
```
- Create a stub. A stub implements the rpc methods of a service and in the
Expand Down
6 changes: 3 additions & 3 deletions examples/cpp/helloworld/greeter_async_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ int main(int argc, char** argv) {
// Instantiate the client. It requires a channel, out of which the actual RPCs
// are created. This channel models a connection to an endpoint (in this case,
// localhost at port 50051). We indicate that the channel isn't authenticated
// (use of InsecureCredentials()).
GreeterClient greeter(
grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials()));
// (use of InsecureChannelCredentials()).
GreeterClient greeter(grpc::CreateChannel(
"localhost:50051", grpc::InsecureChannelCredentials()));
std::string user("world");
std::string reply = greeter.SayHello(user); // The actual RPC call!
std::cout << "Greeter received: " << reply << std::endl;
Expand Down
6 changes: 3 additions & 3 deletions examples/cpp/helloworld/greeter_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ int main(int argc, char** argv) {
// Instantiate the client. It requires a channel, out of which the actual RPCs
// are created. This channel models a connection to an endpoint (in this case,
// localhost at port 50051). We indicate that the channel isn't authenticated
// (use of InsecureCredentials()).
GreeterClient greeter(
grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials()));
// (use of InsecureChannelCredentials()).
GreeterClient greeter(grpc::CreateChannel(
"localhost:50051", grpc::InsecureChannelCredentials()));
std::string user("world");
std::string reply = greeter.SayHello(user);
std::cout << "Greeter received: " << reply << std::endl;
Expand Down
3 changes: 2 additions & 1 deletion examples/cpp/route_guide/route_guide_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ int main(int argc, char** argv) {
// Expect only arg: --db_path=path/to/route_guide_db.json.
std::string db = routeguide::GetDbFileContent(argc, argv);
RouteGuideClient guide(
grpc::CreateChannel("localhost:50051", grpc::InsecureCredentials()),
grpc::CreateChannel("localhost:50051",
grpc::InsecureChannelCredentials()),
db);

std::cout << "-------------- GetFeature --------------" << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion examples/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ gRPC in 3 minutes (Node.js)
PREREQUISITES
-------------

- `node`: This requires Node 10.x or greater.
- `node`: This requires Node 0.10.x or greater.
- [homebrew][] on Mac OS X. This simplifies the installation of the gRPC C core.

INSTALL
Expand Down
2 changes: 1 addition & 1 deletion examples/python/helloworld/greeter_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def serve():
while True:
time.sleep(_ONE_DAY_IN_SECONDS)
except KeyboardInterrupt:
server.stop()
server.stop(0)

if __name__ == '__main__':
serve()
4 changes: 2 additions & 2 deletions include/grpc++/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ namespace grpc {
class CallOpSetInterface;
class ChannelArguments;
class CompletionQueue;
class Credentials;
class SecureCredentials;
class ChannelCredentials;
class SecureChannelCredentials;

template <class R>
class ClientReader;
Expand Down
17 changes: 10 additions & 7 deletions include/grpc++/client_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,24 @@
#include <memory>
#include <string>

#include <grpc/compression.h>
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc++/impl/sync.h>
#include <grpc++/security/auth_context.h>
#include <grpc++/support/config.h>
#include <grpc++/support/status.h>
#include <grpc++/support/string_ref.h>
#include <grpc++/support/time.h>
#include <grpc/compression.h>
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>

struct census_context;

namespace grpc {

class Channel;
class CompletionQueue;
class Credentials;
class CallCredentials;
class RpcMethod;
template <class R>
class ClientReader;
Expand Down Expand Up @@ -244,7 +245,7 @@ class ClientContext {
/// call.
///
/// \see https://github.com/grpc/grpc/blob/master/doc/grpc-auth-support.md
void set_credentials(const std::shared_ptr<Credentials>& creds) {
void set_credentials(const std::shared_ptr<CallCredentials>& creds) {
creds_ = creds;
}

Expand Down Expand Up @@ -315,10 +316,12 @@ class ClientContext {

bool initial_metadata_received_;
std::shared_ptr<Channel> channel_;
grpc::mutex mu_;
grpc_call* call_;
bool call_canceled_;
gpr_timespec deadline_;
grpc::string authority_;
std::shared_ptr<Credentials> creds_;
std::shared_ptr<CallCredentials> creds_;
mutable std::shared_ptr<const AuthContext> auth_context_;
struct census_context* census_context_;
std::multimap<grpc::string, grpc::string> send_initial_metadata_;
Expand Down
6 changes: 4 additions & 2 deletions include/grpc++/create_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ namespace grpc {
/// an object or is invalid, a lame channel is returned.
/// \param args Options for channel creation.
std::shared_ptr<Channel> CreateChannel(
const grpc::string& target, const std::shared_ptr<Credentials>& creds);
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds);

/// Create a new \em custom \a Channel pointing to \a target
///
Expand All @@ -61,7 +62,8 @@ std::shared_ptr<Channel> CreateChannel(
/// an object or is invalid, a lame channel is returned.
/// \param args Options for channel creation.
std::shared_ptr<Channel> CreateCustomChannel(
const grpc::string& target, const std::shared_ptr<Credentials>& creds,
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args);

} // namespace grpc
Expand Down
Loading

0 comments on commit d653b39

Please sign in to comment.