Permalink
Browse files

changed namespace to com.twitter.finagle, restored README.md

  • Loading branch information...
1 parent 6371b73 commit 9fa8e1870c04bbf16247e44551060ee0cea65d46 George Vacariuc committed Feb 29, 2012
Showing with 1,869 additions and 292 deletions.
  1. +1,561 −39 README.md
  2. +55 −0 finagle-protobuf/README.md
  3. +2 −2 .../main/scala/com/{tendril → twitter}/finagle/protobuf/rpc/RpcControllerWithOnFailureCallback.scala
  4. +2 −2 finagle-protobuf/src/main/scala/com/{tendril → twitter}/finagle/protobuf/rpc/RpcFactory.scala
  5. +2 −2 finagle-protobuf/src/main/scala/com/{tendril → twitter}/finagle/protobuf/rpc/RpcServer.scala
  6. +1 −1 finagle-protobuf/src/main/scala/com/{tendril → twitter}/finagle/protobuf/rpc/Util.scala
  7. +2 −2 ...tobuf/src/main/scala/com/{tendril → twitter}/finagle/protobuf/rpc/channel/ClientSideDecoder.scala
  8. +2 −2 ...e-protobuf/src/main/scala/com/{tendril → twitter}/finagle/protobuf/rpc/channel/MethodLookup.scala
  9. +1 −1 ...-protobuf/src/main/scala/com/{tendril → twitter}/finagle/protobuf/rpc/channel/ProtoBufCodec.scala
  10. +2 −2 ...rotobuf/src/main/scala/com/{tendril → twitter}/finagle/protobuf/rpc/channel/ProtobufDecoder.scala
  11. +2 −2 ...rotobuf/src/main/scala/com/{tendril → twitter}/finagle/protobuf/rpc/channel/ProtobufEncoder.scala
  12. +2 −2 ...tobuf/src/main/scala/com/{tendril → twitter}/finagle/protobuf/rpc/channel/ServerSideDecoder.scala
  13. +2 −2 ...obuf/src/main/scala/com/{tendril → twitter}/finagle/protobuf/rpc/channel/SimpleMethodLookup.scala
  14. +3 −3 ...le-protobuf/src/main/scala/com/{tendril → twitter}/finagle/protobuf/rpc/impl/RpcChannelImpl.scala
  15. +6 −6 ...le-protobuf/src/main/scala/com/{tendril → twitter}/finagle/protobuf/rpc/impl/RpcFactoryImpl.scala
  16. +3 −3 ...gle-protobuf/src/main/scala/com/{tendril → twitter}/finagle/protobuf/rpc/impl/RpcServerImpl.scala
  17. +10 −10 finagle-protobuf/src/test/java/com/{tendril → twitter}/finagle/protobuf/rpc/RpcIntegrationTest.java
  18. +210 −210 finagle-protobuf/src/test/java/com/{tendril → twitter}/finagle/protobuf/rpc/SampleServiceProtos.java
  19. +1 −1 ...e-protobuf/src/test/java/com/{tendril → twitter}/finagle/protobuf/rpc/SimpleMethodLookupTest.java
