Commit Graph

219 Commits

Author SHA1 Message Date
Xudong Ma 47ad6f81bf Fix the double-closure of server call for interop tests. 2015-09-15 16:40:59 -07:00
Eric Anderson 1cfba96d17 Enforce sending headers before messages on server
ServerCall already had "headers must be sent before any messages, which
must be sent before closing," but the implementation did not enforce it
and our async server handler didn't obey.

The benefit of forcing sending headers first is that it removes the only
implicit call in our API and interceptors dealing just with metadata
don't need to override sendMessage. The implicit behavior was bug-prone
since it wasn't obvious you were forgetting that headers may not be
sent.
2015-09-11 17:39:40 -07:00
Eric Anderson 701f9cd7ee Remove stray request() in server-sending path 2015-09-11 17:37:22 -07:00
Eric Anderson 9cb36c6e20 Mark some APIs codegen uses experimental to allow for optimizations
Fixes #975
2015-09-11 11:13:27 -07:00
Eric Anderson be0d7e911a Prevent construction of container classes and reduce API 2015-09-10 10:09:13 -07:00
Eric Anderson 23e6318156 Reduce API surface of AbstractStub 2015-09-10 08:36:08 -07:00
Carl Mastrangelo 399be9ac73 Use stub call options for compression 2015-09-09 13:21:04 -07:00
Xudong Ma 0a51f0fbd9 Move StreamRecorder to testing package. 2015-09-01 09:15:03 -07:00
Louis Ryan a4c821d94e Rename onValue to onNext in StreamObserver to align with the naming in Rx & the proposed Flow API in
Java9
2015-08-26 17:38:22 -07:00
nmittler d5977c4552 Fixing the benchmarks
Fixes #873
2015-08-26 13:55:39 -07:00
Carl Mastrangelo a508c1d4f5 Remove Headers 2015-08-24 11:41:10 -07:00
Carl Mastrangelo 572f4332a7 Remove Trailers 2015-08-13 17:11:29 -07:00
Carl Mastrangelo b141093b3b Make serverInterceptor use MethodDescriptor 2015-08-07 09:28:29 -07:00
Carl Mastrangelo e76b8e7ee8 Renamed Server payload to message 2015-08-05 17:10:37 -07:00
Carl Mastrangelo 67fc45d036 Rename Duplex to Bidi 2015-08-05 17:05:47 -07:00
Carl Mastrangelo 89db769d2d Rename sendPayload to sendMessage 2015-07-31 15:28:06 -07:00
Carl Mastrangelo 14e774130d Rename onPayload to onMessage 2015-07-31 15:11:18 -07:00
Kun Zhang 60cf5eb5da Use mutation methods for stub reconfiguration.
This makes the reconfiguration code more concise.

- Remove configureNewStub().
- Add mutation methods withDeadlineNanoTime(), withChannel() etc that
  returns the reconfigured stub.
2015-07-23 11:17:35 -07:00
Kun Zhang eb92967a7e Get rid of AbstractServiceDescriptor as it is no longer useful 2015-07-17 17:03:36 -07:00
Kun Zhang b80abef13f Optimize for flow-control: only request for 2 responses in unary-response cases 2015-07-17 09:09:29 -07:00
Kun Zhang d28535bb20 Fail call if more than responses received while only one is expected 2015-07-16 18:17:07 -07:00
Kun Zhang 686dcff217 Rename unaryFutureCall to futureUnaryCall 2015-07-16 12:34:37 -07:00
Kun Zhang 690b26eb93 Sanitize ClientCalls.
- Remove blockingClientStreamingCall() which is not used, and we don't
  actually want that API.
- Rename duplexStreamingCall() to asyncDuplexStreamingCall() to align
  with other async methods.
- In unary call and client streaming call, do not request for additional
  response after the first response.
2015-07-15 17:35:36 -07:00
Kun Zhang 867c76d185 Separate ServerCall binding utilities per method type.
This gives us more flexibility in API changes in the future.

Unary call and server streaming call should call the flow-control method
call.request() only once. Previously it was called whenever a request
arrives, which is wrong. Now it's fixed.

Resolves #436
2015-07-14 13:36:16 -07:00
Kun Zhang c73b75e477 Change AbstractServiceDescriptor.methods() to Collection. Resolves #573 2015-07-09 14:24:51 -07:00
Kun Zhang 73acc73dbf Remove Method and switch its users to MethodDescriptor.
Resolves #511.

- In generated code, make CONFIG private and METHOD_* fields public.
  METHOD_* fields are MethodDescriptors now, users of the CONFIG field
  should switch to using the METHOD_* fields.
- Move MethodType into MethodDescriptor (#529).
- Unify the fully qualified method name. It is fully qualified service
  name + slash + short method name. It doesn't have the leading slash.
- HandlerRegistry switches the key from short method name to fully
  qualified method name.
2015-07-09 09:29:03 -07:00
Eric Anderson d27cbc8aa3 Improve docs to describe close as being last method called
This isn't changing any of the semantics we already had, but more
informing users of the guarantees we provide.
2015-07-08 15:08:26 -07:00
Kun Zhang d3c5b00827 Add CallOptions.
- Pass CallOptions to Channel.newCall() and
  ClientInterceptor.interceptCall().
- Remove timeout from AbstractStub.StubConfigBuilder and add deadline,
  which is stored in a CallOptions inside the stub.
- Deadline is in nanoseconds in the clock defined by System.nanoTime().
  It is converted to timeout before transmitting on the wire. Fail the
  call with DEADLINE_EXCEEDED if it's already expired.
2015-07-07 14:28:38 -07:00
Eric Anderson 68efade3f5 Set hard-coded deadline to just under 1 year
10 years exceeds the maximum for some systems at the moment. Change to 1
year to workaround such systems while they get changed. And since "have
the default be a large number instead of not present" is a temporary fix
anyway.
2015-07-06 12:48:26 -07:00
Eric Anderson 74b5d29c8a Improve Exception backtrace for blocked streaming
Delaying creating the exception produces a much more useful exception.
The status code, description, and exception type are all identical. The
only difference in the backtrace.
2015-07-01 16:39:15 -07:00
Eric Anderson 7233077cdf Fake infinite timeout; 1s is not a good hard-coded timeout
Stubs don't have any timeout. However, MethodDescriptor does and
requires a timeout. We really want "no timeout," which is infinite, but
we use 10 years as the next best thing. CallOptions will end up fixing
this hack as MethodDescriptor will no longer have timeout.

Before, the hard-coded 1s didn't matter, because nobody was observing
it. Since 77878a0 it is now being sent to servers, and some servers
enforce it. Oops.
2015-07-01 16:24:39 -07:00
Eric Anderson fd52a765ed Blocking calls should error with StatusRuntimeException
Previously, it always threw a RuntimeExecutionException with a
StatusRuntimeException within (since the only callers of setException()
provide a StatusRuntimeException).

Resolves #507
2015-06-18 17:59:32 -07:00
Kun Zhang 2ee4d0228d Rename Call to ClientCalls.
Other classes are already following the convention that ClientFoo for
client-side, and ServerFoo for server-side. Call has been the black
sheep of the family.

- Call -> ClientCall
- Calls -> ClientCalls
- ForwardingCall* -> ForwardingClientCall*
2015-06-04 16:39:25 -07:00
nmittler 64176d5560 Adding outbound flow control for Netty. 2015-05-04 12:19:57 -07:00
nmittler 7779b4fddf Cleaning up some warnings. 2015-04-30 13:57:38 -07:00
Kun Zhang 0d89d3d1bc Fix the issue where the intecepting call fails in start(), does not
call super.start(), and makes the subsequent use of other methods on the
call throw IllegalStateException.

Create ClientInterceptors.CheckedForwardingCall that handles exception
in start logic.

Create Forwarding[Server]Call[Listener] for generic decoration use
cases, with an abstract delegate() for flexibility.

Create SimpleForwarding[Server]Call[Listener] to replace now deprecated
forwarding classes.
2015-04-09 15:56:03 -07:00
Xudong Ma 2cad9e6000 Add "unsed import" check. 2015-04-03 16:55:01 +08:00
Eric Anderson c3e8dae6ce Add checkstyle checking
The checkstyle.xml is a slightly modified version of the upstream Google
checkstyle configuration. All changes have comment describing them.

Lots of warnings were corrected. Examples is the only project that has
warnings still, as the necessary changes require some thought.
2015-03-16 10:53:13 -07:00
zhangkun83 abd4eec055 Implement cancellation for the Future interface. 2015-03-02 10:33:59 -08:00
zhangkun83 c01af90d18 Polish javadoc for stub/* 2015-02-25 15:20:36 -08:00
Louis Ryan 95c6f5082c Udate TODOs to use Github user names 2015-02-23 12:46:28 -08:00
Eric Anderson 746eccaced Fix inbound flow control for Calls.blockingServerStreamingCall
asyncServerStreamingCall provides the initial request(1).

Fixes #93
2015-02-19 09:37:09 -08:00
nmittler f83145865a Removing all references to "stubby" 2015-01-27 11:25:25 -08:00
nmittler de3a13164f Changing gRPC Java inbound flow control model
The goal is to mirror the token-based approach used by the Reactive
Streams API.
2015-01-22 11:46:16 -08:00
ejona 4de2026492 Fix TODO attribution
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=84172357
2015-01-16 16:23:05 -08:00
simonma 828f941e99 Remove dependency on guava Lists for initializing list.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=83808289
2015-01-15 13:42:43 -08:00
nathanmittler 11c363a7ae Disallowing message delivery after status has been delivered to the listener.
Summary of changes:

1) Merged the interfaces MessageDeframer2.Sink and DeframerListener into
MessageDeframer2.Listener. This simplifies the interface of
MessageDeframer2 quite a bit.

2) Added a deliveryPaused() handler to MessageDeframer2.Listener, which
is called by the deframer when there is not enough data to read/deliver
the next message.

3) Modified AbstractStream and AbstractClientStream to manage the timing
of when the closed() event is delivered to the listener. The
transportReportStatus ultimately controls this by creating a task to
close the listener. It either runs this task immediately or when the
next deliveryPaused() event occurs.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=83620903
2015-01-09 17:00:25 -08:00
lryan 56e307fcb6 Add BSD license header to all source files
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=81447025
2015-01-08 14:43:17 -08:00
zhangkun 776ff86687 Eliminate ForwardingChannel and switch all use cases to client interceptors.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=79360027
2015-01-08 14:43:04 -08:00
simonma 3c986bbcdb Move protobuf code dependencies to net/stubby/proto
Remove needless proto dependencies from tests

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78593107
2015-01-08 14:42:59 -08:00
nathanmittler 0304b3d6b2 Cleaning up various compiler warnings in preparation for opensource.
overview:
1) Lots of @SuppressWarnings :)

2) Remove dependencies on StandardCharsets.XXX (which is Java 7)

3) Moved testing/utils/ssl/* to .../stubby/util so that the netty transport doesn't depend directly on the testing module.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78460727
2015-01-08 14:42:59 -08:00
ejona 96e6ed9c53 Define threading requirements of StreamObserver
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78404413
2015-01-08 14:42:58 -08:00
yangg 8b4ecad497 Use "/" instead of "." as the separator between service name and client name.
Change from /Service.method to /Service/method.

quote from the spec:
Method (required): a path identifying the operation to perform on the
specified host, conforming to RFC 3986 sec 3.3. E.g
“/calendar.v1/ListEvents”
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78288091
2015-01-08 14:42:57 -08:00
lryan 28497e3c7e Add support for servers to deliver response headers
Fixes some propagation issues for trailers too
Adds some more testing for metadata exchange

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=77979593
2015-01-08 14:42:56 -08:00
lryan 125c1cee69 Delete Session, Operation and ALL of its associated cruft.
This CL also:
- Removes the OkHTTP server implementation
- Switches NanoTest and Http2OkHttpTest to use Netty server. These tests are currently @Suppressed as OkHttp is not yet draft 14 compliant. Simon is fixing
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76998151
2015-01-08 14:42:53 -08:00
zhangkun bb9699e429 Fixes a few issues in netty server transport:
- Creates and passes a transport instance to ServerListener.transportCreated().
- Keeps the "/" prefix of the fully qualified method name when passing it to the handler
registry.
- Adds necessary "this." when accessing a member variable in ServerCalls.
- BlockingResponseStream.buffer should be added with BlockingResponseStream.this as
as the mark of end of data.

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76922440
2015-01-08 14:42:52 -08:00
zhangkun 01c96175fd GRPC server codegen: generates the bindService() method that returns a
ServerServiceDefinition that connects the server with application-provided
service implementation.

Introduces a class Method, that holds the invariables of a method that are
inferred from the proto file, to be reused for creating MethodDescriptor
for client code and ServerServiceDefinition for server code in the generated
class.

Adds ServerCalls that contains the functionalities that is used by the
bindService() method in the generated class. It minimizes the logic in the
generated code.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76741797
2015-01-08 14:42:51 -08:00
lryan 71e4a92c10 First steps in reducing dependency on proto from runtime.
- Remove transport.proto and move status codes into Status.java with a little refactoring to make
status easier & more precise to use
- Move DeferredProtoInputStream into a proto subpackage
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76392172
2015-01-08 14:42:49 -08:00
lryan 1369ea1d21 Metadata improvements.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=76175838
2015-01-08 14:42:48 -08:00
nathanmittler 23fbc7cb5e Adding support for manually specifying HTTP/2 :authority and :path headers.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75316631
2015-01-08 14:42:44 -08:00
lryan a7d735e69b Phase 2 of converting to new Headers mechanism for side-channel.
Remove 'context' from interfaces/tests/framers/...

Next phases
- Switch the wire format (ESF needs to be done in near lock-step)
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75164642
2015-01-08 14:42:43 -08:00
lryan e4bd1c7d69 Phase 1 of converting to new Headers mechanism for side-channel.
Introduces Header and uses it for propagating text-only header values over existing transports
Leaves Context & wire format otherwise unchanged

Next phases
- Remove context from interfaces
- Switch the wire format (ESF needs to be done in near lock-step)

Interface changes are relatively light
Headers class is functional but not optimal
All serialization is done as string until transports expose interface for binary headers
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=75050265
2015-01-08 14:42:43 -08:00
ejona 621706aa03 Add basic OAuth support to gRPC.
The primary functionality is an interceptor that authenticates calls using oauth. However, most of the changes are for an integration test to make sure the code works with ESF.

This is based on work by lryan and simonma.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=72567773
2015-01-08 14:42:33 -08:00
lryan 34650408aa Add ability to bind HTTP style headers to stubs and have them propagate over
transports that can deliver them.

This unblocks sending OAuth2 headers natively
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=71118741
2015-01-08 14:42:29 -08:00
nathanmittler f4694f57f9 A couple minor fixes to Channel for bugs exposed while integration testing with Netty transport.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69939586
2015-01-08 14:42:26 -08:00
ejona 4d642200e7 [2/2] Swap Operation wrapping from Channel to Transport.
Session is now (properly) implementing transport API, so ChannelImpl has some
testing.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69074094
2015-01-08 14:42:23 -08:00
ejona 35cabd0b82 [1/2] Split Channel and Stub APIs, implement Channel.
Call does not accept InputStream length because Marshaller makes it too hard
for the Stub to determine the length.

SessionCall is updated to implement changes to Call, but it is replaced in the
next CL.

You can see what glue is necessary to join the Transport and Stub APIs. The
ugliest pain is dealing with flow control callback. Some of that code is
unrelated and necessary because the Channel uses a separate thread to run
Call.Listener. Other parts will be necessary because Channel must intervene
during Transport callbacks to handle retry logic.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=69020275
2015-01-08 14:42:23 -08:00
ejona 2af35d9bd3 Improve JavaDoc, including style fixes
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=68555036
2015-01-08 14:42:22 -08:00
ejona 8be938ee25 Move newstub to third_party and rename to stub.
It was an oversight that newstub was not in third_party when committed.

Renaming of package was preformed via a script.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=68416211
2015-01-08 14:42:20 -08:00