View
1,600 README.md

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,55 @@
+
+##### Sample Protobuf based RPC (see RpcIntegrationTest for more samples)
+
+
+ RpcFactory factory = new RpcFactoryImpl();
+
+ ServerBuilder serverBuilder = ServerBuilder.get()
+ .maxConcurrentRequests(10);
+
+ ClientBuilder clientBuilder = ClientBuilder
+ .get()
+ .hosts(String.format("localhost:%s", port))
+ .hostConnectionLimit(1)
+ .retries(2)
+ .requestTimeout(
+ Duration.apply(CLIENT_TIMEOUT_SECONDS, TimeUnit.SECONDS));
+
+
+ SampleWeatherServiceImpl service = new SampleWeatherServiceImpl(80,
+ null);
+ RpcServer server = factory.createServer(serverBuilder, port, service,
+ executorService);
+ WeatherService stub = factory.<WeatherService> createStub(
+ clientBuilder, WeatherService.newStub(null), executorService);
+
+ RpcControllerWithOnFailureCallback controller = (RpcControllerWithOnFailureCallback) factory
+ .createController();
+
+ final CountDownLatch l = new CountDownLatch(1);
+ final AtomicInteger result = new AtomicInteger();
+ GetWeatherForecastRequest request = GetWeatherForecastRequest
+ .newBuilder().setZip("80301").build();
+ stub.getWeatherForecast(
+ controller.onFailure(new RpcCallback<Throwable>() {
+
+ @Override
+ public void run(Throwable e) {
+ }
+ }), request, new RpcCallback<GetWeatherForecastResponse>() {
+
+ @Override
+ public void run(GetWeatherForecastResponse resp) {
+ result.set(resp.getTemp());
+ l.countDown();
+ }
+ });
+
+ l.await(CLIENT_TIMEOUT_SECONDS + 2, TimeUnit.SECONDS);
+ server.close(new Duration(TimeUnit.SECONDS.toNanos(1)));
+
+ assertEquals(service.getTemperature(), result.get());
+
+
+
+
@@ -1,4 +1,4 @@
-package com.tendril.finagle.protobuf.rpc
+package com.twitter.finagle.protobuf.rpc
import com.google.protobuf.RpcCallback
import com.google.protobuf.RpcController
import com.twitter.finagle.TimeoutException
@@ -46,4 +46,4 @@ class RpcControllerWithOnFailureCallback extends RpcController {
case _ => e
}
}
-}
+}
@@ -1,4 +1,4 @@
-package com.tendril.finagle.protobuf.rpc
+package com.twitter.finagle.protobuf.rpc
import com.google.protobuf.Message
import com.google.protobuf.RpcChannel
@@ -16,4 +16,4 @@ trait RpcFactory {
def createStub[T <: Service](cb: ClientBuilder[(String, Message), (String, Message), Any, Any, Any], service: { def newStub(c: RpcChannel): T }, executorService: ExecutorService): T
def createController(): RpcController
-}
+}
@@ -1,8 +1,8 @@
-package com.tendril.finagle.protobuf.rpc
+package com.twitter.finagle.protobuf.rpc
import com.twitter.util.Duration
trait RpcServer {
def close(d: Duration): Unit;
-}
+}
@@ -1,4 +1,4 @@
-package com.tendril.finagle.protobuf.rpc
+package com.twitter.finagle.protobuf.rpc
import java.util.List
@@ -1,4 +1,4 @@
-package com.tendril.finagle.protobuf.rpc.channel
+package com.twitter.finagle.protobuf.rpc.channel
import org.jboss.netty.buffer.ChannelBuffer
import org.jboss.netty.buffer.ChannelBufferInputStream
@@ -20,4 +20,4 @@ class ClientSideDecoder(val repo: MethodLookup, val service: Service) extends Fr
val m = service.getDescriptorForType().findMethodByName(methodName)
service.getResponsePrototype(m)
}
-}
+}
@@ -1,4 +1,4 @@
-package com.tendril.finagle.protobuf.rpc.channel
+package com.twitter.finagle.protobuf.rpc.channel
/**
* Lookup repository that maps method names to 4 bytes.
@@ -10,4 +10,4 @@ trait MethodLookup {
def lookup(code: Int) : String
-}
+}
@@ -1,4 +1,4 @@
-package com.tendril.finagle.protobuf.rpc.channel
+package com.twitter.finagle.protobuf.rpc.channel
import org.jboss.netty.channel.ChannelPipelineFactory
import org.jboss.netty.channel.Channels
@@ -1,4 +1,4 @@
-package com.tendril.finagle.protobuf.rpc.channel
+package com.twitter.finagle.protobuf.rpc.channel
import org.jboss.netty.buffer.ChannelBuffer
import org.jboss.netty.buffer.ChannelBufferInputStream
@@ -52,4 +52,4 @@ trait ProtobufDecoder {
def getPrototype(methodName: String): Message;
-}
+}
@@ -1,4 +1,4 @@
-package com.tendril.finagle.protobuf.rpc.channel
+package com.twitter.finagle.protobuf.rpc.channel
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder
import org.jboss.netty.channel.ChannelHandlerContext
@@ -45,4 +45,4 @@ class CustomProtobufEncoder(val repo: MethodLookup) extends OneToOneEncoder {
ChannelBuffers.wrappedBuffer(message))
}
-}
+}
@@ -1,4 +1,4 @@
-package com.tendril.finagle.protobuf.rpc.channel
+package com.twitter.finagle.protobuf.rpc.channel
import org.jboss.netty.buffer.ChannelBuffer
import org.jboss.netty.channel.Channel
@@ -19,4 +19,4 @@ class ServerSideDecoder(val repo: MethodLookup, val service: Service) extends Fr
val m = service.getDescriptorForType().findMethodByName(methodName)
service.getRequestPrototype(m)
}
-}
+}
@@ -1,6 +1,6 @@
-package com.tendril.finagle.protobuf.rpc.channel
+package com.twitter.finagle.protobuf.rpc.channel
-import com.tendril.finagle.protobuf.rpc.Util
+import com.twitter.finagle.protobuf.rpc.Util
import com.google.protobuf.Service
import scala.collection.JavaConversions._
import scala.collection.mutable._
@@ -1,4 +1,4 @@
-package com.tendril.finagle.protobuf.rpc.impl
+package com.twitter.finagle.protobuf.rpc.impl
import java.net.InetSocketAddress
import com.google.protobuf.Descriptors.MethodDescriptor
@@ -12,8 +12,8 @@ import com.twitter.util.Duration
import com.twitter.util.FuturePool
import com.twitter.finagle.builder.ClientBuilder
import java.util.concurrent.ExecutorService
-import com.tendril.finagle.protobuf.rpc.RpcControllerWithOnFailureCallback
-import com.tendril.finagle.protobuf.rpc.channel.ProtoBufCodec
+import com.twitter.finagle.protobuf.rpc.RpcControllerWithOnFailureCallback
+import com.twitter.finagle.protobuf.rpc.channel.ProtoBufCodec
class RpcChannelImpl(cb: ClientBuilder[(String, Message), (String, Message), Any, Any, Any], s: Service, executorService: ExecutorService) extends RpcChannel {
@@ -1,9 +1,9 @@
-package com.tendril.finagle.protobuf.rpc.impl
+package com.twitter.finagle.protobuf.rpc.impl
-import com.tendril.finagle.protobuf.rpc.RpcFactory
-import com.tendril.finagle.protobuf.rpc.RpcServer
-import com.tendril.finagle.protobuf.rpc.RpcControllerWithOnFailureCallback
-import com.tendril.finagle.protobuf.rpc.RpcServer
+import com.twitter.finagle.protobuf.rpc.RpcFactory
+import com.twitter.finagle.protobuf.rpc.RpcServer
+import com.twitter.finagle.protobuf.rpc.RpcControllerWithOnFailureCallback
+import com.twitter.finagle.protobuf.rpc.RpcServer
import com.twitter.finagle.builder.ServerBuilder
import com.twitter.finagle.builder.ClientBuilder
@@ -25,4 +25,4 @@ class RpcFactoryImpl extends RpcFactory {
}
def createController(): RpcController = { new RpcControllerWithOnFailureCallback() }
-}
+}
@@ -1,7 +1,7 @@
-package com.tendril.finagle.protobuf.rpc.impl
+package com.twitter.finagle.protobuf.rpc.impl
-import com.tendril.finagle.protobuf.rpc.channel.ProtoBufCodec
-import com.tendril.finagle.protobuf.rpc.RpcServer
+import com.twitter.finagle.protobuf.rpc.channel.ProtoBufCodec
+import com.twitter.finagle.protobuf.rpc.RpcServer
import com.twitter.util.Future
import com.twitter.util.Duration
@@ -1,4 +1,4 @@
-package com.tendril.finagle.protobuf.rpc;
+package com.twitter.finagle.protobuf.rpc;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -17,15 +17,15 @@
import com.google.common.base.Throwables;
import com.google.protobuf.RpcCallback;
import com.google.protobuf.RpcController;
-import com.tendril.platform.services.rpc.RpcControllerWithOnFailureCallback;
-import com.tendril.platform.services.rpc.RpcFactory;
-import com.tendril.platform.services.rpc.RpcServer;
-import com.tendril.platform.services.rpc.impl.RpcFactoryImpl;
-import com.tendril.platform.services.sample.SampleServiceProtos.GetHistoricWeatherRequest;
-import com.tendril.platform.services.sample.SampleServiceProtos.GetHistoricWeatherResponse;
-import com.tendril.platform.services.sample.SampleServiceProtos.GetWeatherForecastRequest;
-import com.tendril.platform.services.sample.SampleServiceProtos.GetWeatherForecastResponse;
-import com.tendril.platform.services.sample.SampleServiceProtos.WeatherService;
+import com.twitter.platform.services.rpc.RpcControllerWithOnFailureCallback;
+import com.twitter.platform.services.rpc.RpcFactory;
+import com.twitter.platform.services.rpc.RpcServer;
+import com.twitter.platform.services.rpc.impl.RpcFactoryImpl;
+import com.twitter.platform.services.sample.SampleServiceProtos.GetHistoricWeatherRequest;
+import com.twitter.platform.services.sample.SampleServiceProtos.GetHistoricWeatherResponse;
+import com.twitter.platform.services.sample.SampleServiceProtos.GetWeatherForecastRequest;
+import com.twitter.platform.services.sample.SampleServiceProtos.GetWeatherForecastResponse;
+import com.twitter.platform.services.sample.SampleServiceProtos.WeatherService;
import com.twitter.finagle.builder.ClientBuilder;
import com.twitter.finagle.builder.ServerBuilder;
import com.twitter.util.Duration;
Oops, something went wrong.

0 comments on commit 9fa8e18

Please sign in to comment.