├── GROUPS
├── finagle-memcached
├── README
├── GROUPS
├── OWNERS
├── src
│ ├── test
│ │ ├── resources
│ │ │ └── BUILD
│ │ └── java
│ │ │ ├── BUILD
│ │ │ └── com
│ │ │ └── twitter
│ │ │ └── finagle
│ │ │ └── MemcachedCompilationTest.java
│ └── main
│ │ ├── scala
│ │ └── com
│ │ │ └── twitter
│ │ │ └── finagle
│ │ │ └── memcached
│ │ │ ├── protocol
│ │ │ ├── text
│ │ │ │ └── Decodings.scala
│ │ │ └── Error.scala
│ │ │ └── util
│ │ │ └── AtomicMap.scala
│ │ └── java
│ │ ├── BUILD
│ │ └── com
│ │ └── twitter
│ │ └── finagle
│ │ └── memcached
│ │ └── java
│ │ └── ResultWithCAS.java
└── BUILD
├── finagle-spdy
├── GROUPS
├── OWNERS
├── BUILD
└── src
│ ├── test
│ └── scala
│ │ └── BUILD
│ └── main
│ └── scala
│ ├── BUILD
│ └── com
│ └── twitter
│ └── finagle
│ └── spdy
│ └── SpdyRawFrameCodec.scala
├── finagle-http
├── GROUPS
├── OWNERS
├── src
│ ├── test
│ │ ├── java
│ │ │ ├── BUILD
│ │ │ └── com
│ │ │ │ └── twitter
│ │ │ │ └── finagle
│ │ │ │ └── http
│ │ │ │ ├── RequestCompilationTest.java
│ │ │ │ ├── HttpTracingCompilationTest.java
│ │ │ │ ├── javaapi
│ │ │ │ └── DtabFilterTest.java
│ │ │ │ └── HttpMuxerCompilationTest.java
│ │ └── scala
│ │ │ ├── com
│ │ │ └── twitter
│ │ │ │ └── finagle
│ │ │ │ └── http
│ │ │ │ ├── RequestProxyTest.scala
│ │ │ │ ├── ProxyCredentialsTest.scala
│ │ │ │ └── EmptyParamMapTest.scala
│ │ │ └── BUILD
│ └── main
│ │ ├── java
│ │ ├── BUILD
│ │ └── com
│ │ │ └── twitter
│ │ │ └── finagle
│ │ │ └── http
│ │ │ └── Versions.java
│ │ └── scala
│ │ ├── com
│ │ └── twitter
│ │ │ └── finagle
│ │ │ └── http
│ │ │ ├── codec
│ │ │ ├── OneHundredContinueResponse.scala
│ │ │ └── AnnotateCipher.scala
│ │ │ ├── service
│ │ │ ├── NullService.scala
│ │ │ └── NotFoundService.scala
│ │ │ ├── Version.scala
│ │ │ ├── filter
│ │ │ └── AddResponseHeadersFilter.scala
│ │ │ ├── exp
│ │ │ └── IdentityStreamTransport.scala
│ │ │ ├── ProxyCredentials.scala
│ │ │ ├── ResponseProxy.scala
│ │ │ ├── RequestProxy.scala
│ │ │ └── MediaType.scala
│ │ └── BUILD
└── BUILD
├── finagle-core
├── GROUPS
├── OWNERS
├── src
│ ├── main
│ │ ├── scala
│ │ │ ├── com
│ │ │ │ ├── twitter
│ │ │ │ │ └── finagle
│ │ │ │ │ │ ├── naming
│ │ │ │ │ │ ├── OWNERS
│ │ │ │ │ │ └── DefaultInterpreter.scala
│ │ │ │ │ │ ├── netty3
│ │ │ │ │ │ ├── OWNERS
│ │ │ │ │ │ ├── WorkerPool.scala
│ │ │ │ │ │ ├── ChannelFuture.scala
│ │ │ │ │ │ ├── param
│ │ │ │ │ │ │ └── Params.scala
│ │ │ │ │ │ └── channel
│ │ │ │ │ │ │ └── IdleChannelHandler.scala
│ │ │ │ │ │ ├── server
│ │ │ │ │ │ ├── OWNERS
│ │ │ │ │ │ └── package.scala
│ │ │ │ │ │ ├── loadbalancer
│ │ │ │ │ │ ├── OWNERS
│ │ │ │ │ │ └── NodeT.scala
│ │ │ │ │ │ ├── client
│ │ │ │ │ │ ├── OWNERS
│ │ │ │ │ │ └── package.scala
│ │ │ │ │ │ ├── util
│ │ │ │ │ │ ├── package.scala
│ │ │ │ │ │ ├── OnReady.scala
│ │ │ │ │ │ ├── Showable.scala
│ │ │ │ │ │ ├── NetUtil.scala
│ │ │ │ │ │ └── LoadService.scala
│ │ │ │ │ │ ├── ssl
│ │ │ │ │ │ ├── Engine.scala
│ │ │ │ │ │ └── Util.scala
│ │ │ │ │ │ ├── param
│ │ │ │ │ │ ├── package.scala
│ │ │ │ │ │ ├── WithClientAdmissionControl.scala
│ │ │ │ │ │ ├── WithServerAdmissionControl.scala
│ │ │ │ │ │ ├── WithSessionPool.scala
│ │ │ │ │ │ ├── WithClientTransport.scala
│ │ │ │ │ │ ├── WithServerTransport.scala
│ │ │ │ │ │ ├── WithSessionQualifier.scala
│ │ │ │ │ │ ├── WithConcurrentLoadBalancer.scala
│ │ │ │ │ │ ├── ClientAdmissionControlParams.scala
│ │ │ │ │ │ └── WithSession.scala
│ │ │ │ │ │ ├── exp
│ │ │ │ │ │ └── package.scala
│ │ │ │ │ │ ├── socks
│ │ │ │ │ │ └── AuthenticationSetting.scala
│ │ │ │ │ │ ├── codec
│ │ │ │ │ │ └── package.scala
│ │ │ │ │ │ ├── builder
│ │ │ │ │ │ └── Common.scala
│ │ │ │ │ │ ├── context
│ │ │ │ │ │ └── LocalContext.scala
│ │ │ │ │ │ ├── stats
│ │ │ │ │ │ ├── HostStatsReceiver.scala
│ │ │ │ │ │ └── CancelledCategorizer.scala
│ │ │ │ │ │ ├── tracing
│ │ │ │ │ │ ├── TracingLogHandler.scala
│ │ │ │ │ │ └── ClientRequestTracingFilter.scala
│ │ │ │ │ │ ├── service
│ │ │ │ │ │ ├── ResponseClassificationSyntheticException.scala
│ │ │ │ │ │ ├── FailingFactory.scala
│ │ │ │ │ │ ├── ReqRep.scala
│ │ │ │ │ │ ├── ServiceFactoryRef.scala
│ │ │ │ │ │ ├── ConstantService.scala
│ │ │ │ │ │ ├── OptionallyServableFilter.scala
│ │ │ │ │ │ └── RefcountedService.scala
│ │ │ │ │ │ └── factory
│ │ │ │ │ │ └── RefcountedFactory.scala
│ │ │ │ └── package.scala
│ │ │ ├── package.scala
│ │ │ └── BUILD
│ │ └── java
│ │ │ ├── BUILD
│ │ │ └── com
│ │ │ └── twitter
│ │ │ └── finagle
│ │ │ └── service
│ │ │ └── ResponseClasses.java
│ └── test
│ │ ├── scala
│ │ ├── com
│ │ │ └── twitter
│ │ │ │ └── finagle
│ │ │ │ ├── naming
│ │ │ │ └── OWNERS
│ │ │ │ ├── PathTest.scala
│ │ │ │ ├── service
│ │ │ │ ├── ResponseClassTest.scala
│ │ │ │ └── ServiceTest.scala
│ │ │ │ ├── InitTest.scala
│ │ │ │ ├── Echo.scala
│ │ │ │ ├── netty3
│ │ │ │ └── NumWorkersTest.scala
│ │ │ │ ├── socks
│ │ │ │ └── SocksProxyFlagsTest.scala
│ │ │ │ ├── builder
│ │ │ │ └── ClusterInt.scala
│ │ │ │ ├── integration
│ │ │ │ └── DynamicCluster.scala
│ │ │ │ └── tracing
│ │ │ │ └── TracingLogHandlerTest.scala
│ │ └── BUILD
│ │ ├── resources
│ │ ├── META-INF
│ │ │ └── services
│ │ │ │ ├── com.twitter.finagle.Announcer
│ │ │ │ └── com.twitter.finagle.Resolver
│ │ └── BUILD
│ │ └── java
│ │ ├── BUILD
│ │ └── com
│ │ └── twitter
│ │ └── finagle
│ │ ├── ResolversCompilationTest.java
│ │ ├── MyTestCodec.java
│ │ ├── service
│ │ └── RetryPolicyCompilationTest.java
│ │ ├── ServiceCompilationTest.java
│ │ ├── DtabCompilationTest.java
│ │ ├── NamerCompilationTest.java
│ │ ├── client
│ │ └── StatsScopingCompilationTest.java
│ │ ├── AddressCompilationTest.java
│ │ └── stats
│ │ └── JavaStatsReceiverTest.java
└── BUILD
├── finagle-netty4-http
├── GROUPS
├── OWNERS
├── BUILD
└── src
│ ├── test
│ └── scala
│ │ └── BUILD
│ └── main
│ └── scala
│ ├── BUILD
│ └── com
│ └── twitter
│ └── finagle
│ └── netty4
│ └── http
│ └── TextualContentCompressor.scala
├── finagle-redis
├── GROUPS
├── OWNERS
├── src
│ ├── main
│ │ └── scala
│ │ │ ├── com
│ │ │ └── twitter
│ │ │ │ └── finagle
│ │ │ │ └── redis
│ │ │ │ └── Exceptions.scala
│ │ │ └── BUILD
│ └── test
│ │ ├── java
│ │ ├── BUILD
│ │ └── com
│ │ │ └── twitter
│ │ │ └── finagle
│ │ │ ├── ClientCompilationTest.java
│ │ │ └── redis
│ │ │ └── TestCodec.java
│ │ └── scala
│ │ ├── BUILD
│ │ └── com
│ │ └── twitter
│ │ └── finagle
│ │ └── redis
│ │ ├── Tags.scala
│ │ └── commands
│ │ ├── server
│ │ ├── ServerCodecSuite.scala
│ │ └── ServerClientServerIntegrationSuite.scala
│ │ └── list
│ │ └── ListCodecSuite.scala
└── BUILD
├── finagle-kestrel
├── GROUPS
├── src
│ ├── main
│ │ ├── thrift
│ │ │ └── BUILD
│ │ ├── java
│ │ │ └── BUILD
│ │ └── scala
│ │ │ ├── com
│ │ │ └── twitter
│ │ │ │ └── finagle
│ │ │ │ └── kestrel
│ │ │ │ └── protocol
│ │ │ │ └── Response.scala
│ │ │ └── BUILD
│ └── test
│ │ ├── java
│ │ └── BUILD
│ │ └── scala
│ │ └── BUILD
└── BUILD
├── project
├── build.properties
├── unidoc.sbt
├── build.sbt
└── plugins.sbt
├── finagle-cacheresolver
├── GROUPS
├── OWNERS
├── src
│ └── main
│ │ ├── resources
│ │ ├── BUILD
│ │ └── META-INF
│ │ │ └── services
│ │ │ └── com.twitter.finagle.Resolver
│ │ ├── java
│ │ └── BUILD
│ │ └── scala
│ │ └── BUILD
├── BUILD
└── README
├── finagle-mysql
├── OWNERS
├── src
│ ├── test
│ │ ├── resources
│ │ │ ├── drop-schema.sql
│ │ │ ├── BUILD
│ │ │ ├── create-schema.sql
│ │ │ └── data.sql
│ │ ├── java
│ │ │ ├── BUILD
│ │ │ └── com
│ │ │ │ └── twitter
│ │ │ │ └── finagle
│ │ │ │ └── mysql
│ │ │ │ ├── ParameterCompilationTest.java
│ │ │ │ └── ClientCompilationTest.java
│ │ └── scala
│ │ │ ├── BUILD
│ │ │ └── com
│ │ │ └── twitter
│ │ │ └── finagle
│ │ │ └── mysql
│ │ │ ├── unit
│ │ │ ├── transport
│ │ │ │ └── PacketTest.scala
│ │ │ └── MockService.scala
│ │ │ └── ParameterTest.scala
│ └── main
│ │ └── scala
│ │ ├── BUILD
│ │ └── com
│ │ └── twitter
│ │ └── finagle
│ │ └── mysql
│ │ └── PreparedStatement.scala
├── BUILD
└── README.md
├── finagle-serversets
├── GROUPS
├── OWNERS
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── META-INF
│ │ │ │ └── services
│ │ │ │ │ ├── com.twitter.finagle.Announcer
│ │ │ │ │ ├── com.twitter.finagle.serverset2.Identity
│ │ │ │ │ ├── com.twitter.finagle.serverset2.client.ClientFactory
│ │ │ │ │ └── com.twitter.finagle.Resolver
│ │ │ └── BUILD
│ │ └── scala
│ │ │ ├── com
│ │ │ └── twitter
│ │ │ │ └── finagle
│ │ │ │ └── serverset2
│ │ │ │ └── client
│ │ │ │ ├── Watched.scala
│ │ │ │ ├── apache
│ │ │ │ └── package.scala
│ │ │ │ └── EventDeliveryThread.scala
│ │ │ └── BUILD
│ └── test
│ │ ├── resources
│ │ ├── META-INF
│ │ │ └── services
│ │ │ │ └── com.twitter.finagle.serverset2.Identity
│ │ └── BUILD
│ │ └── scala
│ │ └── com
│ │ └── twitter
│ │ └── finagle
│ │ └── serverset2
│ │ └── client
│ │ └── ZooKeeperClientTest.scala
└── BUILD
├── OWNERS
├── finagle-thrift
├── src
│ ├── main
│ │ ├── ruby
│ │ │ ├── .gitignore
│ │ │ ├── lib
│ │ │ │ └── finagle-thrift
│ │ │ │ │ ├── version.rb
│ │ │ │ │ ├── thrift_client.rb
│ │ │ │ │ └── thrift
│ │ │ │ │ └── tracing_constants.rb
│ │ │ ├── Gemfile
│ │ │ ├── test
│ │ │ │ └── test_helper.rb
│ │ │ └── Rakefile
│ │ ├── resources
│ │ │ └── BUILD
│ │ ├── thrift
│ │ │ └── BUILD
│ │ ├── java
│ │ │ ├── BUILD
│ │ │ └── com
│ │ │ │ └── twitter
│ │ │ │ └── finagle
│ │ │ │ └── thrift
│ │ │ │ └── ThriftClientRequest.java
│ │ └── scala
│ │ │ ├── com
│ │ │ └── twitter
│ │ │ │ └── finagle
│ │ │ │ └── thrift
│ │ │ │ └── ThriftTracing.scala
│ │ │ └── BUILD
│ └── test
│ │ ├── resources
│ │ ├── BUILD
│ │ └── README.md
│ │ ├── thrift
│ │ ├── BUILD
│ │ └── echo.thrift
│ │ ├── java
│ │ ├── BUILD
│ │ └── com
│ │ │ └── twitter
│ │ │ └── finagle
│ │ │ └── thrift
│ │ │ └── service
│ │ │ └── ThriftResponseClassifierCompilationTest.java
│ │ └── scala
│ │ └── BUILD
└── BUILD
├── finagle-zipkin
├── OWNERS
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── BUILD
│ │ │ └── META-INF
│ │ │ │ └── services
│ │ │ │ └── com.twitter.finagle.tracing.Tracer
│ │ ├── thrift
│ │ │ └── BUILD
│ │ └── scala
│ │ │ ├── com
│ │ │ └── twitter
│ │ │ │ └── finagle
│ │ │ │ └── zipkin
│ │ │ │ └── Flags.scala
│ │ │ └── BUILD
│ └── test
│ │ └── scala
│ │ ├── BUILD
│ │ └── com
│ │ └── twitter
│ │ └── finagle
│ │ └── zipkin
│ │ └── thrift
│ │ └── AnnotationTest.scala
└── BUILD
├── finagle-http-compat
├── OWNERS
├── BUILD
└── src
│ ├── main
│ └── scala
│ │ └── BUILD
│ └── test
│ └── scala
│ └── BUILD
├── doc
├── Filters.png
├── ThreadEx.png
├── finagle.png
├── request-timeline.png
├── client-abstraction.png
├── FinagleRelationship.png
├── ThreadExNonBlockingServer.png
├── src
│ └── sphinx
│ │ ├── _static
│ │ ├── filter.png
│ │ ├── filter2.png
│ │ ├── finagle.png
│ │ ├── kitchensink.png
│ │ ├── kitchensink.pxm
│ │ ├── logo_medium.png
│ │ ├── logo_small.png
│ │ └── logo_original.png
│ │ ├── _themes
│ │ ├── bootstrap.zip
│ │ ├── flask
│ │ │ ├── theme.conf
│ │ │ └── relations.html
│ │ └── flask_small
│ │ │ ├── theme.conf
│ │ │ └── layout.html
│ │ ├── changelog.rst
│ │ ├── metrics
│ │ ├── RateLimiting.rst
│ │ ├── AdmissionControl.rst
│ │ ├── IdleApoptosis.rst
│ │ ├── FailFast.rst
│ │ ├── FailureDetector.rst
│ │ ├── Construction.rst
│ │ └── FailureAccrual.rst
│ │ ├── _templates
│ │ ├── sidebarlogo.html
│ │ ├── sidebarintro.html
│ │ └── searchbox.html
│ │ ├── code
│ │ ├── quickstart
│ │ │ ├── build.sbt
│ │ │ ├── Proxy.scala
│ │ │ ├── Server.scala
│ │ │ └── Client.scala
│ │ ├── protocols
│ │ │ └── build.sbt
│ │ └── client-server-anatomy
│ │ │ └── build.sbt
│ │ ├── license.rst
│ │ └── utils
│ │ └── sbt_versions.py
├── filterstack.pic
├── mux.pic
├── Makefile
├── treq.pic
├── lbstack.pic
├── README.md
├── morestack.pic
└── lbdown.pic
├── finagle-integration
├── OWNERS
├── BUILD
├── README
└── src
│ └── test
│ └── scala
│ └── BUILD
├── finagle-netty4
├── OWNERS
├── BUILD
└── src
│ ├── test
│ └── scala
│ │ └── BUILD
│ └── main
│ └── scala
│ └── BUILD
├── finagle-thriftmux
├── OWNERS
├── src
│ ├── test
│ │ ├── resources
│ │ │ └── BUILD
│ │ ├── java
│ │ │ ├── BUILD
│ │ │ └── com
│ │ │ │ └── twitter
│ │ │ │ └── finagle
│ │ │ │ └── thriftmux
│ │ │ │ └── service
│ │ │ │ └── ThriftMuxResponseClassifierCompilationTest.java
│ │ ├── thrift
│ │ │ ├── BUILD
│ │ │ └── testservice.thrift
│ │ └── scala
│ │ │ ├── BUILD
│ │ │ └── com
│ │ │ └── twitter
│ │ │ └── finagle
│ │ │ └── thriftmux
│ │ │ └── ThriftIfaceTest.scala
│ └── main
│ │ └── scala
│ │ ├── BUILD
│ │ └── com
│ │ └── twitter
│ │ └── finagle
│ │ └── ThriftMuxUtil.scala
└── BUILD
├── finagle-mux
├── OWNERS
├── src
│ ├── test
│ │ ├── resources
│ │ │ ├── BUILD
│ │ │ └── end-to-end.pcap
│ │ ├── java
│ │ │ ├── BUILD
│ │ │ └── com
│ │ │ │ └── twitter
│ │ │ │ └── finagle
│ │ │ │ ├── StackParameterCompilationTest.java
│ │ │ │ └── UseMux.java
│ │ └── scala
│ │ │ ├── BUILD
│ │ │ └── com
│ │ │ └── twitter
│ │ │ └── finagle
│ │ │ └── mux
│ │ │ ├── Latch.scala
│ │ │ ├── WindowedMaxTest.scala
│ │ │ └── lease
│ │ │ └── exp
│ │ │ └── LocalConductors.scala
│ └── main
│ │ ├── java
│ │ ├── BUILD
│ │ └── com
│ │ │ └── twitter
│ │ │ └── finagle
│ │ │ └── mux
│ │ │ └── FailureDetectors.java
│ │ └── scala
│ │ ├── BUILD
│ │ └── com
│ │ └── twitter
│ │ └── finagle
│ │ └── mux
│ │ ├── Response.scala
│ │ ├── lease
│ │ └── exp
│ │ │ ├── GenerationalRandom.scala
│ │ │ ├── GarbageCollectorAddable.scala
│ │ │ └── GarbageCollector.scala
│ │ ├── stats
│ │ └── MuxCancelledCategorizer.scala
│ │ └── Request.scala
└── BUILD
├── finagle-native
├── BUILD
└── src
│ └── test
│ ├── resources
│ ├── BUILD
│ └── setup-chain
│ │ ├── makechain.sh
│ │ └── setup_intermediate.sh
│ └── scala
│ └── BUILD
├── finagle-mdns
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── BUILD
│ │ │ └── META-INF
│ │ │ │ └── services
│ │ │ │ ├── com.twitter.finagle.Resolver
│ │ │ │ └── com.twitter.finagle.Announcer
│ │ └── scala
│ │ │ ├── BUILD
│ │ │ └── com
│ │ │ └── twitter
│ │ │ └── finagle
│ │ │ └── mdns
│ │ │ └── Local.scala
│ └── test
│ │ └── scala
│ │ └── BUILD
└── BUILD
├── finagle-stats
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── META-INF
│ │ │ │ └── services
│ │ │ │ │ ├── com.twitter.finagle.stats.StatsRegistry
│ │ │ │ │ ├── com.twitter.finagle.stats.StatsReceiver
│ │ │ │ │ ├── com.twitter.finagle.stats.HostStatsReceiver
│ │ │ │ │ └── com.twitter.finagle.http.HttpMuxHandler
│ │ │ └── BUILD
│ │ └── scala
│ │ │ └── com
│ │ │ └── twitter
│ │ │ └── finagle
│ │ │ └── stats
│ │ │ └── SampledValues.scala
│ └── test
│ │ └── scala
│ │ └── BUILD
└── BUILD
├── finagle-toggle
├── BUILD
├── src
│ ├── test
│ │ ├── resources
│ │ │ ├── BUILD
│ │ │ └── META-INF
│ │ │ │ └── services
│ │ │ │ └── com.twitter.finagle.toggle.ServiceLoadedToggleMap
│ │ └── scala
│ │ │ ├── BUILD
│ │ │ └── com
│ │ │ └── twitter
│ │ │ └── finagle
│ │ │ └── toggle
│ │ │ └── NullToggleMapTest.scala
│ └── main
│ │ └── scala
│ │ ├── BUILD
│ │ └── com
│ │ └── twitter
│ │ └── finagle
│ │ └── toggle
│ │ └── NullToggleMap.scala
└── README.md
├── finagle-ostrich4
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── BUILD
│ │ │ └── META-INF
│ │ │ │ └── services
│ │ │ │ ├── com.twitter.finagle.http.HttpMuxHandler
│ │ │ │ └── com.twitter.finagle.stats.StatsReceiver
│ │ └── scala
│ │ │ ├── BUILD
│ │ │ └── com
│ │ │ └── twitter
│ │ │ └── finagle
│ │ │ └── builder
│ │ │ └── ServerBuilderToTwitterService.scala
│ └── test
│ │ └── scala
│ │ └── BUILD
└── BUILD
├── finagle-benchmark
├── BUILD
└── src
│ └── main
│ └── scala
│ └── com
│ └── twitter
│ └── finagle
│ ├── benchmark
│ └── StdBenchAnnotations.scala
│ ├── PathBenchmark.scala
│ ├── thrift
│ └── HelloServer.scala
│ ├── util
│ ├── ConcurrentRingBufferBench.scala
│ └── InetAddressUtilBench.scala
│ └── NamerBenchmark.scala
├── finagle-commons-stats
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── BUILD
│ │ │ └── META-INF
│ │ │ │ └── services
│ │ │ │ └── com.twitter.finagle.stats.StatsReceiver
│ │ └── scala
│ │ │ └── BUILD
│ └── test
│ │ └── scala
│ │ └── BUILD
└── BUILD
├── finagle-http2
├── BUILD
└── src
│ └── main
│ ├── java
│ └── BUILD
│ └── scala
│ ├── com
│ └── twitter
│ │ └── finagle
│ │ └── http2
│ │ ├── package.scala
│ │ └── Http2Listener.scala
│ └── BUILD
├── finagle-example
├── BUILD
├── src
│ └── main
│ │ ├── thrift
│ │ ├── hello.thrift
│ │ ├── logger.thrift
│ │ └── BUILD
│ │ ├── java
│ │ ├── com
│ │ │ └── twitter
│ │ │ │ └── finagle
│ │ │ │ └── example
│ │ │ │ └── java
│ │ │ │ └── http
│ │ │ │ ├── Cat.java
│ │ │ │ ├── CatService.java
│ │ │ │ ├── CatsDB.java
│ │ │ │ └── JsonUtils.java
│ │ └── BUILD
│ │ └── scala
│ │ └── com
│ │ └── twitter
│ │ └── finagle
│ │ └── example
│ │ └── thrift
│ │ ├── ThriftClient.scala
│ │ └── ThriftServer.scala
└── README
├── finagle-benchmark-thrift
└── src
│ └── main
│ └── thrift
│ ├── hello.thrift
│ └── BUILD
├── finagle-stream
├── BUILD
└── src
│ ├── test
│ └── scala
│ │ └── BUILD
│ └── main
│ └── scala
│ ├── BUILD
│ └── com
│ └── twitter
│ └── finagle
│ └── stream
│ └── package.scala
├── finagle-exception
├── BUILD
└── src
│ ├── main
│ ├── thrift
│ │ └── BUILD
│ └── scala
│ │ └── BUILD
│ └── test
│ └── scala
│ └── BUILD
├── link-netty.sh
├── CONFIG.ini
├── .gitignore
├── finagle-exp
├── BUILD
└── src
│ ├── test
│ └── scala
│ │ └── BUILD
│ └── main
│ └── scala
│ └── BUILD
├── .github
└── PULL_REQUEST_TEMPLATE.md
└── pushsite.bash
/GROUPS:
--------------------------------------------------------------------------------
1 | csl
2 |
--------------------------------------------------------------------------------
/finagle-memcached/README:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/finagle-spdy/GROUPS:
--------------------------------------------------------------------------------
1 | csl
2 |
--------------------------------------------------------------------------------
/finagle-http/GROUPS:
--------------------------------------------------------------------------------
1 | csl
2 | api
--------------------------------------------------------------------------------
/finagle-spdy/OWNERS:
--------------------------------------------------------------------------------
1 | marius
2 |
--------------------------------------------------------------------------------
/finagle-core/GROUPS:
--------------------------------------------------------------------------------
1 | csl
2 | traffic
--------------------------------------------------------------------------------
/finagle-netty4-http/GROUPS:
--------------------------------------------------------------------------------
1 | csl
2 |
--------------------------------------------------------------------------------
/finagle-redis/GROUPS:
--------------------------------------------------------------------------------
1 | cache-team
2 | csl
--------------------------------------------------------------------------------
/finagle-kestrel/GROUPS:
--------------------------------------------------------------------------------
1 | csl
2 | ds-messaging
3 |
--------------------------------------------------------------------------------
/finagle-memcached/GROUPS:
--------------------------------------------------------------------------------
1 | cache-team
2 | csl
3 |
--------------------------------------------------------------------------------
/project/build.properties:
--------------------------------------------------------------------------------
1 | sbt.version=0.13.9
2 |
--------------------------------------------------------------------------------
/finagle-cacheresolver/GROUPS:
--------------------------------------------------------------------------------
1 | cache-team
2 | csl
3 |
--------------------------------------------------------------------------------
/finagle-mysql/OWNERS:
--------------------------------------------------------------------------------
1 | irana
2 | marius
3 | roanta
4 |
--------------------------------------------------------------------------------
/finagle-serversets/GROUPS:
--------------------------------------------------------------------------------
1 | coord-team
2 | traffic
3 |
--------------------------------------------------------------------------------
/OWNERS:
--------------------------------------------------------------------------------
1 | koliver
2 | marius
3 | mnakamura
4 | roanta
5 |
--------------------------------------------------------------------------------
/finagle-thrift/src/main/ruby/.gitignore:
--------------------------------------------------------------------------------
1 | Gemfile.lock
2 |
--------------------------------------------------------------------------------
/finagle-memcached/OWNERS:
--------------------------------------------------------------------------------
1 | koliver
2 | marius
3 | svemuri
4 | yao
5 |
--------------------------------------------------------------------------------
/finagle-zipkin/OWNERS:
--------------------------------------------------------------------------------
1 | koliver
2 | marius
3 | mnakamura
4 | roanta
5 |
--------------------------------------------------------------------------------
/finagle-http-compat/OWNERS:
--------------------------------------------------------------------------------
1 | dschobel
2 | koliver
3 | marius
4 | mnakamura
5 |
--------------------------------------------------------------------------------
/finagle-core/OWNERS:
--------------------------------------------------------------------------------
1 | dschobel
2 | koliver
3 | marius
4 | mnakamura
5 | roanta
6 |
--------------------------------------------------------------------------------
/project/unidoc.sbt:
--------------------------------------------------------------------------------
1 | addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.3.3")
2 |
3 |
--------------------------------------------------------------------------------
/doc/Filters.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/doc/Filters.png
--------------------------------------------------------------------------------
/doc/ThreadEx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/doc/ThreadEx.png
--------------------------------------------------------------------------------
/doc/finagle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/doc/finagle.png
--------------------------------------------------------------------------------
/finagle-integration/OWNERS:
--------------------------------------------------------------------------------
1 | dschobel
2 | koliver
3 | marius
4 | mnakamura
5 | roanta
6 |
--------------------------------------------------------------------------------
/finagle-mysql/src/test/resources/drop-schema.sql:
--------------------------------------------------------------------------------
1 | DROP TABLE IF EXISTS swimming_record;
--------------------------------------------------------------------------------
/finagle-redis/OWNERS:
--------------------------------------------------------------------------------
1 | edede
2 | koliver
3 | marius
4 | mnakamura
5 | mpatidar
6 | roanta
--------------------------------------------------------------------------------
/finagle-serversets/OWNERS:
--------------------------------------------------------------------------------
1 | atollenaere
2 | jdonham
3 | marius
4 | ngreen
5 | tsegal
6 |
--------------------------------------------------------------------------------
/finagle-cacheresolver/OWNERS:
--------------------------------------------------------------------------------
1 | dschobel
2 | koliver
3 | marius
4 | mnakamura
5 | svemuri
6 | yao
7 |
--------------------------------------------------------------------------------
/finagle-netty4/OWNERS:
--------------------------------------------------------------------------------
1 | dschobel
2 | koliver
3 | marius
4 | mnakamura
5 | roanta
6 | vkostyukov
7 |
--------------------------------------------------------------------------------
/finagle-thriftmux/OWNERS:
--------------------------------------------------------------------------------
1 | dschobel
2 | koliver
3 | marius
4 | mnakamura
5 | roanta
6 | ryano
7 |
--------------------------------------------------------------------------------
/doc/request-timeline.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/doc/request-timeline.png
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/naming/OWNERS:
--------------------------------------------------------------------------------
1 | atollenaere
2 | jdonham
3 | marius
4 |
--------------------------------------------------------------------------------
/finagle-core/src/test/scala/com/twitter/finagle/naming/OWNERS:
--------------------------------------------------------------------------------
1 | atollenaere
2 | jdonham
3 | marius
4 |
--------------------------------------------------------------------------------
/finagle-mux/OWNERS:
--------------------------------------------------------------------------------
1 | dschobel
2 | jdonham
3 | koliver
4 | marius
5 | mnakamura
6 | roanta
7 | ryano
8 |
--------------------------------------------------------------------------------
/finagle-netty4-http/OWNERS:
--------------------------------------------------------------------------------
1 | dschobel
2 | koliver
3 | marius
4 | mnakamura
5 | roanta
6 | vkostyukov
7 |
--------------------------------------------------------------------------------
/doc/client-abstraction.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/doc/client-abstraction.png
--------------------------------------------------------------------------------
/finagle-http/OWNERS:
--------------------------------------------------------------------------------
1 | dschobel
2 | koliver
3 | marius
4 | mnakamura
5 | roanta
6 | ryano
7 | vkostyukov
8 |
--------------------------------------------------------------------------------
/finagle-mysql/src/test/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=globs('*.sql')
3 | )
4 |
--------------------------------------------------------------------------------
/doc/FinagleRelationship.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/doc/FinagleRelationship.png
--------------------------------------------------------------------------------
/finagle-core/src/test/resources/META-INF/services/com.twitter.finagle.Announcer:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.TestAnnouncer
2 |
--------------------------------------------------------------------------------
/doc/ThreadExNonBlockingServer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/doc/ThreadExNonBlockingServer.png
--------------------------------------------------------------------------------
/doc/src/sphinx/_static/filter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/doc/src/sphinx/_static/filter.png
--------------------------------------------------------------------------------
/doc/src/sphinx/_static/filter2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/doc/src/sphinx/_static/filter2.png
--------------------------------------------------------------------------------
/doc/src/sphinx/_static/finagle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/doc/src/sphinx/_static/finagle.png
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/netty3/OWNERS:
--------------------------------------------------------------------------------
1 | dschobel
2 | koliver
3 | marius
4 | mnakamura
5 | roanta
6 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/server/OWNERS:
--------------------------------------------------------------------------------
1 | dschobel
2 | jdonham
3 | koliver
4 | marius
5 | mnakamura
6 |
--------------------------------------------------------------------------------
/finagle-thrift/src/main/ruby/lib/finagle-thrift/version.rb:
--------------------------------------------------------------------------------
1 | module FinagleThrift
2 | VERSION = "1.4.1"
3 | end
4 |
5 |
--------------------------------------------------------------------------------
/doc/src/sphinx/_themes/bootstrap.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/doc/src/sphinx/_themes/bootstrap.zip
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/loadbalancer/OWNERS:
--------------------------------------------------------------------------------
1 | jdonham
2 | koliver
3 | marius
4 | mnakamura
5 | ryano
6 |
--------------------------------------------------------------------------------
/finagle-native/BUILD:
--------------------------------------------------------------------------------
1 | target(name='tests',
2 | dependencies=[
3 | 'finagle/finagle-native/src/test/scala'
4 | ]
5 | )
6 |
--------------------------------------------------------------------------------
/finagle-thrift/src/test/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=globs('*', exclude=[globs('BUILD')])
3 | )
4 |
--------------------------------------------------------------------------------
/doc/src/sphinx/_static/kitchensink.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/doc/src/sphinx/_static/kitchensink.png
--------------------------------------------------------------------------------
/doc/src/sphinx/_static/kitchensink.pxm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/doc/src/sphinx/_static/kitchensink.pxm
--------------------------------------------------------------------------------
/doc/src/sphinx/_static/logo_medium.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/doc/src/sphinx/_static/logo_medium.png
--------------------------------------------------------------------------------
/doc/src/sphinx/_static/logo_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/doc/src/sphinx/_static/logo_small.png
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/client/OWNERS:
--------------------------------------------------------------------------------
1 | dschobel
2 | jdonham
3 | koliver
4 | marius
5 | mnakamura
6 | ryano
7 |
--------------------------------------------------------------------------------
/finagle-serversets/src/main/resources/META-INF/services/com.twitter.finagle.Announcer:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.zookeeper.ZkAnnouncer
2 |
--------------------------------------------------------------------------------
/doc/src/sphinx/_static/logo_original.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/doc/src/sphinx/_static/logo_original.png
--------------------------------------------------------------------------------
/finagle-core/src/test/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=rglobs('*', exclude=[rglobs('BUILD*', '*.pyc')])
3 | )
4 |
--------------------------------------------------------------------------------
/finagle-integration/BUILD:
--------------------------------------------------------------------------------
1 | target(name='tests',
2 | dependencies=[
3 | 'finagle/finagle-integration/src/test/scala'
4 | ]
5 | )
6 |
--------------------------------------------------------------------------------
/finagle-mdns/src/main/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=rglobs('*', exclude=[rglobs('BUILD*', '*.pyc')])
3 | )
4 |
--------------------------------------------------------------------------------
/finagle-mux/src/test/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=rglobs('*', exclude=[rglobs('BUILD*', '*.pyc')])
3 | )
4 |
--------------------------------------------------------------------------------
/finagle-stats/src/main/resources/META-INF/services/com.twitter.finagle.stats.StatsRegistry:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.stats.MetricsExporter
2 |
--------------------------------------------------------------------------------
/finagle-toggle/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-toggle',
2 | dependencies=[
3 | 'finagle/finagle-toggle/src/main/scala'
4 | ]
5 | )
6 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/package.scala:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Start with [[com.twitter.finagle]].
4 | *
5 | */
6 | package object com
7 |
--------------------------------------------------------------------------------
/finagle-memcached/src/test/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=rglobs('*', exclude=[rglobs('BUILD*', '*.pyc')])
3 | )
4 |
--------------------------------------------------------------------------------
/finagle-native/src/test/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=rglobs('*', exclude=[rglobs('BUILD*', '*.pyc')])
3 | )
4 |
--------------------------------------------------------------------------------
/finagle-ostrich4/src/main/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=rglobs('*', exclude=[rglobs('BUILD*', '*.pyc')])
3 | )
4 |
--------------------------------------------------------------------------------
/finagle-ostrich4/src/main/resources/META-INF/services/com.twitter.finagle.http.HttpMuxHandler:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.stats.OstrichExporter
2 |
--------------------------------------------------------------------------------
/finagle-serversets/src/main/resources/META-INF/services/com.twitter.finagle.serverset2.Identity:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.serverset2.UserIdentity
2 |
--------------------------------------------------------------------------------
/finagle-serversets/src/test/resources/META-INF/services/com.twitter.finagle.serverset2.Identity:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.serverset2.TestIdentity
2 |
--------------------------------------------------------------------------------
/finagle-stats/src/main/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=rglobs('*', exclude=[rglobs('BUILD*', '*.pyc')])
3 | )
4 |
--------------------------------------------------------------------------------
/finagle-stats/src/main/resources/META-INF/services/com.twitter.finagle.stats.StatsReceiver:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.stats.MetricsStatsReceiver
2 |
--------------------------------------------------------------------------------
/finagle-thrift/src/main/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=rglobs('*', exclude=[rglobs('BUILD*', '*.pyc')])
3 | )
4 |
--------------------------------------------------------------------------------
/finagle-thriftmux/src/test/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=rglobs('*', exclude=[rglobs('BUILD*', '*.pyc')])
3 | )
4 |
--------------------------------------------------------------------------------
/finagle-toggle/src/test/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=rglobs('*', exclude=[rglobs('BUILD*', '*.pyc')])
3 | )
4 |
--------------------------------------------------------------------------------
/finagle-zipkin/src/main/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=rglobs('*', exclude=[rglobs('BUILD*', '*.pyc')])
3 | )
4 |
--------------------------------------------------------------------------------
/finagle-zipkin/src/main/resources/META-INF/services/com.twitter.finagle.tracing.Tracer:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.zipkin.thrift.SamplingTracer
2 |
--------------------------------------------------------------------------------
/finagle-benchmark/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-benchmark',
2 | dependencies=[
3 | 'finagle/finagle-benchmark/src/main/scala'
4 | ]
5 | )
6 |
--------------------------------------------------------------------------------
/finagle-cacheresolver/src/main/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=rglobs('*', exclude=[rglobs('BUILD*', '*.pyc')])
3 | )
4 |
--------------------------------------------------------------------------------
/finagle-cacheresolver/src/main/resources/META-INF/services/com.twitter.finagle.Resolver:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.cacheresolver.TwitterCacheResolver
2 |
--------------------------------------------------------------------------------
/finagle-commons-stats/src/main/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=rglobs('*', exclude=[rglobs('BUILD*', '*.pyc')])
3 | )
4 |
--------------------------------------------------------------------------------
/finagle-mux/src/test/resources/end-to-end.pcap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UlricQin/finagle/develop/finagle-mux/src/test/resources/end-to-end.pcap
--------------------------------------------------------------------------------
/finagle-ostrich4/src/main/resources/META-INF/services/com.twitter.finagle.stats.StatsReceiver:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.stats.OstrichStatsReceiver
2 |
--------------------------------------------------------------------------------
/finagle-serversets/src/main/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=rglobs('*', exclude=[rglobs('BUILD*', '*.pyc')])
3 | )
4 |
--------------------------------------------------------------------------------
/finagle-serversets/src/test/resources/BUILD:
--------------------------------------------------------------------------------
1 | resources(name='resources',
2 | sources=rglobs('*', exclude=[rglobs('BUILD*', '*.pyc')])
3 | )
4 |
--------------------------------------------------------------------------------
/project/build.sbt:
--------------------------------------------------------------------------------
1 | scalacOptions ++= Seq(
2 | "-deprecation",
3 | "-unchecked",
4 | "-feature", "-Xlint",
5 | "-encoding", "utf8"
6 | )
7 |
--------------------------------------------------------------------------------
/finagle-commons-stats/src/main/resources/META-INF/services/com.twitter.finagle.stats.StatsReceiver:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.stats.CommonsStatsReceiver
2 |
--------------------------------------------------------------------------------
/finagle-integration/README:
--------------------------------------------------------------------------------
1 | The finagle-integration package is a collection of tests which apply across
2 | multiple finagle protocol implementations.
3 |
--------------------------------------------------------------------------------
/finagle-stats/src/main/resources/META-INF/services/com.twitter.finagle.stats.HostStatsReceiver:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.stats.MetricsHostStatsReceiver
2 |
--------------------------------------------------------------------------------
/finagle-thrift/src/main/ruby/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | # Specify your gem's dependencies in finagle-thrift.gemspec
4 | gemspec
5 |
6 |
--------------------------------------------------------------------------------
/doc/src/sphinx/changelog.rst:
--------------------------------------------------------------------------------
1 | Changelog
2 | =========
3 |
4 | Below is a list of changes for each Finagle release.
5 |
6 |
7 | .. include:: ../../../CHANGES
8 |
--------------------------------------------------------------------------------
/finagle-core/src/test/resources/META-INF/services/com.twitter.finagle.Resolver:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.TestResolver
2 | com.twitter.finagle.TestAsyncInetResolver
3 |
--------------------------------------------------------------------------------
/finagle-mdns/src/main/resources/META-INF/services/com.twitter.finagle.Resolver:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.mdns.LocalResolver
2 | com.twitter.finagle.mdns.MDNSResolver
3 |
--------------------------------------------------------------------------------
/finagle-mdns/src/main/resources/META-INF/services/com.twitter.finagle.Announcer:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.mdns.LocalAnnouncer
2 | com.twitter.finagle.mdns.MDNSAnnouncer
3 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/package.scala:
--------------------------------------------------------------------------------
1 | package com
2 |
3 | /**
4 | *
5 | * Start with [[com.twitter.finagle]].
6 | *
7 | */
8 | package object twitter
9 |
--------------------------------------------------------------------------------
/finagle-serversets/src/main/resources/META-INF/services/com.twitter.finagle.serverset2.client.ClientFactory:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.serverset2.client.apache.ApacheFactory
2 |
--------------------------------------------------------------------------------
/finagle-serversets/src/main/resources/META-INF/services/com.twitter.finagle.Resolver:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.zookeeper.ZkResolver
2 | com.twitter.finagle.serverset2.Zk2Resolver
3 |
--------------------------------------------------------------------------------
/finagle-http2/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-http2',
2 | dependencies=[
3 | 'finagle/finagle-http2/src/main/scala',
4 | 'finagle/finagle-http2/src/main/java',
5 | ]
6 | )
7 |
--------------------------------------------------------------------------------
/doc/src/sphinx/metrics/RateLimiting.rst:
--------------------------------------------------------------------------------
1 | RateLimitingFilter
2 | <<<<<<<<<<<<<<<<<<
3 |
4 | **refused**
5 | A counter of the number of refused connections by the rate limiting filter.
6 |
--------------------------------------------------------------------------------
/finagle-stats/src/main/resources/META-INF/services/com.twitter.finagle.http.HttpMuxHandler:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.stats.MetricsExporter
2 | com.twitter.finagle.stats.HostMetricsExporter
3 |
--------------------------------------------------------------------------------
/finagle-example/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-example',
2 | dependencies=[
3 | 'finagle/finagle-example/src/main/java',
4 | 'finagle/finagle-example/src/main/scala',
5 | ]
6 | )
7 |
--------------------------------------------------------------------------------
/doc/src/sphinx/_templates/sidebarlogo.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/doc/src/sphinx/code/quickstart/build.sbt:
--------------------------------------------------------------------------------
1 | name := "quickstart"
2 |
3 | version := "1.0"
4 |
5 | scalaVersion := "2.11.8"
6 |
7 | libraryDependencies += "com.twitter" %% "finagle-http" % "6.35.0"
8 |
--------------------------------------------------------------------------------
/finagle-cacheresolver/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-cacheresolver',
2 | dependencies=[
3 | 'finagle/finagle-cacheresolver/src/main/java',
4 | 'finagle/finagle-cacheresolver/src/main/scala'
5 | ]
6 | )
7 |
--------------------------------------------------------------------------------
/finagle-example/src/main/thrift/hello.thrift:
--------------------------------------------------------------------------------
1 | namespace java com.twitter.finagle.example.thriftjava
2 | #@namespace scala com.twitter.finagle.example.thriftscala
3 |
4 | service Hello {
5 | string hi();
6 | }
7 |
--------------------------------------------------------------------------------
/finagle-http/src/test/java/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='java',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | 'finagle/finagle-http'
5 | ],
6 | fatal_warnings=False,
7 | sources=rglobs('*.java')
8 | )
9 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/util/package.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle
2 |
3 | package object util {
4 | val DefaultLogger = java.util.logging.Logger.getLogger("com.twitter.finagle")
5 | }
6 |
--------------------------------------------------------------------------------
/doc/src/sphinx/code/protocols/build.sbt:
--------------------------------------------------------------------------------
1 | name := "protocols"
2 |
3 | version := "1.0"
4 |
5 | scalaVersion := "2.11.8"
6 |
7 | libraryDependencies ++= Seq(
8 | "com.twitter" %% "finagle-mysql" % "6.35.0"
9 | )
10 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/server/package.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle
2 |
3 | package object server {
4 | type Transformer[Req, Rep] = ServiceFactory[Req, Rep] => ServiceFactory[Req, Rep]
5 | }
6 |
--------------------------------------------------------------------------------
/finagle-benchmark-thrift/src/main/thrift/hello.thrift:
--------------------------------------------------------------------------------
1 | namespace java com.twitter.finagle.benchmark.thriftjava
2 | #@namespace scala com.twitter.finagle.benchmark.thriftscala
3 |
4 | service Hello {
5 | string echo(1: string body);
6 | }
7 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/ssl/Engine.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.ssl
2 |
3 | import javax.net.ssl.SSLEngine
4 |
5 | case class Engine(self: SSLEngine, handlesRenegotiation: Boolean = false, certId: String = "")
--------------------------------------------------------------------------------
/finagle-thrift/src/main/thrift/BUILD:
--------------------------------------------------------------------------------
1 | java_thrift_library(name='thrift',
2 | provides = artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-thrift-thrift',
5 | repo = artifactory,
6 | ),
7 | sources=rglobs('*.thrift')
8 | )
9 |
--------------------------------------------------------------------------------
/doc/src/sphinx/_themes/flask/theme.conf:
--------------------------------------------------------------------------------
1 | [theme]
2 | inherit = basic
3 | stylesheet = flasky.css
4 | pygments_style = flask_theme_support.FlaskyStyle
5 |
6 | [options]
7 | index_logo = ''
8 | index_logo_height = 120px
9 | touch_icon =
10 |
--------------------------------------------------------------------------------
/doc/src/sphinx/code/client-server-anatomy/build.sbt:
--------------------------------------------------------------------------------
1 | name := "client-server-anatomy"
2 |
3 | version := "1.0"
4 |
5 | scalaVersion := "2.11.8"
6 |
7 | libraryDependencies ++= Seq(
8 | "com.twitter" %% "finagle-core" % "6.35.0"
9 | )
10 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/param/package.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle
2 |
3 | /**
4 | * Defines common [[com.twitter.finagle.Stack.Param]]'s shared between
5 | * finagle clients and servers.
6 | */
7 | package object param
8 |
--------------------------------------------------------------------------------
/finagle-mdns/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-mdns',
2 | dependencies=[
3 | 'finagle/finagle-mdns/src/main/scala'
4 | ]
5 | )
6 |
7 | target(name='tests',
8 | dependencies=[
9 | 'finagle/finagle-mdns/src/test/scala'
10 | ]
11 | )
12 |
--------------------------------------------------------------------------------
/finagle-mux/src/test/java/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='java',
2 | dependencies=[
3 | '3rdparty/jvm/io/netty',
4 | 'finagle/finagle-mux',
5 | 'util/util-core',
6 | ],
7 | fatal_warnings=False,
8 | sources=rglobs('*.java')
9 | )
10 |
--------------------------------------------------------------------------------
/finagle-redis/src/main/scala/com/twitter/finagle/redis/Exceptions.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.redis
2 |
3 | case class ServerError(message: String) extends Exception(message)
4 | case class ClientError(message: String) extends Exception(message)
5 |
--------------------------------------------------------------------------------
/finagle-serversets/src/main/scala/com/twitter/finagle/serverset2/client/Watched.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.serverset2.client
2 |
3 | import com.twitter.util.Var
4 |
5 | private[serverset2] case class Watched[+T](value: T, state: Var[WatchState])
6 |
--------------------------------------------------------------------------------
/finagle-spdy/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-spdy',
2 | dependencies=[
3 | 'finagle/finagle-spdy/src/main/scala'
4 | ]
5 | )
6 |
7 | target(name='tests',
8 | dependencies=[
9 | 'finagle/finagle-spdy/src/test/scala'
10 | ]
11 | )
12 |
--------------------------------------------------------------------------------
/finagle-stats/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-stats',
2 | dependencies=[
3 | 'finagle/finagle-stats/src/main/scala'
4 | ]
5 | )
6 |
7 | target(name='tests',
8 | dependencies=[
9 | 'finagle/finagle-stats/src/test/scala'
10 | ]
11 | )
12 |
--------------------------------------------------------------------------------
/doc/filterstack.pic:
--------------------------------------------------------------------------------
1 | .sp
2 | .PS
3 | maxpswid=100
4 | maxpsht=100
5 | boxwid=4.3
6 | .ps +10
7 |
8 | down
9 | box "FactoryToService: \fBService[Req, Rep]\fP"
10 | arrow <-
11 | box "RetryFilter"
12 | arrow <-
13 | box "GlobalTimeoutFilter"
14 | .PE
15 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/exp/package.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle
2 |
3 | /**
4 | * Package exp contains experimental code. This can be removed or
5 | * stabilized (moved elsewhere) at any time.
6 | */
7 | package object exp
8 |
--------------------------------------------------------------------------------
/finagle-core/src/test/java/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='java',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/io/netty',
5 | 'finagle/finagle-core',
6 | 'util/util-core',
7 | ],
8 | sources=rglobs('*.java'),
9 | )
10 |
--------------------------------------------------------------------------------
/finagle-mysql/src/test/java/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='java',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | 'finagle/finagle-core',
5 | 'finagle/finagle-mysql'
6 | ],
7 | fatal_warnings=False,
8 | sources=rglobs('*.java')
9 | )
10 |
--------------------------------------------------------------------------------
/finagle-netty4/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-netty4',
2 | dependencies=[
3 | 'finagle/finagle-netty4/src/main/scala'
4 | ]
5 | )
6 |
7 | target(name='tests',
8 | dependencies=[
9 | 'finagle/finagle-netty4/src/test/scala'
10 | ]
11 | )
12 |
--------------------------------------------------------------------------------
/finagle-stream/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-stream',
2 | dependencies=[
3 | 'finagle/finagle-stream/src/main/scala'
4 | ]
5 | )
6 |
7 | target(name='tests',
8 | dependencies=[
9 | 'finagle/finagle-stream/src/test/scala'
10 | ]
11 | )
12 |
--------------------------------------------------------------------------------
/finagle-zipkin/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-zipkin',
2 | dependencies=[
3 | 'finagle/finagle-zipkin/src/main/scala'
4 | ]
5 | )
6 |
7 | target(name='tests',
8 | dependencies=[
9 | 'finagle/finagle-zipkin/src/test/scala'
10 | ]
11 | )
12 |
--------------------------------------------------------------------------------
/doc/src/sphinx/metrics/AdmissionControl.rst:
--------------------------------------------------------------------------------
1 | Deadline Admission Control
2 | <<<<<<<<<<<<<<<<<<<<<<<<<<
3 |
4 | .. _deadline_admission_control_stats:
5 |
6 | **admission_control/deadline/exceeded**
7 | A counter of the number of requests whose deadline has expired.
8 |
--------------------------------------------------------------------------------
/finagle-ostrich4/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-ostrich4',
2 | dependencies=[
3 | 'finagle/finagle-ostrich4/src/main/scala'
4 | ]
5 | )
6 |
7 | target(name='tests',
8 | dependencies=[
9 | 'finagle/finagle-ostrich4/src/test/scala'
10 | ]
11 | )
12 |
--------------------------------------------------------------------------------
/finagle-toggle/src/test/resources/META-INF/services/com.twitter.finagle.toggle.ServiceLoadedToggleMap:
--------------------------------------------------------------------------------
1 | com.twitter.finagle.toggle.ServiceLoadedToggleTestA
2 | com.twitter.finagle.toggle.ServiceLoadedToggleTestB
3 | com.twitter.finagle.toggle.ServiceLoadedToggleTestBToo
4 |
--------------------------------------------------------------------------------
/doc/mux.pic:
--------------------------------------------------------------------------------
1 | .\" Shows ServiceFactory stack
2 | .sp
3 | .PS
4 | maxpswid=100
5 | maxpsht=100
6 | boxwid=1.2
7 | .ps +10
8 |
9 | box "[4]\fIsize\fP"; right; box "[1]\fItype\fP"; right; box "[3]\fItag\fP"; right; box width 2.3 "[size-8]\fImessage\fP"
10 |
11 | .PE
12 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/client/package.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle
2 |
3 | package object client {
4 | /** Transform a service factory stack. */
5 | type Transformer[Req, Rep] = ServiceFactory[Req, Rep] => ServiceFactory[Req, Rep]
6 | }
7 |
--------------------------------------------------------------------------------
/finagle-example/src/main/java/com/twitter/finagle/example/java/http/Cat.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.example.java.http;
2 |
3 | public class Cat {
4 | public String name;
5 |
6 | public Cat(String name) {
7 | this.name = name;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/finagle-exception/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-exception',
2 | dependencies=[
3 | 'finagle/finagle-exception/src/main/scala'
4 | ]
5 | )
6 |
7 | target(name='tests',
8 | dependencies=[
9 | 'finagle/finagle-exception/src/test/scala'
10 | ]
11 | )
12 |
--------------------------------------------------------------------------------
/finagle-serversets/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-serversets',
2 | dependencies=[
3 | 'finagle/finagle-serversets/src/main/scala'
4 | ]
5 | )
6 |
7 | target(name='tests',
8 | dependencies=[
9 | 'finagle/finagle-serversets/src/test/scala'
10 | ]
11 | )
12 |
--------------------------------------------------------------------------------
/doc/src/sphinx/_themes/flask_small/theme.conf:
--------------------------------------------------------------------------------
1 | [theme]
2 | inherit = basic
3 | stylesheet = flasky.css
4 | nosidebar = true
5 | pygments_style = flask_theme_support.FlaskyStyle
6 |
7 | [options]
8 | index_logo = ''
9 | index_logo_height = 120px
10 | github_fork = ''
11 |
--------------------------------------------------------------------------------
/finagle-http-compat/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-http-compat',
2 | dependencies=[
3 | 'finagle/finagle-http-compat/src/main/scala'
4 | ]
5 | )
6 |
7 | target(name='tests',
8 | dependencies=[
9 | 'finagle/finagle-http-compat/src/test/scala'
10 | ]
11 | )
12 |
--------------------------------------------------------------------------------
/finagle-netty4-http/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-netty4-http',
2 | dependencies=[
3 | 'finagle/finagle-netty4-http/src/main/scala'
4 | ]
5 | )
6 |
7 | target(name='tests',
8 | dependencies=[
9 | 'finagle/finagle-netty4-http/src/test/scala'
10 | ]
11 | )
12 |
--------------------------------------------------------------------------------
/finagle-commons-stats/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/org/scalatest',
5 | 'finagle/finagle-commons-stats'
6 | ],
7 | fatal_warnings=True,
8 | sources=rglobs('*.scala')
9 | )
10 |
--------------------------------------------------------------------------------
/finagle-native/src/test/resources/setup-chain/makechain.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # concatencate the SSL certs to make the chain
4 | # first the intermediate
5 | cat sslCA/intermediate_ca/intermediate_ca.crt > chain.cert
6 |
7 | # ... then root CA
8 | cat sslCA/cacert.pem >> chain.cert
9 |
--------------------------------------------------------------------------------
/finagle-commons-stats/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-commons-stats',
2 | dependencies=[
3 | 'finagle/finagle-commons-stats/src/main/scala'
4 | ]
5 | )
6 |
7 | target(name='tests',
8 | dependencies=[
9 | 'finagle/finagle-commons-stats/src/test/scala'
10 | ]
11 | )
12 |
--------------------------------------------------------------------------------
/finagle-kestrel/src/main/thrift/BUILD:
--------------------------------------------------------------------------------
1 | create_thrift_libraries(
2 | base_name='thrift',
3 | generate_languages=["java", "scala"],
4 | sources=rglobs('*.thrift'),
5 | provides_java_name='finagle-kestrel-thrift-java',
6 | provides_scala_name='finagle-kestrel-thrift-scala',
7 | )
8 |
--------------------------------------------------------------------------------
/finagle-spdy/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/io/netty',
5 | '3rdparty/jvm/org/scalatest',
6 | 'finagle/finagle-spdy'
7 | ],
8 | fatal_warnings=True,
9 | sources=rglobs('*.scala')
10 | )
11 |
--------------------------------------------------------------------------------
/finagle-mysql/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-mysql',
2 | dependencies=[
3 | 'finagle/finagle-mysql/src/main/scala'
4 | ]
5 | )
6 |
7 | target(name='tests',
8 | dependencies=[
9 | 'finagle/finagle-mysql/src/test/java',
10 | 'finagle/finagle-mysql/src/test/scala'
11 | ]
12 | )
13 |
--------------------------------------------------------------------------------
/finagle-redis/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-redis',
2 | dependencies=[
3 | 'finagle/finagle-redis/src/main/scala'
4 | ]
5 | )
6 |
7 | target(name='tests',
8 | dependencies=[
9 | 'finagle/finagle-redis/src/test/java',
10 | 'finagle/finagle-redis/src/test/scala'
11 | ]
12 | )
13 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/util/OnReady.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.util
2 |
3 | import com.twitter.util.Future
4 |
5 | /**
6 | * A base type for something that signals its readiness asynchronously.
7 | */
8 | trait OnReady {
9 | def onReady: Future[Unit]
10 | }
11 |
--------------------------------------------------------------------------------
/finagle-thrift/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-thrift',
2 | dependencies=[
3 | 'finagle/finagle-thrift/src/main/scala'
4 | ]
5 | )
6 |
7 | target(name='tests',
8 | dependencies=[
9 | 'finagle/finagle-thrift/src/test/java',
10 | 'finagle/finagle-thrift/src/test/scala'
11 | ]
12 | )
13 |
--------------------------------------------------------------------------------
/link-netty.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ $# -ne 1 ]; then
4 | echo 'usage: '$0' nettyjarpath' 1>&2
5 | exit 1
6 | fi
7 |
8 | for p in finagle-core finagle-test; do
9 | rm -f $p/lib_managed/compile/netty*
10 | mkdir -p $p/libs/
11 | rm -f $p/libs/netty*
12 | ln -s $1 $p/libs
13 | done
14 |
--------------------------------------------------------------------------------
/finagle-http2/src/main/java/BUILD:
--------------------------------------------------------------------------------
1 | java_library(name='java',
2 | provides = artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-http2-java',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/io/netty:netty4-http2',
9 | ],
10 | sources=rglobs('*.java'),
11 | )
12 |
--------------------------------------------------------------------------------
/finagle-redis/src/test/java/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='java',
2 | dependencies=[
3 | '3rdparty/jvm/io/netty',
4 | '3rdparty/jvm/junit',
5 | 'finagle/finagle-core',
6 | 'finagle/finagle-redis',
7 | 'util/util-core'
8 | ],
9 | fatal_warnings=False,
10 | sources=rglobs('*.java')
11 | )
12 |
--------------------------------------------------------------------------------
/CONFIG.ini:
--------------------------------------------------------------------------------
1 | ; See http://go/CONFIG.ini
2 |
3 | ; owned by Core System Libraries
4 | [jira]
5 | project: CSL
6 |
7 | [docbird]
8 | project_name = finagle
9 | project_type = library
10 | docs_dir = doc/src/sphinx
11 | contact_email = finaglers@twitter.com
12 | go_link = http://go/finagle
13 | tags = finagle,rpc
14 |
--------------------------------------------------------------------------------
/finagle-mdns/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/org/scalatest',
5 | 'finagle/finagle-core',
6 | 'finagle/finagle-mdns',
7 | 'util/util-core',
8 | ],
9 | fatal_warnings=True,
10 | sources=rglobs('*.scala')
11 | )
12 |
--------------------------------------------------------------------------------
/finagle-thriftmux/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-thriftmux',
2 | dependencies=[
3 | 'finagle/finagle-thriftmux/src/main/scala'
4 | ]
5 | )
6 |
7 | target(name='tests',
8 | dependencies=[
9 | 'finagle/finagle-thriftmux/src/test/java',
10 | 'finagle/finagle-thriftmux/src/test/scala'
11 | ]
12 | )
13 |
--------------------------------------------------------------------------------
/finagle-example/src/main/java/com/twitter/finagle/example/java/http/CatService.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.example.java.http;
2 |
3 | public final class CatService {
4 | private final static CatsDB db = new CatsDB();
5 |
6 | public static Cat find(int id) {
7 | return db.get(id);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/finagle-thrift/src/test/thrift/BUILD:
--------------------------------------------------------------------------------
1 | java_thrift_library(
2 | name='thrift-java',
3 | language='java',
4 | compiler='scrooge',
5 | rpc_style='finagle',
6 | sources=rglobs('*.thrift'),
7 | )
8 | java_thrift_library(
9 | name='thrift-scala',
10 | language='scala',
11 | sources=rglobs('*.thrift'),
12 | )
13 |
--------------------------------------------------------------------------------
/finagle-thrift/src/main/ruby/lib/finagle-thrift/thrift_client.rb:
--------------------------------------------------------------------------------
1 | module FinagleThrift
2 | module ThriftClient
3 | def handled_proxy(method_name, *args)
4 | Trace.push(Trace.id.next_id) do
5 | Trace.set_rpc_name(method_name)
6 | super(method_name, *args)
7 | end
8 | end
9 | end
10 | end
--------------------------------------------------------------------------------
/finagle-thriftmux/src/test/java/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='java',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | 'finagle/finagle-core',
5 | 'finagle/finagle-thriftmux',
6 | 'finagle/finagle-thriftmux/src/test/thrift:thrift-scala',
7 | 'util/util-core',
8 | ],
9 | sources=rglobs('*.java')
10 | )
11 |
--------------------------------------------------------------------------------
/finagle-mux/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-mux',
2 | dependencies=[
3 | 'finagle/finagle-mux/src/main/scala',
4 | 'finagle/finagle-mux/src/main/java'
5 | ]
6 | )
7 |
8 | target(name='tests',
9 | dependencies=[
10 | 'finagle/finagle-mux/src/test/java',
11 | 'finagle/finagle-mux/src/test/scala'
12 | ]
13 | )
14 |
--------------------------------------------------------------------------------
/finagle-core/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-core',
2 | dependencies=[
3 | 'finagle/finagle-core/src/main/java',
4 | 'finagle/finagle-core/src/main/scala'
5 | ]
6 | )
7 |
8 | target(name='tests',
9 | dependencies=[
10 | 'finagle/finagle-core/src/test/java',
11 | 'finagle/finagle-core/src/test/scala'
12 | ]
13 | )
14 |
--------------------------------------------------------------------------------
/finagle-http/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-http',
2 | dependencies=[
3 | 'finagle/finagle-http/src/main/scala',
4 | 'finagle/finagle-http/src/main/java'
5 | ]
6 | )
7 |
8 | target(name='tests',
9 | dependencies=[
10 | 'finagle/finagle-http/src/test/java',
11 | 'finagle/finagle-http/src/test/scala'
12 | ]
13 | )
14 |
--------------------------------------------------------------------------------
/finagle-http/src/main/java/BUILD:
--------------------------------------------------------------------------------
1 | java_library(name='java',
2 | provides = artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-http-java',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | 'finagle/finagle-http/src/main/scala'
9 | ],
10 | fatal_warnings=False,
11 | sources=rglobs('*.java'),
12 | )
13 |
--------------------------------------------------------------------------------
/finagle-kestrel/src/test/java/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='java',
2 | dependencies=[
3 | '3rdparty/jvm/org/scala-lang:scala-library',
4 | '3rdparty/jvm/junit',
5 | 'finagle/finagle-core',
6 | 'finagle/finagle-kestrel',
7 | 'util/util-core'
8 | ],
9 | fatal_warnings=False,
10 | sources=rglobs('*.java')
11 | )
12 |
--------------------------------------------------------------------------------
/finagle-benchmark-thrift/src/main/thrift/BUILD:
--------------------------------------------------------------------------------
1 | java_thrift_library(name='thrift-scala',
2 | provides = artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-benchmark',
5 | repo = artifactory,
6 | ),
7 | sources=rglobs('*.thrift'),
8 | compiler='scrooge',
9 | language='scala',
10 | rpc_style='finagle',
11 | )
12 |
--------------------------------------------------------------------------------
/doc/src/sphinx/metrics/IdleApoptosis.rst:
--------------------------------------------------------------------------------
1 | ExpiringService
2 | <<<<<<<<<<<<<<<
3 |
4 | **idle**
5 | A counter of the number of times the service has expired from staying idle
6 | for too long in between requests.
7 |
8 | **lifetime**
9 | A counter of the number of times the service has exceeded its lifetime
10 | expiration duration.
11 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/ssl/Util.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.ssl
2 |
3 | object Shell {
4 | def run(args: Array[String]) {
5 | val process = Runtime.getRuntime.exec(args)
6 | process.waitFor()
7 | require(process.exitValue == 0, "Failed to run command '%s'".format(args.mkString(" ")))
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/finagle-exception/src/main/thrift/BUILD:
--------------------------------------------------------------------------------
1 | java_thrift_library(name='thrift-scala',
2 | sources=rglobs('*.thrift'),
3 | compiler='scrooge',
4 | language='scala',
5 | rpc_style='finagle',
6 | provides=artifact(org='com.twitter',
7 | name='finagle-exception-thrift',
8 | repo = artifactory,),
9 | )
10 |
--------------------------------------------------------------------------------
/finagle-thrift/src/main/ruby/test/test_helper.rb:
--------------------------------------------------------------------------------
1 | base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
2 | lib_dir = File.join(base_dir, "lib")
3 | test_dir = File.join(base_dir, "test")
4 |
5 | $LOAD_PATH.unshift(lib_dir)
6 |
7 | require 'test/unit'
8 | require 'rubygems'
9 | require 'thrift'
10 | require 'finagle-thrift'
11 |
--------------------------------------------------------------------------------
/finagle-zipkin/src/main/thrift/BUILD:
--------------------------------------------------------------------------------
1 | java_thrift_library(name='thrift-scala',
2 | sources=rglobs('*.thrift'),
3 | compiler='scrooge',
4 | language='scala',
5 | rpc_style='finagle',
6 | provides=artifact(org='com.twitter',
7 | name='finagle-zipkin-thrift',
8 | repo = artifactory,),
9 | )
10 |
11 |
--------------------------------------------------------------------------------
/finagle-netty4/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/org/mockito:mockito-all',
5 | '3rdparty/jvm/org/scalacheck',
6 | '3rdparty/jvm/org/scalatest',
7 | 'finagle/finagle-netty4',
8 | ],
9 | fatal_warnings=True,
10 | sources=rglobs('*.scala')
11 | )
12 |
--------------------------------------------------------------------------------
/finagle-redis/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/io/netty',
5 | '3rdparty/jvm/org/scalatest',
6 | 'finagle/finagle-core',
7 | 'finagle/finagle-redis',
8 | 'util/util-core'
9 | ],
10 | fatal_warnings=True,
11 | sources=rglobs('*.scala')
12 | )
13 |
--------------------------------------------------------------------------------
/finagle-kestrel/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-kestrel',
2 | dependencies=[
3 | 'finagle/finagle-kestrel/src/main/java',
4 | 'finagle/finagle-kestrel/src/main/scala'
5 | ]
6 | )
7 |
8 | target(name='tests',
9 | dependencies=[
10 | 'finagle/finagle-kestrel/src/test/java',
11 | 'finagle/finagle-kestrel/src/test/scala'
12 | ]
13 | )
14 |
--------------------------------------------------------------------------------
/finagle-redis/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-redis',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | 'finagle/finagle-core',
9 | 'util/util-core',
10 | 'util/util-logging'
11 | ],
12 | sources=rglobs('*.scala'),
13 | )
14 |
--------------------------------------------------------------------------------
/finagle-stream/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/io/netty',
4 | '3rdparty/jvm/junit',
5 | '3rdparty/jvm/org/scalatest',
6 | 'finagle/finagle-core',
7 | 'finagle/finagle-stream',
8 | 'util/util-core'
9 | ],
10 | fatal_warnings=True,
11 | sources=rglobs('*.scala')
12 | )
13 |
--------------------------------------------------------------------------------
/finagle-thriftmux/src/test/thrift/BUILD:
--------------------------------------------------------------------------------
1 | java_thrift_library(name='thrift-scala',
2 | sources=rglobs('*.thrift'),
3 | compiler='scrooge',
4 | language='scala',
5 | rpc_style='finagle',
6 | )
7 | java_thrift_library(name='thrift-java',
8 | sources=rglobs('*.thrift'),
9 | compiler='scrooge',
10 | language='java',
11 | rpc_style='finagle',
12 | )
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | finagle-native/lib/finaglenative.jar
2 | target/
3 | dist/
4 | project/boot/
5 | project/plugins/project/
6 | project/plugins/src_managed/
7 | *.log
8 | *.tmproj
9 | lib_managed/
10 | *.swp
11 | *.iml
12 | out/
13 | .ensime
14 | *~
15 | *#
16 | .#*
17 | .ivyjars
18 | .idea
19 | .DS_Store
20 | sbt-launch-0.7.5.jar
21 | sbt-launch.jar
22 | *.pyc
23 |
--------------------------------------------------------------------------------
/finagle-netty4-http/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/org/mockito:mockito-all',
5 | '3rdparty/jvm/org/scalacheck',
6 | '3rdparty/jvm/org/scalatest',
7 | 'finagle/finagle-netty4-http'
8 | ],
9 | fatal_warnings=True,
10 | sources=rglobs('*.scala')
11 | )
12 |
--------------------------------------------------------------------------------
/finagle-stats/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/org/scalacheck',
5 | '3rdparty/jvm/org/scalatest',
6 | 'science/src/java/com/twitter/common/metrics:metrics',
7 | 'finagle/finagle-stats'
8 | ],
9 | fatal_warnings=True,
10 | sources=rglobs('*.scala')
11 | )
12 |
--------------------------------------------------------------------------------
/doc/Makefile:
--------------------------------------------------------------------------------
1 | # todo: custom pic2graph
2 |
3 | %.ps: %.pic
4 | cat $< | groff -e -p -Tps -P-pa0 > $@
5 |
6 | %.pdf: %.ps
7 | convert -trim -crop 0x0 $< $@
8 |
9 | %.png: %.ps
10 | convert -trim -crop 0x0 $< $@
11 |
12 | all: lbstack.png filterstack.png morestack.png lbdown.png
13 | clean:
14 | rm -f lbstack.png filterstack.png morestack.png lbdown.png
15 |
--------------------------------------------------------------------------------
/doc/src/sphinx/license.rst:
--------------------------------------------------------------------------------
1 | License
2 | =======
3 |
4 | Finagle is maintained by Twitter, Inc., and licenced under an
5 | Apache v2 license (see :ref:`license`)
6 |
7 | Authors
8 | -------
9 |
10 | .. include:: ../../../CONTRIBUTORS
11 |
12 | .. _license:
13 |
14 | The Apache license
15 | ------------------
16 |
17 | .. literalinclude:: ../../../LICENSE
18 |
--------------------------------------------------------------------------------
/finagle-memcached/BUILD:
--------------------------------------------------------------------------------
1 | target(name='finagle-memcached',
2 | dependencies=[
3 | 'finagle/finagle-memcached/src/main/java',
4 | 'finagle/finagle-memcached/src/main/scala'
5 | ]
6 | )
7 |
8 | target(name='tests',
9 | dependencies=[
10 | 'finagle/finagle-memcached/src/test/java',
11 | 'finagle/finagle-memcached/src/test/scala'
12 | ]
13 | )
14 |
--------------------------------------------------------------------------------
/finagle-toggle/README.md:
--------------------------------------------------------------------------------
1 | Finagle Toggle
2 | ==============
3 |
4 | This is a module designed to give Finagle, and other libraries,
5 | ["Feature Toggles"](http://martinfowler.com/articles/feature-toggles.html).
6 |
7 | *NOTE:* `finagle-toggle` is in the early stages of development
8 | and as such, APIs should be considered unstable and subject
9 | to change.
10 |
--------------------------------------------------------------------------------
/finagle-exp/BUILD:
--------------------------------------------------------------------------------
1 | target(name='benchmark',
2 | dependencies=[
3 | 'finagle/finagle-exp/src/main/scala:benchmark'
4 | ]
5 | )
6 |
7 | target(name='finagle-exp',
8 | dependencies=[
9 | 'finagle/finagle-exp/src/main/scala'
10 | ]
11 | )
12 |
13 | target(name='tests',
14 | dependencies=[
15 | 'finagle/finagle-exp/src/test/scala'
16 | ]
17 | )
18 |
--------------------------------------------------------------------------------
/finagle-thriftmux/src/test/thrift/testservice.thrift:
--------------------------------------------------------------------------------
1 | namespace java com.twitter.finagle.thriftmux.thriftjava
2 | #@namespace scala com.twitter.finagle.thriftmux.thriftscala
3 |
4 | exception InvalidQueryException {
5 | 1: i32 errorCode
6 | }
7 |
8 | service TestService {
9 | string query(1: string x) throws (
10 | 1: InvalidQueryException ex
11 | )
12 | }
13 |
--------------------------------------------------------------------------------
/finagle-example/README:
--------------------------------------------------------------------------------
1 | # How to run the examples:
2 |
3 | From the command line:
4 |
5 | % sbt "project finagle-example" run
6 |
7 | If the example requires a command line parameter, do this:
8 |
9 | % sbt "project finagle-example" "run p1 p2"
10 |
11 | If you are running a server and a client, start the server in one terminal, then start the client in another.
12 |
13 |
--------------------------------------------------------------------------------
/finagle-thrift/src/test/java/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='java',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/org/scala-lang:scala-library',
5 | '3rdparty/jvm/org/slf4j:slf4j-api',
6 | '3rdparty/jvm/org/apache/thrift:thrift-0.5.0',
7 | 'finagle/finagle-thrift',
8 | 'util/util-core',
9 | ],
10 | sources=rglobs('*.java')
11 | )
12 |
--------------------------------------------------------------------------------
/doc/src/sphinx/_templates/sidebarintro.html:
--------------------------------------------------------------------------------
1 | Finagle
2 |
3 | Finagle is a network stack for distributed systems.
4 |
5 |
6 | Useful Links
7 |
11 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/socks/AuthenticationSetting.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.socks
2 |
3 | sealed abstract class AuthenticationSetting(val typeByte: Byte)
4 | case object Unauthenticated extends AuthenticationSetting(0x00)
5 | case class UsernamePassAuthenticationSetting(username: String, password: String)
6 | extends AuthenticationSetting(0x02)
7 |
--------------------------------------------------------------------------------
/finagle-mux/src/main/java/BUILD:
--------------------------------------------------------------------------------
1 | java_library(name='java',
2 | provides = artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-mux-java',
5 | repo = artifactory,
6 | ),
7 | fatal_warnings=False,
8 | sources=rglobs('*.java'),
9 | dependencies=[
10 | '3rdparty/jvm/org/scala-lang:scala-library',
11 | 'finagle/finagle-mux/src/main/scala'
12 | ]
13 | )
14 |
--------------------------------------------------------------------------------
/finagle-mysql/src/test/resources/create-schema.sql:
--------------------------------------------------------------------------------
1 | CREATE TEMPORARY TABLE IF NOT EXISTS swimming_record (
2 | id bigint(20) NOT NULL AUTO_INCREMENT,
3 | event varchar(30) DEFAULT NULL,
4 | time float DEFAULT NULL,
5 | name varchar(40) DEFAULT NULL,
6 | nationality varchar(20) DEFAULT NULL,
7 | date date DEFAULT NULL,
8 | PRIMARY KEY (id)
9 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--------------------------------------------------------------------------------
/finagle-spdy/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-spdy',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/io/netty',
9 | 'finagle/finagle-core',
10 | 'util/util-core'
11 | ],
12 | fatal_warnings=True,
13 | sources=rglobs('*.scala'),
14 | )
15 |
--------------------------------------------------------------------------------
/finagle-exp/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/org/mockito:mockito-all',
5 | '3rdparty/jvm/org/scalatest',
6 | 'finagle/finagle-core',
7 | 'finagle/finagle-exp',
8 | 'util/util-core',
9 | 'util/util-stats',
10 | ],
11 | fatal_warnings=True,
12 | sources=rglobs('*.scala')
13 | )
14 |
--------------------------------------------------------------------------------
/finagle-http/src/main/scala/com/twitter/finagle/http/codec/OneHundredContinueResponse.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http.codec
2 |
3 | import org.jboss.netty.handler.codec.http.{DefaultHttpResponse, HttpResponseStatus, HttpVersion}
4 |
5 | private[finagle] object OneHundredContinueResponse
6 | extends DefaultHttpResponse(
7 | HttpVersion.HTTP_1_1,
8 | HttpResponseStatus.CONTINUE)
9 |
--------------------------------------------------------------------------------
/finagle-stream/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-stream',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/io/netty',
9 | 'finagle/finagle-core',
10 | 'util/util-core',
11 | ],
12 | fatal_warnings=True,
13 | sources=rglobs('*.scala'),
14 | )
15 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/codec/package.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle
2 |
3 | import com.twitter.io.Buf
4 |
5 | package object codec {
6 | type FrameEncoder[-Out] = (Out => Buf)
7 |
8 | // as can be surmised from the type, stateful implementations
9 | // of `FrameDecoder` should be expected.
10 | type FrameDecoder[+In] = (Buf => IndexedSeq[In])
11 | }
12 |
--------------------------------------------------------------------------------
/finagle-core/src/main/java/BUILD:
--------------------------------------------------------------------------------
1 | java_library(name='java',
2 | provides = artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-core-java',
5 | repo = artifactory,
6 | ),
7 | fatal_warnings=False,
8 | sources=rglobs('*.java'),
9 | dependencies=[
10 | 'finagle/finagle-core/src/main/scala',
11 | 'util/util-core/src/main/scala'
12 | ],
13 | strict_deps=True,
14 | )
15 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/builder/Common.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.builder
2 |
3 | /**
4 | * Used by builder to throw exceptions if the specification is incomplete.
5 | * {{{
6 | * if (!_codec.isDefined)
7 | * throw new IncompleteSpecification("No codec was specified")
8 | * }}}
9 | */
10 | class IncompleteSpecification(message: String) extends Exception(message)
11 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/util/Showable.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.util
2 |
3 | /**
4 | * Trait showable is a type-class for showing parseable
5 | * representations of objects.
6 | */
7 | trait Showable[-T] {
8 | def show(t: T): String
9 | }
10 |
11 | object Showable {
12 | def show[T](t: T)(implicit showable: Showable[T]): String =
13 | showable.show(t)
14 | }
15 |
--------------------------------------------------------------------------------
/finagle-thrift/src/main/java/BUILD:
--------------------------------------------------------------------------------
1 | java_library(name='java',
2 | sources=rglobs('*.java'),
3 | dependencies=[
4 | '3rdparty/jvm/org/slf4j:slf4j-api',
5 | '3rdparty/jvm/org/apache/thrift:libthrift-0.5.0',
6 | 'scrooge/scrooge-core',
7 | ],
8 | provides=artifact(org='com.twitter',
9 | name='finagle-thrift-java',
10 | repo = artifactory,),
11 | )
12 |
--------------------------------------------------------------------------------
/finagle-thrift/src/main/scala/com/twitter/finagle/thrift/ThriftTracing.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.thrift
2 |
3 | /**
4 | * Support for finagle tracing in thrift.
5 | */
6 |
7 | private[finagle] object ThriftTracing {
8 | /**
9 | * v1: transaction id frame
10 | * v2: full tracing header
11 | * v3: zipkin
12 | */
13 | val CanTraceMethodName = "__can__finagle__trace__v3__"
14 | }
15 |
--------------------------------------------------------------------------------
/doc/src/sphinx/code/quickstart/Proxy.scala:
--------------------------------------------------------------------------------
1 | import com.twitter.finagle.{Http, Service}
2 | import com.twitter.finagle.http.{Request, Response}
3 | import com.twitter.util.Await
4 |
5 | //#app
6 | object Proxy extends App {
7 | val client: Service[Request, Response] =
8 | Http.newService("www.google.com:80")
9 |
10 | val server = Http.serve(":8080", client)
11 | Await.ready(server)
12 | }
13 | //#app
14 |
--------------------------------------------------------------------------------
/finagle-http/src/main/java/com/twitter/finagle/http/Versions.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http;
2 |
3 | /**
4 | * Java friendly versions of {@link com.twitter.finagle.http.Version}.
5 | */
6 | public final class Versions {
7 | private Versions() { }
8 |
9 | public static final Version HTTP_1_1 = Version.Http11$.MODULE$;
10 | public static final Version HTTP_1_0 = Version.Http10$.MODULE$;
11 | }
12 |
--------------------------------------------------------------------------------
/finagle-integration/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/org/mockito:mockito-all',
5 | '3rdparty/jvm/org/scalatest',
6 | 'finagle/finagle-http',
7 | 'finagle/finagle-memcached',
8 | 'finagle/finagle-mux',
9 | 'finagle/finagle-mysql',
10 | ],
11 | fatal_warnings=True,
12 | sources=rglobs('*.scala')
13 | )
14 |
--------------------------------------------------------------------------------
/finagle-mysql/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-mysql',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/io/netty',
9 | 'finagle/finagle-core',
10 | 'util/util-core',
11 | 'util/util-cache',
12 | 'util/util-logging'
13 | ],
14 | sources=rglobs('*.scala'),
15 | )
16 |
--------------------------------------------------------------------------------
/finagle-thrift/src/test/resources/README.md:
--------------------------------------------------------------------------------
1 | From http://stackoverflow.com/questions/10175812/how-to-create-a-self-signed-certificate-with-openssl ..
2 |
3 | `openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 999 -nodes`
4 |
5 | .. which means that the certificate used in the `com.twitter.finagle.thrift.EndToEndTest` `"Configuring SSL over stack param"`
6 | test-case will be invalid from May 3, 2018.
7 |
--------------------------------------------------------------------------------
/finagle-benchmark/src/main/scala/com/twitter/finagle/benchmark/StdBenchAnnotations.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.benchmark
2 |
3 | import java.util.concurrent.TimeUnit
4 | import org.openjdk.jmh.annotations._
5 |
6 | @Fork(1)
7 | @OutputTimeUnit(TimeUnit.NANOSECONDS)
8 | @BenchmarkMode(Array(Mode.AverageTime))
9 | @Warmup(iterations = 10)
10 | @Measurement(iterations = 10)
11 | abstract class StdBenchAnnotations
12 |
--------------------------------------------------------------------------------
/finagle-cacheresolver/README:
--------------------------------------------------------------------------------
1 | This is a transitional package to support the migration to Netty4.
2 | It separates the duplicated TwitterCacheResolver from finagle-memcached
3 | and finagle-memcachedx.
4 |
5 | Once the Netty4 migration is complete and we again have only one
6 | implementation of finagle-memcached this package can be deleted and
7 | the TwitterCacheResolver moved back into the unified finagle-memcached
8 | package.
9 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/netty3/WorkerPool.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.netty3
2 |
3 | import com.twitter.app.GlobalFlag
4 | import com.twitter.jvm.numProcs
5 | import org.jboss.netty.channel.socket.nio.NioWorkerPool
6 |
7 | object numWorkers extends GlobalFlag((numProcs() * 2).ceil.toInt, "Size of netty3 worker pool")
8 |
9 | object WorkerPool extends NioWorkerPool(Executor, numWorkers())
10 |
--------------------------------------------------------------------------------
/finagle-core/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/org/mockito:mockito-all',
5 | '3rdparty/jvm/org/scalacheck',
6 | '3rdparty/jvm/org/scalatest',
7 | 'finagle/finagle-core',
8 | 'util/util-stats',
9 | ],
10 | sources=rglobs('*.scala'),
11 | resources=[
12 | 'finagle/finagle-core/src/test/resources'
13 | ]
14 | )
15 |
--------------------------------------------------------------------------------
/finagle-ostrich4/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/org/mockito:mockito-all',
5 | '3rdparty/jvm/io/netty',
6 | '3rdparty/jvm/org/scalatest',
7 | 'finagle/finagle-core',
8 | 'finagle/finagle-ostrich4',
9 | 'ostrich',
10 | 'util/util-core'
11 | ],
12 | fatal_warnings=True,
13 | sources=rglobs('*.scala')
14 | )
15 |
--------------------------------------------------------------------------------
/finagle-example/src/main/thrift/logger.thrift:
--------------------------------------------------------------------------------
1 | namespace java com.twitter.finagle.example.thriftjava
2 | #@namespace scala com.twitter.finagle.example.thriftscala
3 |
4 | exception WriteException {}
5 | exception ReadException {}
6 |
7 | service LoggerService {
8 | string log(1: string message, 2: i32 logLevel) throws (1: WriteException writeEx);
9 | i32 getLogSize() throws (1: ReadException readEx);
10 | }
11 |
12 |
13 |
--------------------------------------------------------------------------------
/finagle-thrift/src/test/thrift/echo.thrift:
--------------------------------------------------------------------------------
1 | namespace java com.twitter.finagle.thrift.thriftjava
2 | #@namespace scala com.twitter.finagle.thrift.thriftscala
3 |
4 | exception InvalidQueryException {
5 | 1: i32 errorCode
6 | }
7 |
8 | service Echo {
9 | string echo(string msg) throws (
10 | 1: InvalidQueryException ex
11 | );
12 | }
13 |
14 | service ExtendedEcho extends Echo {
15 | string getStatus();
16 | }
17 |
--------------------------------------------------------------------------------
/finagle-toggle/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-toggle',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | 'util/util-app/src/main/java',
9 | 'util/util-app/src/main/scala',
10 | 'util/util-core',
11 | ],
12 | fatal_warnings=True,
13 | strict_deps=True,
14 | sources=rglobs('*.scala'),
15 | )
16 |
--------------------------------------------------------------------------------
/finagle-http-compat/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-http-compat',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/io/netty',
9 | 'finagle/finagle-core',
10 | 'finagle/finagle-http',
11 | 'util/util-core',
12 | ],
13 | fatal_warnings=True,
14 | sources=rglobs('*.scala'),
15 | )
16 |
--------------------------------------------------------------------------------
/finagle-http/src/test/java/com/twitter/finagle/http/RequestCompilationTest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http;
2 |
3 | import org.junit.Test;
4 |
5 | public class RequestCompilationTest {
6 | @Test
7 | public void testMain() throws Exception {
8 | Request r1 = Request.apply(Versions.HTTP_1_1, Methods.GET, "/");
9 | Request r2 = Request.apply(Versions.HTTP_1_1, Methods.newMethod("CUSTOM"), "/");
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/finagle-native/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/io/netty',
5 | '3rdparty/jvm/org/scalatest',
6 | 'finagle/finagle-core',
7 | 'finagle/finagle-http',
8 | 'util/util-core',
9 | ],
10 | fatal_warnings=True,
11 | sources=rglobs('*.scala'),
12 | resources=[
13 | 'finagle/finagle-native/src/test/resources'
14 | ]
15 | )
16 |
--------------------------------------------------------------------------------
/finagle-zipkin/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/org/mockito:mockito-all',
4 | '3rdparty/jvm/org/scalacheck',
5 | '3rdparty/jvm/org/scalatest',
6 | '3rdparty/jvm/junit',
7 | 'util/util-core',
8 | 'util/util-codec',
9 | 'finagle/finagle-core',
10 | 'finagle/finagle-zipkin'
11 | ],
12 | fatal_warnings=True,
13 | sources=rglobs('*.scala')
14 | )
15 |
--------------------------------------------------------------------------------
/finagle-http-compat/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/io/netty',
5 | '3rdparty/jvm/org/scalacheck',
6 | '3rdparty/jvm/org/scalatest',
7 | 'finagle/finagle-core',
8 | 'finagle/finagle-http',
9 | 'finagle/finagle-http-compat',
10 | 'util/util-core',
11 | ],
12 | fatal_warnings=True,
13 | sources=rglobs('*.scala')
14 | )
15 |
--------------------------------------------------------------------------------
/finagle-mdns/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-mdns',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/javax/jmdns',
9 | 'finagle/finagle-core',
10 | 'util/util-core'
11 | ],
12 | sources=rglobs('*.scala'),
13 | resources=[
14 | 'finagle/finagle-mdns/src/main/resources'
15 | ],
16 | )
17 |
--------------------------------------------------------------------------------
/finagle-netty4/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-netty4',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/io/netty:netty4',
9 | '3rdparty/jvm/io/netty:netty4-http',
10 | 'finagle/finagle-core',
11 | 'util/util-core'
12 | ],
13 | fatal_warnings=True,
14 | sources=rglobs('*.scala'),
15 | )
16 |
--------------------------------------------------------------------------------
/doc/treq.pic:
--------------------------------------------------------------------------------
1 | .\" Shows ServiceFactory stack
2 | .sp
3 | .PS
4 | maxpswid=100
5 | maxpsht=100
6 | boxwid=1.2
7 | .ps +10
8 |
9 | box "[4]\fIsize\fP"; right; box "[1]\fITreq\fP"; right; box "[3]\fItag\fP"; right;
10 | box width 1.5 "[8]\fIspan id\fP"; right
11 | box width 1.5 "[8]\fIparent id\fP"; right
12 | box width 1.5 "[8]\fItrace id\fP"; right
13 | box width 1.5 "[4]\fIflags\fP"; right
14 | box width 1.5 "[size-32]\fIbody\fP"
15 | .PE
16 |
--------------------------------------------------------------------------------
/finagle-benchmark/src/main/scala/com/twitter/finagle/PathBenchmark.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle
2 |
3 | import com.twitter.finagle.benchmark.StdBenchAnnotations
4 | import org.openjdk.jmh.annotations._
5 |
6 | @State(Scope.Benchmark)
7 | class PathBenchmark extends StdBenchAnnotations {
8 |
9 | @Param(Array("/"))
10 | var path: String = "/"
11 |
12 | @Benchmark
13 | def read(): Path =
14 | Path.read(path)
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/finagle-core/src/test/java/com/twitter/finagle/ResolversCompilationTest.java:
--------------------------------------------------------------------------------
1 | /* Copyright 2015 Twitter, Inc. */
2 | package com.twitter.finagle;
3 |
4 | import org.junit.Test;
5 |
6 | public class ResolversCompilationTest {
7 |
8 | @Test
9 | public void testEval() {
10 | Resolvers.eval("/s/foo");
11 | }
12 |
13 | @Test
14 | public void testEvalLabeled() {
15 | Resolvers.evalLabeled("foo=/s/bar");
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/finagle-exception/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/com/fasterxml/jackson/core:jackson-databind',
4 | '3rdparty/jvm/junit',
5 | '3rdparty/jvm/org/mockito:mockito-all',
6 | '3rdparty/jvm/org/scalatest',
7 | 'finagle/finagle-core',
8 | 'finagle/finagle-exception',
9 | 'util/util-codec',
10 | 'util/util-core'
11 | ],
12 | sources=rglobs('*.scala')
13 | )
14 |
--------------------------------------------------------------------------------
/finagle-core/src/test/scala/com/twitter/finagle/PathTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle
2 |
3 | import org.junit.runner.RunWith
4 | import org.scalatest.FunSuite
5 | import org.scalatest.junit.{AssertionsForJUnit, JUnitRunner}
6 |
7 | @RunWith(classOf[JUnitRunner])
8 | class PathTest extends FunSuite with AssertionsForJUnit {
9 | test("Path.show") {
10 | assert(NameTreeParsers.parsePath("/foo/bar").show == "/foo/bar")
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/finagle-core/src/test/java/com/twitter/finagle/MyTestCodec.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle;
2 |
3 | import org.jboss.netty.channel.ChannelPipelineFactory;
4 |
5 | /**
6 | * A compilation test for defining codecs in java.
7 | */
8 |
9 | public class MyTestCodec extends AbstractCodec {
10 | // This is the only necessary definition.
11 | public ChannelPipelineFactory pipelineFactory() {
12 | return null;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/finagle-kestrel/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/com/google/guava',
4 | '3rdparty/jvm/junit',
5 | '3rdparty/jvm/org/mockito:mockito-all',
6 | '3rdparty/jvm/io/netty',
7 | '3rdparty/jvm/org/scalatest',
8 | 'finagle/finagle-core',
9 | 'finagle/finagle-kestrel',
10 | 'finagle/finagle-memcached',
11 | 'util/util-core'
12 | ],
13 | sources=rglobs('*.scala')
14 | )
15 |
--------------------------------------------------------------------------------
/doc/src/sphinx/metrics/FailFast.rst:
--------------------------------------------------------------------------------
1 | FailFastFactory
2 | <<<<<<<<<<<<<<<
3 |
4 | **marked_dead**
5 | A counter of how many times the host has been marked dead due to connection
6 | problems.
7 |
8 | **unhealthy_for_ms**
9 | A gauge of how long, in milliseconds, Finagle has been trying to reestablish
10 | a connection.
11 |
12 | **unhealthy_num_tries**
13 | A gauge of the number of times the Factory has tried to reestablish a
14 | connection.
15 |
--------------------------------------------------------------------------------
/finagle-redis/src/test/scala/com/twitter/finagle/redis/Tags.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.redis.tags
2 |
3 | import org.scalatest.Tag
4 |
5 | object RedisTest extends Tag("com.twitter.finagle.redis.tags.RedisTest")
6 | object CodecTest extends Tag("com.twitter.finagle.redis.tags.CodecTest")
7 | object ClientTest extends Tag("com.twitter.finagle.redis.tags.ClientTest")
8 | object ClientServerTest extends Tag("com.twitter.finagle.redis.tags.ClientServerTest")
9 |
--------------------------------------------------------------------------------
/finagle-stats/src/main/scala/com/twitter/finagle/stats/SampledValues.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.stats
2 |
3 | import com.twitter.common.metrics.Snapshot
4 | import scala.collection.Map
5 |
6 | /**
7 | * Struct representing the sampled values from
8 | * the Metrics registry.
9 | */
10 | private[stats] case class SampledValues(
11 | gauges: Map[String, Number],
12 | counters: Map[String, Number],
13 | histograms: Map[String, Snapshot])
14 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/util/NetUtil.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.core.util
2 |
3 |
4 | object NetUtil {
5 | private val Ipv4Digit = """(?:0|1\d{0,2}|2(?:|[0-4]\d?|5[0-5]?|[6-9])|[3-9]\d?)"""
6 | private val Ipv4Regex = Seq(Ipv4Digit, Ipv4Digit, Ipv4Digit, Ipv4Digit).mkString("""\.""").r
7 |
8 | /* Check if string is an IPv4 address. */
9 | def isIpv4Address(ip: String): Boolean =
10 | Ipv4Regex.pattern.matcher(ip).matches
11 | }
12 |
--------------------------------------------------------------------------------
/finagle-thrift/src/main/ruby/lib/finagle-thrift/thrift/tracing_constants.rb:
--------------------------------------------------------------------------------
1 | #
2 | # Autogenerated by Thrift
3 | #
4 | # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5 | #
6 |
7 | require 'tracing_types'
8 |
9 | module FinagleThrift
10 | CLIENT_SEND = %q"cs"
11 |
12 | CLIENT_RECV = %q"cr"
13 |
14 | SERVER_SEND = %q"ss"
15 |
16 | SERVER_RECV = %q"sr"
17 |
18 | SERVER_ADDR = %q"sa"
19 |
20 | CLIENT_ADDR = %q"ca"
21 |
22 | end
23 |
--------------------------------------------------------------------------------
/finagle-thriftmux/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-thriftmux',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/org/apache/thrift:thrift-0.5.0',
9 | 'finagle/finagle-core',
10 | 'finagle/finagle-mux',
11 | 'finagle/finagle-thrift',
12 | 'util/util-core'
13 | ],
14 | fatal_warnings=True,
15 | sources=rglobs('*.scala'),
16 | )
17 |
--------------------------------------------------------------------------------
/finagle-mux/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/org/mockito:mockito-all',
5 | '3rdparty/jvm/io/netty',
6 | '3rdparty/jvm/org/scalacheck',
7 | '3rdparty/jvm/org/scalatest',
8 | 'finagle/finagle-core',
9 | 'finagle/finagle-mux',
10 | 'util/util-core'
11 | ],
12 | sources=rglobs('*.scala'),
13 | resources=[
14 | 'finagle/finagle-mux/src/test/resources'
15 | ]
16 | )
17 |
--------------------------------------------------------------------------------
/finagle-mysql/README.md:
--------------------------------------------------------------------------------
1 | *finagle-mysql* is a MySQL driver built for Finagle. The project provides a simple query API with
2 | support for prepared statements and transactions while leveraging Finagle's
3 | [client stack](http://twitter.github.io/finagle/guide/Clients.html) for connection pooling,
4 | load balancing, etc. See the [API](http://twitter.github.io/finagle/docs/#com.twitter.finagle.exp.Mysql$)
5 | or [docs](http://twitter.github.io/finagle/guide/Protocols.html#mysql) for usage examples.
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/netty3/ChannelFuture.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.netty3
2 |
3 | import org.jboss.netty.channel._
4 |
5 | /**
6 | * A ChannelFuture that doesn't need to have a channel on creation.
7 | */
8 | private[finagle] class LatentChannelFuture extends DefaultChannelFuture(null, false) {
9 | @volatile private var channel: Channel = _
10 |
11 | def setChannel(c: Channel) { channel = c }
12 | override def getChannel() = channel
13 | }
14 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/param/WithClientAdmissionControl.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.param
2 |
3 | import com.twitter.finagle.Stack
4 |
5 | trait WithClientAdmissionControl[A <: Stack.Parameterized[A]] { self: Stack.Parameterized[A] =>
6 |
7 |
8 | /**
9 | * An entry point for configuring the clients' admission control
10 | */
11 | val withAdmissionControl: ClientAdmissionControlParams[A] =
12 | new ClientAdmissionControlParams(this)
13 | }
14 |
--------------------------------------------------------------------------------
/finagle-serversets/src/main/scala/com/twitter/finagle/serverset2/client/apache/package.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.serverset2.client
2 |
3 | import com.twitter.io.Buf
4 |
5 | package object apache {
6 | private[apache] def toByteArray(buf: Buf): Array[Byte] = buf match {
7 | case Buf.ByteArray.Owned(a, 0, len) if len == buf.length => a
8 | case b => {
9 | val bytes = new Array[Byte](b.length)
10 | b.write(bytes, 0)
11 | bytes
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/doc/lbstack.pic:
--------------------------------------------------------------------------------
1 | .\" Shows ServiceFactory stack
2 | .sp
3 | .PS
4 | maxpswid=100
5 | maxpsht=100
6 | boxwid=1.4
7 | .ps +10
8 |
9 | copy "service.pic"
10 |
11 | stack; move; stack
12 |
13 | box "\fIServiceFactory (LoadBalancer) - GroupSession\fP" with .n at 1/2 of the way between 2nd last [].sw and last [].se + (0, -.5) wid 2*last [].wid + movewid thickness 2
14 |
15 | .\" box with .nw at Fst.nw ht Fst.Bound.ht
16 | .\" box with .nw at 3rd last [].nw wid 3*last [].wid ht last [].ht
17 | .PE
18 |
--------------------------------------------------------------------------------
/finagle-memcached/src/test/java/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='java',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/io/netty',
5 | '3rdparty/jvm/org/scala-lang:scala-library',
6 | 'science/src/java/com/twitter/common/zookeeper:testing',
7 | 'finagle/finagle-core',
8 | 'finagle/finagle-memcached',
9 | 'finagle/finagle-memcached/src/test/scala:external',
10 | 'util/util-core',
11 | ],
12 | fatal_warnings=False,
13 | sources=rglobs('*.java')
14 | )
15 |
--------------------------------------------------------------------------------
/finagle-cacheresolver/src/main/java/BUILD:
--------------------------------------------------------------------------------
1 | java_library(name='java',
2 | provides = artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-cacheresolver-java',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/org/scala-lang:scala-library',
9 | 'science/src/java/com/twitter/common/zookeeper:client',
10 | 'finagle/finagle-core',
11 | 'finagle/finagle-cacheresolver/src/main/scala',
12 | 'util/util-core',
13 | ],
14 | sources=rglobs('*.java')
15 | )
16 |
--------------------------------------------------------------------------------
/finagle-zipkin/src/main/scala/com/twitter/finagle/zipkin/Flags.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.zipkin
2 |
3 | import com.twitter.app.GlobalFlag
4 | import com.twitter.finagle.zipkin.thrift.Sampler
5 | import java.net.InetSocketAddress
6 |
7 | object host extends GlobalFlag[InetSocketAddress](
8 | new InetSocketAddress("localhost", 1463),
9 | "Host to scribe traces to")
10 |
11 | object initialSampleRate extends GlobalFlag[Float](
12 | Sampler.DefaultSampleRate,
13 | "Initial sample rate")
14 |
--------------------------------------------------------------------------------
/finagle-core/src/test/java/com/twitter/finagle/service/RetryPolicyCompilationTest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.service;
2 |
3 | import scala.runtime.Nothing$;
4 |
5 | import org.junit.Assert;
6 | import org.junit.Test;
7 |
8 | import com.twitter.util.Try;
9 |
10 | public class RetryPolicyCompilationTest {
11 |
12 | @Test
13 | public void testFutureCastMap() throws Exception {
14 | RetryPolicy> policy = RetryPolicy.tries(2);
15 | Assert.assertNotNull(policy);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/finagle-http2/src/main/scala/com/twitter/finagle/http2/package.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle
2 |
3 | import com.twitter.finagle.Http.param.HttpImpl
4 | import com.twitter.finagle.netty4.http.{Netty4ClientStreamTransport, Netty4ServerStreamTransport}
5 |
6 | package object http2 {
7 | private[finagle] val Http2: HttpImpl = HttpImpl(
8 | new Netty4ClientStreamTransport(_),
9 | new Netty4ServerStreamTransport(_),
10 | Http2Transporter.apply _,
11 | Http2Listener.apply _
12 | )
13 | }
14 |
--------------------------------------------------------------------------------
/finagle-toggle/src/main/scala/com/twitter/finagle/toggle/NullToggleMap.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.toggle
2 |
3 | import com.twitter.finagle.toggle.Toggle.Metadata
4 |
5 | /**
6 | * A [[ToggleMap]] implementation where there are no
7 | * [[Toggle Toggles]].
8 | */
9 | object NullToggleMap extends ToggleMap {
10 | override def toString: String = "NullToggleMap"
11 |
12 | def apply(id: String): Toggle[Int] = Toggle.Undefined
13 |
14 | def iterator: Iterator[Metadata] = Iterator.empty
15 | }
16 |
--------------------------------------------------------------------------------
/finagle-toggle/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/org/scalacheck',
5 | '3rdparty/jvm/org/scalatest',
6 | 'finagle/finagle-toggle',
7 | 'util/util-app/src/main/java',
8 | 'util/util-app/src/main/scala',
9 | 'util/util-core',
10 | ],
11 | resources=[
12 | 'finagle/finagle-toggle/src/test/resources'
13 | ],
14 | sources=rglobs('*.scala'),
15 | fatal_warnings=True,
16 | strict_deps=True,
17 | )
18 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Problem
2 |
3 | Explain the context and why you're making that change. What is the
4 | problem you're trying to solve? In some cases there is not a problem
5 | and this can be thought of being the motivation for your change.
6 |
7 | Solution
8 |
9 | Describe the modifications you've done.
10 |
11 | Result
12 |
13 | What will change as a result of your pull request? Note that sometimes
14 | this section is unnecessary because it is self-explanatory based on
15 | the solution.
16 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/util/LoadService.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.util
2 |
3 | import scala.reflect.ClassTag
4 |
5 | /**
6 | * Load a singleton class in the manner of [[java.util.ServiceLoader]]. It is
7 | * more resilient to varying Java packaging configurations than ServiceLoader.
8 | *
9 | * @see `com.twitter.app.LoadService` in util-app
10 | */
11 | object LoadService {
12 |
13 | def apply[T: ClassTag](): Seq[T] =
14 | com.twitter.app.LoadService()
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/finagle-netty4-http/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-netty4-http',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/io/netty:netty4',
9 | '3rdparty/jvm/io/netty:netty4-http',
10 | 'finagle/finagle-core',
11 | 'finagle/finagle-http',
12 | 'finagle/finagle-netty4',
13 | 'util/util-core',
14 | ],
15 | fatal_warnings=True,
16 | sources=rglobs('*.scala'),
17 | )
18 |
--------------------------------------------------------------------------------
/doc/src/sphinx/metrics/FailureDetector.rst:
--------------------------------------------------------------------------------
1 | ThresholdFailureDetector
2 | <<<<<<<<<<<<<<<<<<<<<<<<
3 |
4 | **ping**
5 | A counter of the number of pings sent to remote peers.
6 |
7 | **ping_latency_us**
8 | A stat of round trip ping latencies in microseconds.
9 |
10 | **marked_busy**
11 | A counter of the number of times the endpoints are marked busy.
12 |
13 | **revivals**
14 | A counter of the number of times the endpoints revive.
15 |
16 | **close**
17 | A counter of the number of endpoints that are closed.
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/context/LocalContext.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.context
2 |
3 | /**
4 | * A type of context that is local to the process. The type of Key is
5 | * also unique (generative) to each instance of this context, so that keys
6 | * cannot be used across different instances of this context type.
7 | */
8 | class LocalContext extends Context {
9 | class Key[A]
10 |
11 | /**
12 | * A java-friendly key constructor.
13 | */
14 | def newKey[A]() = new Key[A]
15 | }
16 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/stats/HostStatsReceiver.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.stats
2 |
3 | /**
4 | * A StatsReceiver type that's used for per host stats only. The underlying
5 | * implementation can be any StatsReceiver. The type is used as a marker.
6 | */
7 | trait HostStatsReceiver extends StatsReceiverProxy
8 |
9 | class InMemoryHostStatsReceiver extends HostStatsReceiver {
10 | private[this] val _self: InMemoryStatsReceiver = new InMemoryStatsReceiver
11 | def self = _self
12 | }
13 |
--------------------------------------------------------------------------------
/finagle-kestrel/src/main/java/BUILD:
--------------------------------------------------------------------------------
1 | java_library(name='java',
2 | provides = artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-kestrel-java',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/io/netty',
9 | '3rdparty/jvm/org/scala-lang:scala-library',
10 | 'finagle/finagle-core',
11 | 'finagle/finagle-memcached',
12 | 'finagle/finagle-kestrel/src/main/scala',
13 | 'util/util-core',
14 | ],
15 | fatal_warnings=False,
16 | sources=rglobs('*.java')
17 | )
18 |
--------------------------------------------------------------------------------
/finagle-spdy/src/main/scala/com/twitter/finagle/spdy/SpdyRawFrameCodec.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.spdy
2 |
3 | import org.jboss.netty.handler.codec.spdy.{
4 | SpdyFrameCodec, SpdyHeaderBlockRawDecoder, SpdyHeaderBlockRawEncoder, SpdyVersion
5 | }
6 |
7 | private[finagle] class SpdyRawFrameCodec(version: SpdyVersion, maxChunkSize: Int, maxHeaderSize: Int)
8 | extends SpdyFrameCodec(version, maxChunkSize,
9 | new SpdyHeaderBlockRawDecoder(version, maxHeaderSize),
10 | new SpdyHeaderBlockRawEncoder(version))
11 |
--------------------------------------------------------------------------------
/finagle-thrift/src/main/ruby/Rakefile:
--------------------------------------------------------------------------------
1 | $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
2 |
3 | require 'rubygems'
4 |
5 | require 'finagle-thrift/version'
6 | require 'rake/testtask'
7 |
8 | desc 'Default: run unit tests.'
9 | task :default => :test
10 |
11 | desc 'Test the gem.'
12 | Rake::TestTask.new(:test) do |t|
13 | t.libs << 'lib'
14 | t.pattern = 'test/**/*_test.rb'
15 | t.verbose = true
16 | end
17 |
18 | desc 'Build the gem'
19 | task :build do
20 | system "gem build finagle-thrift.gemspec"
21 | end
22 |
--------------------------------------------------------------------------------
/doc/README.md:
--------------------------------------------------------------------------------
1 | # Finagle User Guide
2 |
3 | To generate the user guide website locally, `cd` into the `finagle`
4 | directory and run the following commands.
5 |
6 | $ ./sbt finagle-doc/make-site
7 | $ open doc/target/site/index.html
8 |
9 | To publish a new version of the user guide to GitHub Pages:
10 |
11 | 1. Make sure SBT sees the current version as the release version of
12 | Finagle (and not the SNAPSHOT version) by running from the master branch.
13 | 2. Execute the script `finagle/pushsite.bash`.
14 |
--------------------------------------------------------------------------------
/doc/src/sphinx/metrics/Construction.rst:
--------------------------------------------------------------------------------
1 | ClientBuilder
2 | <<<<<<<<<<<<<
3 |
4 | **codec_connection_preparation_latency_ms**
5 | A histogram of the length of time it takes to prepare a connection and get
6 | back a service, regardless of success or failure.
7 |
8 | StatsServiceFactory
9 | <<<<<<<<<<<<<<<<<<<
10 |
11 | **available**
12 | A gauge of whether the underlying factory is available (1) or not (0).
13 | Finagle uses this primarily to decide whether a host is eligible for new
14 | connections in the load balancer.
15 |
--------------------------------------------------------------------------------
/doc/morestack.pic:
--------------------------------------------------------------------------------
1 | .sp
2 | .PS
3 | maxpswid=100
4 | maxpsht=100
5 | .ps +10
6 | boxwid=1.4
7 |
8 | copy "service.pic"
9 |
10 | Stack: stack
11 | down
12 | boxwid=last [].wid
13 | box "RequestTimeoutFilter" with .n at last [].s+(0,-.25)
14 | box "FailureAccrualFactory"
15 | box "FailFastFactory"
16 | box "StatsFilter"
17 | box "MonitorFilter"
18 |
19 | box with .n at Stack.n+(0,.05) ht (Stack.ht+5*boxht+.25+.05)+.6 wid 1.05*boxwid thickness 2.4
20 | "\fIServiceFactory - EndpointSession\fP" with .s at last box .s+(0,.2)
21 |
22 | .PE
23 |
--------------------------------------------------------------------------------
/finagle-commons-stats/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-commons-stats',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | 'science/src/java/com/twitter/common/stats:stats',
9 | 'finagle/finagle-core',
10 | 'util/util-registry',
11 | 'util/util-stats',
12 | ],
13 | fatal_warnings=True,
14 | sources=rglobs('*.scala'),
15 | resources=[
16 | 'finagle/finagle-commons-stats/src/main/resources'
17 | ],
18 | )
19 |
--------------------------------------------------------------------------------
/finagle-core/src/test/scala/com/twitter/finagle/service/ResponseClassTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.service
2 |
3 | import org.junit.runner.RunWith
4 | import org.scalatest.FunSuite
5 | import org.scalatest.junit.JUnitRunner
6 |
7 | @RunWith(classOf[JUnitRunner])
8 | class ResponseClassTest extends FunSuite {
9 |
10 | test("validates fractionalSuccess") {
11 | intercept[IllegalArgumentException] { ResponseClass.Successful(0.0) }
12 | intercept[IllegalArgumentException] { ResponseClass.Successful(1.1) }
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/finagle-http/src/main/scala/com/twitter/finagle/http/service/NullService.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http.service
2 |
3 | import com.twitter.finagle.Service
4 | import com.twitter.finagle.http.{Request, Response}
5 | import com.twitter.util.Future
6 |
7 |
8 | /*** A null Service. Useful for testing. */
9 | class NullService[REQUEST <: Request] extends Service[REQUEST, Response] {
10 | def apply(request: REQUEST): Future[Response] =
11 | Future.value(request.response)
12 | }
13 |
14 | object NullService extends NullService[Request]
15 |
--------------------------------------------------------------------------------
/finagle-kestrel/src/main/scala/com/twitter/finagle/kestrel/protocol/Response.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.kestrel.protocol
2 |
3 | import com.twitter.io.Buf
4 |
5 | sealed abstract class Response
6 | case class NotFound() extends Response
7 | case class Stored() extends Response
8 | case class Deleted() extends Response
9 | case class Error() extends Response
10 |
11 | case class Values(values: Seq[Value]) extends Response
12 | case class Value(key: Buf, value: Buf)
13 |
--------------------------------------------------------------------------------
/finagle-memcached/src/main/scala/com/twitter/finagle/memcached/protocol/text/Decodings.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.memcached.protocol.text
2 |
3 | import com.twitter.io.Buf
4 |
5 | sealed abstract class Decoding
6 | case class Tokens(tokens: Seq[Buf]) extends Decoding
7 | case class TokensWithData(
8 | tokens: Seq[Buf],
9 | data: Buf,
10 | casUnique: Option[Buf] = None)
11 | extends Decoding
12 | case class ValueLines(lines: Seq[TokensWithData]) extends Decoding
13 | case class StatLines(lines: Seq[Tokens]) extends Decoding
14 |
--------------------------------------------------------------------------------
/finagle-thrift/src/main/java/com/twitter/finagle/thrift/ThriftClientRequest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.thrift;
2 |
3 | /**
4 | * Defines a (framed) thrift request, simply composed of the raw
5 | * message & a boolean indicating whether it is a one-shot message or
6 | * not.
7 | */
8 |
9 | public class ThriftClientRequest {
10 | public byte[] message;
11 | public boolean oneway;
12 |
13 | public ThriftClientRequest(byte[] message, boolean oneway) {
14 | this.message = message;
15 | this.oneway = oneway;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/finagle-example/src/main/scala/com/twitter/finagle/example/thrift/ThriftClient.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.example.thrift
2 |
3 | import com.twitter.finagle.example.thriftscala.Hello
4 | import com.twitter.finagle.Thrift
5 |
6 | object ThriftClient {
7 | def main(args: Array[String]) {
8 | //#thriftclientapi
9 | val client = Thrift.client.newIface[Hello.FutureIface]("localhost:8080")
10 | client.hi().onSuccess { response =>
11 | println("Received response: " + response)
12 | }
13 | //#thriftclientapi
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/netty3/param/Params.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.netty3.param
2 |
3 | import com.twitter.finagle.{util, Stack}
4 | import org.jboss.netty.util.Timer
5 |
6 | /**
7 | * A class eligible for configuring a netty3 timer.
8 | */
9 | private[finagle] case class Netty3Timer(timer: Timer) {
10 | def mk(): (Netty3Timer, Stack.Param[Netty3Timer]) =
11 | (this, Netty3Timer.param)
12 | }
13 | private[finagle] object Netty3Timer {
14 | implicit val param = Stack.Param(Netty3Timer(util.DefaultTimer.netty))
15 | }
16 |
--------------------------------------------------------------------------------
/finagle-http/src/main/scala/com/twitter/finagle/http/Version.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http
2 |
3 | /**
4 | * Represents the HTTP version.
5 | *
6 | * For Java-friendly enums, see [[com.twitter.finagle.http.Versions]].
7 | */
8 | sealed abstract class Version
9 |
10 | object Version {
11 | /** HTTP 1.0 */
12 | case object Http10 extends Version {
13 | override def toString: String = "HTTP/1.0"
14 | }
15 |
16 | /** HTTP 1.1 */
17 | case object Http11 extends Version {
18 | override def toString: String = "HTTP/1.1"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/finagle-memcached/src/main/java/BUILD:
--------------------------------------------------------------------------------
1 | java_library(name='java',
2 | provides = artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-memcached-java',
5 | repo = artifactory
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/com/google/guava',
9 | 'science/src/java/com/twitter/common/zookeeper:client',
10 | '3rdparty/jvm/io/netty',
11 | '3rdparty/jvm/org/scala-lang:scala-library',
12 | 'finagle/finagle-core',
13 | 'finagle/finagle-memcached/src/main/scala',
14 | 'util/util-core',
15 | ],
16 | sources=rglobs('*.java')
17 | )
18 |
--------------------------------------------------------------------------------
/finagle-mux/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-mux',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/io/netty',
9 | 'science/src/java/com/twitter/common/quantity:quantity',
10 | 'science/src/java/com/twitter/common/stats:util',
11 | 'science/src/java/com/twitter/common/util:system-mocks',
12 | 'finagle/finagle-core',
13 | 'util/util-core',
14 | ],
15 | fatal_warnings=True,
16 | sources=rglobs('*.scala'),
17 | )
18 |
--------------------------------------------------------------------------------
/finagle-redis/src/test/scala/com/twitter/finagle/redis/commands/server/ServerCodecSuite.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.redis.protocol
2 |
3 | import com.twitter.finagle.redis.naggati.RedisRequestTest
4 | import com.twitter.finagle.redis.tags.CodecTest
5 | import org.junit.runner.RunWith
6 | import org.scalatest.junit.JUnitRunner
7 |
8 | @RunWith(classOf[JUnitRunner])
9 | final class ServerCodecSuite extends RedisRequestTest {
10 |
11 | test("Correctly encode FLUSHALL", CodecTest) {
12 | assert(codec(wrap("FLUSHALL\r\n")) == List(FlushAll))
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/finagle-example/src/main/scala/com/twitter/finagle/example/thrift/ThriftServer.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.example.thrift
2 |
3 | import com.twitter.finagle.example.thriftscala.Hello
4 | import com.twitter.finagle.Thrift
5 | import com.twitter.util.{Await, Future}
6 |
7 | object ThriftServer {
8 | def main(args: Array[String]) {
9 | //#thriftserverapi
10 | val server = Thrift.server.serveIface("localhost:8080", new Hello[Future] {
11 | def hi() = Future.value("hi")
12 | })
13 | Await.ready(server)
14 | //#thriftserverapi
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/finagle-thrift/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-thrift',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/io/netty',
9 | '3rdparty/jvm/org/apache/thrift:thrift-0.5.0',
10 | 'finagle/finagle-core',
11 | 'finagle/finagle-thrift/src/main/java',
12 | 'scrooge/scrooge-core',
13 | 'util/util-core',
14 | ],
15 | sources=rglobs('*.scala'),
16 | resources=[
17 | 'finagle/finagle-thrift/src/main/resources'
18 | ],
19 | )
20 |
--------------------------------------------------------------------------------
/finagle-ostrich4/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-ostrich4',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/io/netty',
9 | 'finagle/finagle-core',
10 | 'finagle/finagle-http',
11 | 'ostrich',
12 | 'util/util-core',
13 | 'util/util-registry',
14 | 'util/util-stats',
15 | ],
16 | fatal_warnings=True,
17 | sources=rglobs('*.scala'),
18 | resources=[
19 | 'finagle/finagle-ostrich4/src/main/resources'
20 | ],
21 | )
22 |
--------------------------------------------------------------------------------
/finagle-exp/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-exp',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | 'finagle/finagle-core',
9 | 'finagle/finagle-thrift',
10 | 'util/util-core',
11 | ],
12 | fatal_warnings=True,
13 | sources=rglobs('com/twitter/finagle/exp/*.scala'),
14 | )
15 |
16 | benchmark(name='benchmark',
17 | dependencies=[
18 | ':scala',
19 | 'util/util-core',
20 | ],
21 | sources=rglobs('com/twitter/finagle/benchmark/*.scala')
22 | )
23 |
--------------------------------------------------------------------------------
/finagle-kestrel/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-kestrel',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/com/google/guava',
9 | '3rdparty/jvm/io/netty',
10 | 'finagle/finagle-core',
11 | 'finagle/finagle-memcached',
12 | 'finagle/finagle-thrift',
13 | 'finagle/finagle-thrift/src/main/java',
14 | 'finagle/finagle-kestrel/src/main/thrift:thrift-scala',
15 | 'util/util-core',
16 | ],
17 | sources=rglobs('*.scala'),
18 | )
19 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/tracing/TracingLogHandler.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.tracing
2 |
3 | import com.twitter.logging._
4 | import java.util.{logging => javalog}
5 |
6 | /**
7 | * A logging Handler that sends log information via tracing
8 | */
9 | class TracingLogHandler(
10 | formatter: Formatter = BareFormatter,
11 | level: Option[Level] = None
12 | ) extends Handler(formatter, level) {
13 |
14 | def flush() {}
15 | def close() {}
16 |
17 | def publish(record: javalog.LogRecord) {
18 | Trace.record(getFormatter.format(record))
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/doc/src/sphinx/code/quickstart/Server.scala:
--------------------------------------------------------------------------------
1 | //#imports
2 | import com.twitter.finagle.{Http, Service}
3 | import com.twitter.finagle.http
4 | import com.twitter.util.{Await, Future}
5 | //#imports
6 |
7 | object Server extends App {
8 | //#service
9 | val service = new Service[http.Request, http.Response] {
10 | def apply(req: http.Request): Future[http.Response] =
11 | Future.value(
12 | http.Response(req.version, http.Status.Ok)
13 | )
14 | }
15 | //#service
16 | //#builder
17 | val server = Http.serve(":8080", service)
18 | Await.ready(server)
19 | //#builder
20 | }
21 |
--------------------------------------------------------------------------------
/finagle-core/src/test/scala/com/twitter/finagle/InitTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle
2 |
3 | import org.junit.runner.RunWith
4 | import org.scalatest.FunSuite
5 | import org.scalatest.junit.JUnitRunner
6 |
7 | @RunWith(classOf[JUnitRunner])
8 | class InitTest extends FunSuite {
9 |
10 | test("loadBuildProperties") {
11 | Init.loadBuildProperties match {
12 | case None =>
13 | fail("build.properties not found for finagle-core")
14 | case Some(p) =>
15 | val version = p.getProperty("version")
16 | assert(version != null)
17 | }
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/finagle-http/src/test/scala/com/twitter/finagle/http/RequestProxyTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http
2 |
3 | import org.junit.runner.RunWith
4 | import org.scalatest.FunSuite
5 | import org.scalatest.junit.JUnitRunner
6 |
7 | @RunWith(classOf[JUnitRunner])
8 | class RequestProxyTest extends FunSuite {
9 | test("request.ctx") {
10 | val field = Request.Schema.newField[Int]
11 | val request1 = Request()
12 | request1.ctx(field) = 42
13 | val request2 = new RequestProxy {
14 | override val request = request1
15 | }
16 | assert(request2.ctx(field) == 42)
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/finagle-redis/src/test/java/com/twitter/finagle/ClientCompilationTest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle;
2 |
3 | import org.junit.Test;
4 |
5 | import com.twitter.finagle.param.Tracer;
6 | import com.twitter.finagle.tracing.NullTracer;
7 |
8 | public final class ClientCompilationTest {
9 |
10 | /**
11 | * Tests Java usage of the Redis client. The client API should be as accessible in Java as it is
12 | * in Scala.
13 | */
14 | @Test
15 | public void testClientCompilation() {
16 | final Redis.Client client = Redis.client().configured(new Tracer(new NullTracer()).mk());
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/param/WithServerAdmissionControl.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.param
2 |
3 | import com.twitter.finagle.Stack
4 |
5 | /**
6 | * Provides the `withAdmissionControl` API entry point.
7 | *
8 | * @see [[ServerAdmissionControlParams]]
9 | */
10 | trait WithServerAdmissionControl[A <: Stack.Parameterized[A]] { self: Stack.Parameterized[A] =>
11 |
12 | /**
13 | * An entry point for configuring the servers' admission control.
14 | */
15 | val withAdmissionControl: ServerAdmissionControlParams[A] =
16 | new ServerAdmissionControlParams(this)
17 | }
18 |
--------------------------------------------------------------------------------
/finagle-mysql/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/io/netty',
4 | '3rdparty/jvm/junit',
5 | '3rdparty/jvm/mysql:mysql-connector-mxj-gpl',
6 | '3rdparty/jvm/mysql:mysql-connector-mxj-gpl-db-files',
7 | '3rdparty/jvm/mysql:mysql-connector-java',
8 | '3rdparty/jvm/org/mockito:mockito-all',
9 | '3rdparty/jvm/org/scalatest',
10 | 'finagle/finagle-mysql',
11 | 'util/util-core',
12 | ],
13 | fatal_warnings=True,
14 | sources=rglobs('*.scala'),
15 | resources=[
16 | 'finagle/finagle-mysql/src/test/resources'
17 | ]
18 | )
19 |
--------------------------------------------------------------------------------
/finagle-example/src/main/thrift/BUILD:
--------------------------------------------------------------------------------
1 | java_thrift_library(name='thrift-scala',
2 | provides = artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-example-thrift-scala',
5 | repo = artifactory,
6 | ),
7 | sources=rglobs('*.thrift'),
8 | compiler='scrooge',
9 | language='scala',
10 | rpc_style='finagle',
11 | )
12 |
13 | java_thrift_library(name='thrift-java',
14 | provides = artifact(
15 | org = 'com.twitter',
16 | name = 'finagle-example-thrift-java',
17 | repo = artifactory,
18 | ),
19 | sources=rglobs('*.thrift'),
20 | compiler='scrooge',
21 | language='java',
22 | )
23 |
--------------------------------------------------------------------------------
/finagle-http/src/test/java/com/twitter/finagle/http/HttpTracingCompilationTest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http;
2 |
3 | import org.junit.Test;
4 |
5 | /** Compilation tests for HttpTracing */
6 | public class HttpTracingCompilationTest {
7 |
8 | /** a comment */
9 | @Test
10 | public void testHeaders() {
11 | HttpTracing.headers().TraceId();
12 | HttpTracing.headers().SpanId();
13 | HttpTracing.headers().ParentSpanId();
14 | HttpTracing.headers().Sampled();
15 | HttpTracing.headers().Flags();
16 | HttpTracing.headers().All();
17 | HttpTracing.headers().Required();
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/finagle-thriftmux/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/io/netty',
5 | '3rdparty/jvm/org/scalatest',
6 | '3rdparty/jvm/org/apache/thrift:thrift-0.5.0',
7 | 'finagle/finagle-core',
8 | 'finagle/finagle-thrift',
9 | 'finagle/finagle-thriftmux',
10 | 'finagle/finagle-thriftmux/src/test/thrift:thrift-java',
11 | 'finagle/finagle-thriftmux/src/test/thrift:thrift-scala',
12 | 'util/util-core',
13 | ],
14 | sources=rglobs('*.scala'),
15 | resources=[
16 | 'finagle/finagle-thriftmux/src/test/resources'
17 | ]
18 | )
19 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/service/ResponseClassificationSyntheticException.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.service
2 |
3 | import com.twitter.util.NoStacktrace
4 |
5 | /**
6 | * Used by [[com.twitter.finagle.param.ResponseClassifier response classification]]
7 | * to indicate synthetic failures that are not `Exceptions`.
8 | *
9 | * @see [[com.twitter.finagle.service.StatsFilter]]
10 | */
11 | class ResponseClassificationSyntheticException private[finagle]()
12 | extends Exception
13 | with NoStacktrace {
14 | override def getMessage: String =
15 | "A synthetic ResponseClassification failure"
16 | }
17 |
--------------------------------------------------------------------------------
/finagle-http/src/test/java/com/twitter/finagle/http/javaapi/DtabFilterTest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http.javaapi;
2 |
3 | import org.junit.Assert;
4 | import org.junit.Test;
5 |
6 | import com.twitter.finagle.http.Request;
7 | import com.twitter.finagle.http.Response;
8 | import com.twitter.finagle.http.filter.DtabFilter;
9 |
10 | /**
11 | * A Java compilation test for DtabFilter.
12 | */
13 | public class DtabFilterTest {
14 |
15 | @Test
16 | public void tesDtab() {
17 | DtabFilter finagleDtabFilter = new DtabFilter.Finagle();
18 | Assert.assertNotNull(finagleDtabFilter);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/finagle-memcached/src/main/java/com/twitter/finagle/memcached/java/ResultWithCAS.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.memcached.java;
2 |
3 | import com.twitter.io.Buf;
4 |
5 | public class ResultWithCAS {
6 | public final Buf value;
7 | public final Buf casUnique;
8 |
9 | public ResultWithCAS(Buf value, Buf casUnique) {
10 | if (value == null) {
11 | throw new NullPointerException("value cannot be null");
12 | }
13 |
14 | if (casUnique == null) {
15 | throw new NullPointerException("casUnique cannot be null");
16 | }
17 |
18 | this.value = value;
19 | this.casUnique = casUnique;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/param/WithSessionPool.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.param
2 |
3 | import com.twitter.finagle.Stack
4 |
5 | /**
6 | * Provides the `withSessionPool` (default pool) API entry point.
7 | *
8 | * @see [[SessionPoolingParams]]
9 | */
10 | trait WithSessionPool[A <: Stack.Parameterized[A]] { self: Stack.Parameterized[A] =>
11 |
12 | /**
13 | * An entry point for configuring the client's session pool.
14 | *
15 | * @see [[https://twitter.github.io/finagle/guide/Clients.html#pooling]]
16 | */
17 | val withSessionPool: SessionPoolingParams[A] = new SessionPoolingParams(self)
18 | }
19 |
--------------------------------------------------------------------------------
/finagle-example/src/main/java/com/twitter/finagle/example/java/http/CatsDB.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.example.java.http;
2 |
3 | import java.util.HashMap;
4 |
5 | public class CatsDB {
6 | private final static HashMap db = new HashMap<>();
7 |
8 | public Cat get(Integer id) {
9 | if (db.isEmpty())
10 | addExampleCats();
11 |
12 | return db.get(id);
13 | }
14 |
15 | private void addExampleCats() {
16 | db.put(0, new Cat("Doug"));
17 | db.put(1, new Cat("Ozzy"));
18 | db.put(2, new Cat("Logan"));
19 | db.put(3, new Cat("Dylan"));
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/finagle-thrift/src/test/java/com/twitter/finagle/thrift/service/ThriftResponseClassifierCompilationTest.java:
--------------------------------------------------------------------------------
1 | /* Copyright 2015 Twitter, Inc. */
2 | package com.twitter.finagle.thrift.service;
3 |
4 | import scala.PartialFunction;
5 |
6 | import org.junit.Test;
7 |
8 | import com.twitter.finagle.service.ReqRep;
9 | import com.twitter.finagle.service.ResponseClass;
10 |
11 | public class ThriftResponseClassifierCompilationTest {
12 |
13 | @Test
14 | public void testThriftExceptionsAsFailures() {
15 | PartialFunction classifier =
16 | ThriftResponseClassifier.ThriftExceptionsAsFailures();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/finagle-core/src/test/java/com/twitter/finagle/ServiceCompilationTest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle;
2 |
3 | import org.junit.Test;
4 |
5 | import com.twitter.util.Function;
6 | import com.twitter.util.Future;
7 |
8 | public class ServiceCompilationTest {
9 |
10 | @Test
11 | public void testCompilation() {
12 | Service.constant(Future.value("hi"));
13 |
14 | Service mkSvc =
15 | Service.mk(new Function>() {
16 | public Future apply(String s) {
17 | return Future.value(s + s);
18 | }
19 | });
20 |
21 | Service.rescue(mkSvc);
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/finagle-example/src/main/java/com/twitter/finagle/example/java/http/JsonUtils.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.example.java.http;
2 |
3 | import com.fasterxml.jackson.databind.ObjectMapper;
4 |
5 | public final class JsonUtils {
6 | static ObjectMapper mapper = new ObjectMapper();
7 |
8 | public static byte[] toBytes(Object value) {
9 | try {
10 | return mapper.writeValueAsBytes(value);
11 | } catch (Exception e) {
12 | System.out.println(e.getMessage());
13 | throw new IllegalArgumentException(String.format("Could not transform to bytes: %s", e.getMessage()));
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/finagle-http2/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-http2',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/io/netty:netty',
9 | '3rdparty/jvm/io/netty:netty4',
10 | '3rdparty/jvm/io/netty:netty4-http2',
11 | 'finagle/finagle-core',
12 | 'finagle/finagle-http',
13 | 'finagle/finagle-http2/src/main/java:java',
14 | 'finagle/finagle-netty4',
15 | 'finagle/finagle-netty4-http',
16 | 'util/util-core',
17 | ],
18 | strict_deps=True,
19 | fatal_warnings=True,
20 | sources=rglobs('*.scala'),
21 | )
22 |
--------------------------------------------------------------------------------
/finagle-benchmark/src/main/scala/com/twitter/finagle/thrift/HelloServer.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.thrift
2 |
3 | import com.twitter.finagle.ThriftMux
4 | import com.twitter.finagle.benchmark.thriftscala._
5 |
6 | import com.twitter.util.{Await, Future}
7 |
8 | /**
9 | * Thrift server for [[HelloClient]] (thrift allocations benchmark).
10 | */
11 | object HelloServer {
12 | def main(args: Array[String]): Unit = {
13 | val server = ThriftMux.server.
14 | serveIface("localhost:1234", new Hello[Future] {
15 | def echo(m: String) = {
16 | Future.value(m)
17 | }
18 | })
19 |
20 | Await.ready(server)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/service/FailingFactory.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.service
2 |
3 | import com.twitter.util.{Future, Time}
4 | import com.twitter.finagle.{ServiceFactory, ClientConnection, Status}
5 |
6 | /**
7 | * A [[com.twitter.finagle.ServiceFactory]] that fails to construct services.
8 | */
9 | class FailingFactory[Req, Rep](error: Throwable)
10 | extends ServiceFactory[Req, Rep]
11 | {
12 | def apply(conn: ClientConnection) = Future.exception(error)
13 | def close(deadline: Time) = Future.Done
14 | override def status: Status = Status.Open
15 | override val toString = "failing_factory_%s".format(error)
16 | }
17 |
--------------------------------------------------------------------------------
/finagle-memcached/src/main/scala/com/twitter/finagle/memcached/protocol/Error.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.memcached.protocol
2 |
3 | /**
4 | * Indicates that a request failed because an attempt was made to decode a
5 | * non-existent memcached command.
6 | */
7 | class NonexistentCommand(message: String) extends Exception(message)
8 |
9 | /**
10 | * A catch-all exception class for memcached client-related failures.
11 | */
12 | class ClientError(message: String) extends Exception(message)
13 |
14 | /**
15 | * A catch-all exception class for memcached server-related failures.
16 | */
17 | class ServerError(message: String) extends Exception(message)
18 |
--------------------------------------------------------------------------------
/finagle-http/src/main/scala/com/twitter/finagle/http/filter/AddResponseHeadersFilter.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http.filter
2 |
3 | import com.twitter.finagle.{Service, SimpleFilter}
4 | import com.twitter.finagle.http.{Response, Request}
5 | import com.twitter.util.Future
6 | import scala.collection.Map
7 |
8 | class AddResponseHeadersFilter(responseHeaders: Map[String, String])
9 | extends SimpleFilter[Request, Response] {
10 | def apply(request: Request, service: Service[Request, Response]): Future[Response] = {
11 | service(request) map { response =>
12 | response.headerMap ++= responseHeaders
13 | response
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/finagle-thriftmux/src/test/java/com/twitter/finagle/thriftmux/service/ThriftMuxResponseClassifierCompilationTest.java:
--------------------------------------------------------------------------------
1 | /* Copyright 2015 Twitter, Inc. */
2 | package com.twitter.finagle.thriftmux.service;
3 |
4 | import scala.PartialFunction;
5 |
6 | import org.junit.Test;
7 |
8 | import com.twitter.finagle.service.ReqRep;
9 | import com.twitter.finagle.service.ResponseClass;
10 |
11 | public class ThriftMuxResponseClassifierCompilationTest {
12 |
13 | @Test
14 | public void testThriftExceptionsAsFailures() {
15 | PartialFunction classifier =
16 | ThriftMuxResponseClassifier.ThriftExceptionsAsFailures();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/finagle-http/src/main/scala/com/twitter/finagle/http/service/NotFoundService.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http.service
2 |
3 | import com.twitter.finagle.Service
4 | import com.twitter.finagle.http.{Status, Request, Response}
5 | import com.twitter.util.Future
6 |
7 |
8 | /**
9 | * NotFoundService just returns 404 Not Found.
10 | */
11 | class NotFoundService[REQUEST <: Request] extends Service[REQUEST, Response] {
12 | def apply(request: REQUEST): Future[Response] = {
13 | val response = request.response
14 | response.status = Status.NotFound
15 | Future.value(response)
16 | }
17 | }
18 |
19 | object NotFoundService extends NotFoundService[Request]
20 |
--------------------------------------------------------------------------------
/finagle-benchmark/src/main/scala/com/twitter/finagle/util/ConcurrentRingBufferBench.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.util
2 |
3 | import com.twitter.finagle.benchmark.StdBenchAnnotations
4 | import org.openjdk.jmh.annotations._
5 |
6 | @State(Scope.Benchmark)
7 | @Threads(Threads.MAX)
8 | class ConcurrentRingBufferBench extends StdBenchAnnotations {
9 |
10 | @Param(Array("1000"))
11 | var size: Int = _
12 |
13 | var b: ConcurrentRingBuffer[Int] = _
14 |
15 | @Setup
16 | def setup() {
17 | b = new ConcurrentRingBuffer[Int](size)
18 | }
19 |
20 | @Benchmark
21 | def timePutAndGet(): Option[Int] = {
22 | b.tryPut(1)
23 | b.tryGet()
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/finagle-exception/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-exception',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/com/fasterxml/jackson/core:jackson-databind',
9 | '3rdparty/jvm/com/fasterxml/jackson/module:jackson-module-scala',
10 | '3rdparty/jvm/org/apache/thrift:thrift-0.5.0',
11 | 'finagle/finagle-core',
12 | 'finagle/finagle-thrift',
13 | 'util/util-app',
14 | 'util/util-codec',
15 | 'util/util-core',
16 | 'finagle/finagle-exception/src/main/thrift:thrift-scala',
17 | ],
18 | sources=rglobs('*.scala'),
19 | )
20 |
--------------------------------------------------------------------------------
/doc/lbdown.pic:
--------------------------------------------------------------------------------
1 | .sp
2 | .PS
3 | maxpswid=100
4 | maxpsht=100
5 | boxwid=1.4
6 | .ps +10
7 |
8 | copy "service.pic"
9 |
10 | Stack: stack
11 | "\s+9............\s-9" ljust with .w at last [].e+(.3,0)
12 |
13 | boxwid=Stack.wid+2
14 | down
15 | box "\fIServiceFactory - LoadBalancer\fP" with .nw at Stack.sw+(0,-.25) thickness 2
16 | move .1
17 | box "\fIConnectTimeout\fP" thickness 2
18 | box "\fIStatsFactory\fP" thickness 2
19 | box "\fITracingFilter\fP" thickness 2
20 | box "\fICodec preparation\fP" thickness 2
21 | box with .nw at Stack.nw+(-.2,.2) ht Stack.ht+5*boxht+.1+.25+.2+.2+.5 wid boxwid+.2+.2 thickness 3
22 | "\fI\s+7ServiceFactory\s-7\fP" with .s at last box .s+(0,.2)
23 | .PE
--------------------------------------------------------------------------------
/doc/src/sphinx/code/quickstart/Client.scala:
--------------------------------------------------------------------------------
1 | import com.twitter.finagle.{Http, Service}
2 | import com.twitter.finagle.http
3 | import com.twitter.util.{Await, Future}
4 |
5 | object Client extends App {
6 | //#builder
7 | val client: Service[http.Request, http.Response] = Http.newService("www.scala-lang.org:80")
8 | //#builder
9 | //#dispatch
10 | val request = http.Request(http.Method.Get, "/")
11 | request.host = "www.scala-lang.org"
12 | val response: Future[http.Response] = client(request)
13 | //#dispatch
14 | //#callback
15 | Await.result(response.onSuccess { rep: http.Response =>
16 | println("GET success: " + rep)
17 | })
18 |
19 | //#callback
20 | }
21 |
--------------------------------------------------------------------------------
/finagle-mux/src/main/scala/com/twitter/finagle/mux/Response.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.mux
2 |
3 | import com.twitter.io.Buf
4 |
5 | /** A mux response. */
6 | sealed trait Response {
7 | /** The payload of the response. */
8 | def body: Buf
9 | }
10 |
11 | object Response {
12 | private case class Impl(body: Buf) extends Response {
13 | override def toString = s"mux.Response.Impl($body)"
14 | }
15 |
16 | val empty: Response = Impl(Buf.Empty)
17 |
18 | def apply(buf: Buf): Response = Impl(buf)
19 | }
20 |
21 | /** For java compatibility */
22 | object Responses {
23 | val empty: Response = Response.empty
24 |
25 | def make(payload: Buf): Response = Response(payload)
26 | }
--------------------------------------------------------------------------------
/finagle-mux/src/test/scala/com/twitter/finagle/mux/Latch.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.mux
2 |
3 | import com.twitter.util.{Future, Promise}
4 |
5 | /**
6 | * A latch is a weak, asynchronous, level-triggered condition
7 | * variable. It does not enforce a locking regime, so users must be
8 | * extra careful to flip() only under lock. It can be used as a kind of
9 | * asynchronous barrier.
10 | */
11 | private class Latch {
12 | @volatile private[this] var p = new Promise[Unit]
13 |
14 | def get: Future[Unit] = p
15 |
16 | def flip(): Unit = {
17 | val oldp = p
18 | p = new Promise[Unit]
19 | oldp.setDone()
20 | }
21 |
22 | def setDone(): Unit = { p.setDone() }
23 | }
--------------------------------------------------------------------------------
/doc/src/sphinx/_themes/flask/relations.html:
--------------------------------------------------------------------------------
1 | Related Topics
2 |
20 |
--------------------------------------------------------------------------------
/finagle-benchmark/src/main/scala/com/twitter/finagle/util/InetAddressUtilBench.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.util
2 |
3 | import com.twitter.finagle.benchmark.StdBenchAnnotations
4 | import com.twitter.finagle.core.util.InetAddressUtil
5 | import java.net.InetAddress
6 | import org.openjdk.jmh.annotations._
7 |
8 | @State(Scope.Benchmark)
9 | @Threads(1)
10 | class InetAddressUtilBench extends StdBenchAnnotations {
11 | val ip = "69.55.236.117"
12 |
13 | @Benchmark
14 | def timeOldInetAddressGetByName(): InetAddress = {
15 | InetAddress.getByName(ip)
16 | }
17 |
18 | @Benchmark
19 | def timeNewInetAddressGetByName(): InetAddress = {
20 | InetAddressUtil.getByName(ip)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/param/WithClientTransport.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.param
2 |
3 | import com.twitter.finagle.Stack
4 |
5 | /**
6 | * Provides the `withTransport` (client's transport) API entry point.
7 | *
8 | * @see [[ClientTransportParams]]
9 | */
10 | trait WithClientTransport[A <: Stack.Parameterized[A]] { self: Stack.Parameterized[A] =>
11 |
12 | /**
13 | * An entry point for configuring the client's [[com.twitter.finagle.transport.Transport]].
14 | *
15 | * `Transport` is a Finagle abstraction over the network connection (i.e., a TCP connection).
16 | */
17 | val withTransport: ClientTransportParams[A] = new ClientTransportParams(self)
18 | }
19 |
--------------------------------------------------------------------------------
/finagle-http/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/com/google/code/findbugs:jsr305',
4 | '3rdparty/jvm/com/google/guava',
5 | '3rdparty/jvm/commons-lang',
6 | '3rdparty/jvm/io/netty',
7 | '3rdparty/jvm/junit',
8 | '3rdparty/jvm/org/mockito:mockito-all',
9 | '3rdparty/jvm/org/scalacheck',
10 | '3rdparty/jvm/org/scalatest',
11 | 'finagle/finagle-core',
12 | 'finagle/finagle-http',
13 | 'util/util-app',
14 | 'util/util-core',
15 | 'util/util-collection',
16 | 'util/util-logging',
17 | 'util/util-stats',
18 | ],
19 | fatal_warnings=True,
20 | strict_deps=True,
21 | sources=rglobs('*.scala')
22 | )
23 |
--------------------------------------------------------------------------------
/pushsite.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 |
4 | set -e
5 |
6 | dir=/tmp/finagle.$$
7 | trap "rm -fr $dir" 0 1 2
8 |
9 | echo 'making site...' 1>&2
10 | ./sbt finagle-doc/make-site >/dev/null 2>&1
11 |
12 | echo 'making unidoc...' 1>&2
13 | ./sbt unidoc >/dev/null 2>&1
14 |
15 | echo 'cloning...' 1>&2
16 | git clone -b gh-pages git@github.com:twitter/finagle.git $dir >/dev/null 2>&1
17 |
18 | savedir=$(pwd)
19 | cd $dir
20 | git rm -fr .
21 | touch .nojekyll
22 | cp $savedir/site/index.html .
23 | cp -r $savedir/target/scala-2.11/unidoc/ docs
24 | cp -r $savedir/doc/target/site guide
25 | git add -f .
26 | git diff-index --quiet HEAD || (git commit -am"site push by $(whoami)"; git push origin gh-pages:gh-pages;)
27 |
--------------------------------------------------------------------------------
/doc/src/sphinx/utils/sbt_versions.py:
--------------------------------------------------------------------------------
1 | import re
2 |
3 | def find_release(file):
4 | """
5 | Attempt to find the library version in an SBT build file.
6 |
7 | Note that the use of a variable named 'libVersion' is only a convention.
8 | """
9 | try:
10 | f = open(file, 'r')
11 | for line in f:
12 | m = re.search('libVersion\s*=\s*"(\d+\.\d+\.\d+)"', line)
13 | if m is not None:
14 | return m.group(1)
15 | return ''
16 | except (OSError, IOError):
17 | return ''
18 |
19 | def release_to_version(release):
20 | """Extract the 'version' from the full release string."""
21 | m = re.search('(\d+\.\d+)\.\d+', release)
22 | return '' if m is None else m.group(1)
23 |
24 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/param/WithServerTransport.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.param
2 |
3 | import com.twitter.finagle.Stack
4 |
5 | /**
6 | * Provides the `withTransport` (server's transport) API entry point.
7 | *
8 | * @see [[ServerTransportParams]]
9 | */
10 | trait WithServerTransport[A <: Stack.Parameterized[A]] { self: Stack.Parameterized[A] =>
11 |
12 | /**
13 | * An entry point for configuring servers' [[com.twitter.finagle.transport.Transport]].
14 | *
15 | * `Transport` is a Finagle abstraction over the network connection (i.e., a TCP connection).
16 | */
17 | val withTransport: ServerTransportParams[A] = new ServerTransportParams(self)
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/finagle-core/src/test/scala/com/twitter/finagle/Echo.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle
2 |
3 | import com.twitter.finagle.client.StringClient
4 | import com.twitter.finagle.server.StringServer
5 | import java.net.SocketAddress
6 |
7 | private[finagle] object Echo
8 | extends Client[String, String] with StringClient
9 | with Server[String, String] with StringServer {
10 |
11 | def serve(addr: SocketAddress, service: ServiceFactory[String, String]) =
12 | stringServer.serve(addr, service)
13 |
14 | def newClient(dest: Name, label: String) =
15 | stringClient.newClient(dest, label)
16 |
17 | def newService(dest: Name, label: String) =
18 | stringClient.newService(dest, label)
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/param/WithSessionQualifier.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.param
2 |
3 | import com.twitter.finagle.Stack
4 |
5 | /**
6 | * Provides the `withSessionQualifier` API entry point.
7 | *
8 | * @see [[SessionQualificationParams]]
9 | */
10 | trait WithSessionQualifier[A <: Stack.Parameterized[A]] { self: Stack.Parameterized[A] =>
11 |
12 | /**
13 | * An entry point for configuring the client's session qualifiers
14 | * (e.g. circuit breakers).
15 | *
16 | * @see [[https://twitter.github.io/finagle/guide/Clients.html#circuit-breaking]]
17 | */
18 | val withSessionQualifier: SessionQualificationParams[A] = new SessionQualificationParams(self)
19 | }
20 |
--------------------------------------------------------------------------------
/finagle-mysql/src/test/java/com/twitter/finagle/mysql/ParameterCompilationTest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.mysql;
2 |
3 | import org.junit.Test;
4 |
5 | import com.twitter.finagle.exp.mysql.Parameter;
6 | import com.twitter.finagle.exp.mysql.Parameters;
7 |
8 | import junit.framework.Assert;
9 |
10 | public final class ParameterCompilationTest {
11 |
12 | /**
13 | * Tests Java usage of the Parameter class/object.
14 | */
15 | @Test
16 | public void testParameter() {
17 | Parameter nullParam = Parameters.nullParameter();
18 | Assert.assertEquals(null, nullParam.value());
19 |
20 | // unsafeWrap
21 | Assert.assertEquals("asdf", Parameters.unsafeWrap("asdf").value());
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/finagle-core/src/test/java/com/twitter/finagle/DtabCompilationTest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle;
2 |
3 | import org.junit.Test;
4 |
5 | /**
6 | * A Java compilation test for Dtab manipulation.
7 | */
8 | public class DtabCompilationTest {
9 | @Test
10 | public void testCompilation() {
11 | Dtab d = Dtab.empty();
12 | d = Dtab.local();
13 | d = Dtab.base();
14 | Dtab.setLocal(d);
15 | Dtab base = Dtab.base();
16 | Dtab.setBase(Dtab.empty());
17 | Dtab.setBase(base);
18 | d = Dtab.local().concat(Dtab.base());
19 | d = Dtab.local().append(Dentry.read("/foo=>/bar"));
20 | Dentry dentry = new Dentry(Dentry.readPrefix("/s/*"), new NameTree.Leaf(Path.read("/a")));
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/finagle-stream/src/main/scala/com/twitter/finagle/stream/package.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle
2 |
3 | /**
4 | * Finagle-stream implements a rather peculiar protocol: it streams
5 | * discrete messages delineated by HTTP chunks. It isn't how we'd design
6 | * a protocol to stream messages, but we are stuck with it for legacy
7 | * reasons.
8 | *
9 | * Finagle-stream sessions are also ``one-shot``: each session handles
10 | * exactly one stream. The session terminates together with the stream.
11 | */
12 | package object stream {
13 | implicit val streamRequestType = new RequestType[StreamRequest] {
14 | def canonize(req: StreamRequest) = req
15 | def specialize(req: StreamRequest) = req
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/finagle-redis/src/test/scala/com/twitter/finagle/redis/commands/list/ListCodecSuite.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.redis.protocol
2 |
3 | import com.twitter.finagle.redis.naggati.RedisRequestTest
4 | import com.twitter.finagle.redis.tags.CodecTest
5 | import org.junit.runner.RunWith
6 | import org.scalatest.junit.JUnitRunner
7 |
8 | @RunWith(classOf[JUnitRunner])
9 | final class ListCodecSuite extends RedisRequestTest {
10 |
11 | test("Correctly encode LPUSH for key value pair", CodecTest) {
12 | unwrap(codec(wrap("LPUSH foo bar\r\n"))) {
13 | case LPush(key, List(value)) => {
14 | assert(chanBuf2String(key) == "foo")
15 | assert(chanBuf2String(value) == "bar")
16 | }
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/finagle-http/src/main/scala/com/twitter/finagle/http/exp/IdentityStreamTransport.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http.exp
2 |
3 | import com.twitter.finagle.transport.Transport
4 | import com.twitter.util.Future
5 |
6 | private[finagle] class IdentityStreamTransport[A, B](self: Transport[A, B])
7 | extends StreamTransportProxy[A, B](self) {
8 | def write(any: A): Future[Unit] = self.write(any)
9 | def read(): Future[Multi[B]] = self.read().map(IdentityStreamTransport.readFn)
10 | }
11 |
12 | private[http] object IdentityStreamTransport {
13 | private[this] val _readFn: Any => Multi[Any] = { item =>
14 | Multi(item, Future.Done)
15 | }
16 |
17 | def readFn[B]: B => Multi[B] = _readFn.asInstanceOf[B => Multi[B]]
18 | }
19 |
--------------------------------------------------------------------------------
/finagle-benchmark/src/main/scala/com/twitter/finagle/NamerBenchmark.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle
2 |
3 | import com.twitter.finagle.benchmark.StdBenchAnnotations
4 | import com.twitter.util.Activity
5 | import org.openjdk.jmh.annotations._
6 |
7 | @State(Scope.Benchmark)
8 | class NamerBenchmark extends StdBenchAnnotations {
9 |
10 | @Param(Array("/$/nil"))
11 | var path: String = "/$/nil"
12 |
13 | private[this] var parsedPath: Path = _
14 |
15 | @Setup(Level.Iteration)
16 | def setup(): Unit = {
17 | val pathParts = path.split('/').drop(1)
18 | parsedPath = Path.Utf8(pathParts: _*)
19 | }
20 |
21 | @Benchmark
22 | def lookup(): Activity[NameTree[Name]] =
23 | Namer.global.lookup(parsedPath)
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/finagle-http/src/test/scala/com/twitter/finagle/http/ProxyCredentialsTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http
2 |
3 | import org.junit.runner.RunWith
4 | import org.scalatest.FunSuite
5 | import org.scalatest.junit.JUnitRunner
6 |
7 | @RunWith(classOf[JUnitRunner])
8 | class ProxyCredentialsTest extends FunSuite {
9 | test("add Proxy-Authorization header") {
10 | val creds = ProxyCredentials("foo", "bar")
11 | assert(creds.basicAuthorization == "Basic Zm9vOmJhcg==")
12 | }
13 |
14 | test("construct via Map") {
15 | val creds = ProxyCredentials(Map(
16 | "http_proxy_user" -> "foo",
17 | "http_proxy_pass" -> "bar"
18 | )).get
19 | assert(creds.basicAuthorization == "Basic Zm9vOmJhcg==")
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/finagle-mysql/src/test/java/com/twitter/finagle/mysql/ClientCompilationTest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.mysql;
2 |
3 | import org.junit.Test;
4 |
5 | import com.twitter.finagle.exp.Mysql;
6 | import com.twitter.finagle.exp.Mysql.Client;
7 | import com.twitter.finagle.param.Label;
8 |
9 | public final class ClientCompilationTest {
10 |
11 | /**
12 | * Tests Java usage of the Mysql client. The client API should be as accessible in Java as it is
13 | * in Scala.
14 | */
15 | @Test
16 | public void testClientCompilation() {
17 | final Client client = Mysql.client()
18 | .withDatabase("random-db")
19 | .configured(new Label("test").mk())
20 | .withCredentials("user", "password");
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/project/plugins.sbt:
--------------------------------------------------------------------------------
1 | resolvers += Classpaths.sbtPluginReleases
2 | resolvers += "twitter-repo" at "https://maven.twttr.com"
3 |
4 | val branch = Process("git" :: "rev-parse" :: "--abbrev-ref" :: "HEAD" :: Nil).!!.trim
5 | val scroogeSbtPluginVersionPrefix = "4.7.0"
6 | val scroogeSbtPluginVersion =
7 | if (branch == "master") scroogeSbtPluginVersionPrefix
8 | else scroogeSbtPluginVersionPrefix + "-SNAPSHOT"
9 | addSbtPlugin("com.twitter" % "scrooge-sbt-plugin" % scroogeSbtPluginVersion)
10 |
11 | addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.8.1")
12 | addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.0.0")
13 | addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.2.0")
14 | addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.2")
15 |
--------------------------------------------------------------------------------
/finagle-mysql/src/test/scala/com/twitter/finagle/mysql/unit/transport/PacketTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.exp.mysql.transport
2 |
3 | import org.junit.runner.RunWith
4 | import org.scalatest.FunSuite
5 | import org.scalatest.junit.JUnitRunner
6 |
7 | @RunWith(classOf[JUnitRunner])
8 | class PacketTest extends FunSuite {
9 | val seq = 2.toShort
10 | val bytes = Array[Byte](0x01, 0x02, 0x03, 0x04)
11 | val body = Buffer(bytes)
12 | val packet = Packet(seq, body)
13 |
14 | test("Encode a Packet") {
15 | val buf = Buffer.fromChannelBuffer(packet.toChannelBuffer)
16 | val br = BufferReader(buf)
17 | assert(bytes.size == br.readInt24())
18 | assert(seq == br.readByte())
19 | assert(bytes === br.takeRest())
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/service/ReqRep.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.service
2 |
3 | import com.twitter.util.Try
4 |
5 | /**
6 | * Represents a request/response pair.
7 | *
8 | * For some protocols, like HTTP, these types are what you'd expect —
9 | * `com.twitter.finagle.http.Request` and `com.twitter.finagle.http.Response`.
10 | * While for other protocols that may not be the case. Please review
11 | * the protocol's
12 | * "com.twitter.finagle.$protocol.service.$ProtocolResponseClassifier"
13 | * for details.
14 | *
15 | * @see `com.twitter.finagle.http.service.HttpResponseClassifier`
16 | * @see `com.twitter.finagle.thriftmux.service.ThriftMuxResponseClassifier`
17 | */
18 | case class ReqRep(request: Any, response: Try[Any])
19 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/service/ServiceFactoryRef.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.service
2 |
3 | import com.twitter.finagle.{ServiceFactoryProxy, ServiceFactory}
4 | import com.twitter.util.Updatable
5 |
6 | /**
7 | * An updatable service factory proxy.
8 | *
9 | * @param init The starting factory to proxy to
10 | */
11 | private[finagle] class ServiceFactoryRef[Req, Rep](
12 | init: ServiceFactory[Req, Rep]
13 | ) extends ServiceFactoryProxy[Req, Rep](init) with Updatable[ServiceFactory[Req, Rep]] {
14 | @volatile private[this] var cur: ServiceFactory[Req, Rep] = init
15 |
16 | def update(newFactory: ServiceFactory[Req, Rep]) {
17 | cur = newFactory
18 | }
19 |
20 | override def self: ServiceFactory[Req, Rep] = cur
21 | }
22 |
--------------------------------------------------------------------------------
/finagle-memcached/src/main/scala/com/twitter/finagle/memcached/util/AtomicMap.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.memcached.util
2 |
3 | import scala.collection.mutable
4 |
5 | /**
6 | * Improve concurrency with fine-grained locking. A hash of synchronized hash
7 | * tables, keyed on the request key.
8 | */
9 | class AtomicMap[A, B](maps: Seq[mutable.Map[A, B]]) {
10 | def this(concurrencyLevel: Int) = this {
11 | (0 until concurrencyLevel) map { i => mutable.Map[A, B]() }
12 | }
13 | def this() = this(16)
14 |
15 | private[this] val concurrencyLevel = maps.size
16 |
17 | def lock[C](key: A)(f: mutable.Map[A, B] => C) = {
18 | val map = maps((key.hashCode % concurrencyLevel).abs)
19 | f.synchronized {
20 | f(map)
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/finagle-toggle/src/test/scala/com/twitter/finagle/toggle/NullToggleMapTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.toggle
2 |
3 | import org.junit.runner.RunWith
4 | import org.scalacheck.Arbitrary.arbitrary
5 | import org.scalatest.FunSuite
6 | import org.scalatest.junit.JUnitRunner
7 | import org.scalatest.prop.GeneratorDrivenPropertyChecks
8 |
9 | @RunWith(classOf[JUnitRunner])
10 | class NullToggleMapTest extends FunSuite
11 | with GeneratorDrivenPropertyChecks {
12 |
13 | private val IntGen = arbitrary[Int]
14 |
15 | test("apply") {
16 | val toggle = NullToggleMap("hi")
17 | forAll(IntGen) { i =>
18 | assert(!toggle.isDefinedAt(i))
19 | }
20 | }
21 |
22 | test("iterator") {
23 | assert(NullToggleMap.iterator.isEmpty)
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/finagle-serversets/src/test/scala/com/twitter/finagle/serverset2/client/ZooKeeperClientTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.serverset2.client
2 |
3 | import org.junit.runner.RunWith
4 | import org.scalatest.junit.JUnitRunner
5 | import org.scalatest.FunSuite
6 |
7 | @RunWith(classOf[JUnitRunner])
8 | class ZooKeeperClientTest extends FunSuite {
9 | test("ZooKeeperReader.patToPathAndPrefix") {
10 | import ZooKeeperReader.{patToPathAndPrefix=>p}
11 |
12 | intercept[IllegalArgumentException] { p("") }
13 | intercept[IllegalArgumentException] { p("foo/bar") }
14 |
15 | assert(p("/") == (("/", "")))
16 | assert(p("/foo") == (("/", "foo")))
17 | assert(p("/foo/bar") == (("/foo", "bar")))
18 | assert(p("/foo/bar/") == (("/foo/bar", "")))
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-core',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/com/google/guava',
9 | '3rdparty/jvm/com/twitter:jsr166e',
10 | '3rdparty/jvm/io/netty',
11 | '3rdparty/jvm/commons-codec:commons-codec',
12 | 'util/util-app',
13 | 'util/util-cache',
14 | 'util/util-codec',
15 | 'util/util-collection',
16 | 'util/util-core/src/main/scala:scala',
17 | 'util/util-hashing',
18 | 'util/util-jvm',
19 | 'util/util-lint',
20 | 'util/util-logging',
21 | 'util/util-registry',
22 | 'util/util-stats',
23 | ],
24 | strict_deps=True,
25 | sources=rglobs('*.scala'),
26 | )
27 |
--------------------------------------------------------------------------------
/finagle-memcached/src/test/java/com/twitter/finagle/MemcachedCompilationTest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle;
2 |
3 | import org.junit.Test;
4 |
5 | import com.twitter.finagle.memcached.Client;
6 | import com.twitter.finagle.param.Label;
7 | import com.twitter.hashing.KeyHashers;
8 |
9 | public class MemcachedCompilationTest {
10 |
11 | /**
12 | * Tests Java usage of the Memcached client. The client API should be as accessible in Java as it
13 | * is in Scala.
14 | */
15 | @Test
16 | public void testClientCompilation() {
17 | final Client client = Memcached.client()
18 | .withKeyHasher(KeyHashers.FNV1_32())
19 | .configured(new Label("test").mk())
20 | .withEjectFailedHost(true)
21 | .newRichClient("localhost:11211");
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/finagle-http/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-http',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/com/google/code/findbugs:jsr305',
9 | '3rdparty/jvm/com/google/guava',
10 | '3rdparty/jvm/com/twitter/bijection:core',
11 | '3rdparty/jvm/commons-lang',
12 | '3rdparty/jvm/io/netty',
13 | '3rdparty/jvm/org/apache/commons:commons-codec',
14 | 'finagle/finagle-core',
15 | 'util/util-app',
16 | 'util/util-codec',
17 | 'util/util-collection',
18 | 'util/util-core',
19 | 'util/util-logging',
20 | 'util/util-stats',
21 | ],
22 | strict_deps=True,
23 | fatal_warnings=True,
24 | sources=rglobs('*.scala'),
25 | )
26 |
--------------------------------------------------------------------------------
/finagle-mux/src/main/java/com/twitter/finagle/mux/FailureDetectors.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.mux;
2 |
3 | /**
4 | * A Java adaptation of the {@link com.twitter.finagle.mux.FailureDetector} companion object.
5 | */
6 | public final class FailureDetectors {
7 | private FailureDetectors() { }
8 |
9 | /**
10 | * Default config type for {FailureDetector}
11 | *
12 | * @see FailureDetector$#globalFlagConfig
13 | */
14 | public static final FailureDetector.Config GLOBAL_FLAG_CONFIG =
15 | FailureDetector.GlobalFlagConfig$.MODULE$;
16 |
17 | /**
18 | * Null config type for {FailureDetector}
19 | *
20 | * @see FailureDetector$#nullConfig
21 | */
22 | public static final FailureDetector.Config NULL_CONFIG =
23 | FailureDetector.NullConfig$.MODULE$;
24 | }
25 |
--------------------------------------------------------------------------------
/finagle-core/src/test/scala/com/twitter/finagle/service/ServiceTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.service
2 |
3 | import org.scalatest.FunSuite
4 | import org.scalatest.junit.JUnitRunner
5 | import org.junit.runner.RunWith
6 | import com.twitter.finagle.Service
7 | import com.twitter.util.TimeConversions._
8 | import com.twitter.util.{Throw, Await, Try, Future}
9 |
10 | @RunWith(classOf[JUnitRunner])
11 | class ServiceTest extends FunSuite {
12 | test("Service should rescue") {
13 | val e = new RuntimeException("yargs")
14 | val exceptionThrowingService = new Service[Int, Int] {
15 | def apply(request: Int) = {
16 | throw e
17 | }
18 | }
19 |
20 | assert(Try(Await.result(Service.rescue(exceptionThrowingService)(1), 1.second)) == Throw(e))
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/finagle-thriftmux/src/test/scala/com/twitter/finagle/thriftmux/ThriftIfaceTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.thriftmux
2 |
3 | import com.twitter.finagle.ThriftMux
4 | import com.twitter.util.{Future, Try}
5 | import org.junit.runner.RunWith
6 | import org.scalatest.FunSuite
7 | import org.scalatest.junit.{AssertionsForJUnit, JUnitRunner}
8 |
9 | @RunWith(classOf[JUnitRunner])
10 | class ThriftIfaceTest extends FunSuite with AssertionsForJUnit {
11 | test("invalid thrift ifaces") {
12 | trait FakeThriftIface {
13 | def query(x: String): Future[String]
14 | }
15 |
16 | intercept[IllegalArgumentException] {
17 | ThriftMux.server.serveIface(
18 | "localhost:*",
19 | new FakeThriftIface { def query(x: String) = Future.value(x) })
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/doc/src/sphinx/_templates/searchbox.html:
--------------------------------------------------------------------------------
1 | {#
2 | basic/searchbox.html
3 | ~~~~~~~~~~~~~~~~~~~~
4 |
5 | Note: we override this to change the blurb.
6 | #}
7 | {%- if pagename != "search" %}
8 |
9 |
{{ _('Quick search') }}
10 |
16 |
17 | {{ _('Search the contents of this site.') }}
18 |
19 |
20 |
21 | {%- endif %}
--------------------------------------------------------------------------------
/doc/src/sphinx/_themes/flask_small/layout.html:
--------------------------------------------------------------------------------
1 | {% extends "basic/layout.html" %}
2 | {% block header %}
3 | {{ super() }}
4 | {% if pagename == 'index' %}
5 |
6 | {% endif %}
7 | {% endblock %}
8 | {% block footer %}
9 | {% if pagename == 'index' %}
10 |
11 | {% endif %}
12 | {% endblock %}
13 | {# do not display relbars #}
14 | {% block relbar1 %}{% endblock %}
15 | {% block relbar2 %}
16 | {% if theme_github_fork %}
17 |
19 | {% endif %}
20 | {% endblock %}
21 | {% block sidebar1 %}{% endblock %}
22 | {% block sidebar2 %}{% endblock %}
23 |
--------------------------------------------------------------------------------
/finagle-cacheresolver/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-cacheresolver',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/com/google/code/gson',
9 | '3rdparty/jvm/org/apache/zookeeper:zookeeper-client',
10 | 'science/src/java/com/twitter/common/io:io',
11 | 'science/src/java/com/twitter/common/quantity:quantity',
12 | 'science/src/java/com/twitter/common/zookeeper:client',
13 | 'science/src/java/com/twitter/common/zookeeper:server-set',
14 | 'finagle/finagle-core',
15 | 'finagle/finagle-serversets',
16 | 'util/util-core'
17 | ],
18 | sources=rglobs('*.scala'),
19 | resources=[
20 | 'finagle/finagle-cacheresolver/src/main/resources'
21 | ]
22 | )
23 |
--------------------------------------------------------------------------------
/doc/src/sphinx/metrics/FailureAccrual.rst:
--------------------------------------------------------------------------------
1 | FailureAccrualFactory
2 | <<<<<<<<<<<<<<<<<<<<<
3 |
4 |
5 | **removed_for_ms**
6 | A counter of the total time in milliseconds any host has spent in dead
7 | state due to failure accrual.
8 |
9 | **probes**
10 | A counter of the number of requests sent through failure accrual while
11 | a host was marked dead to probe for revival.
12 |
13 | **removals**
14 | A count of how many times any host has been removed due to failure
15 | accrual. Note that there is no specificity on which host in the
16 | cluster has been removed, so a high value here could be one
17 | problem-child or aggregate problems across all hosts.
18 |
19 | **revivals**
20 | A count of how many times a previously-removed host has been
21 | reactivated after the penalty period has elapsed.
22 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/param/WithConcurrentLoadBalancer.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.param
2 |
3 | import com.twitter.finagle.Stack
4 |
5 | /**
6 | * Provides the `withLoadBalancer` (concurrent balancer) API entry point.
7 | *
8 | * @see [[ConcurrentLoadBalancingParams]]
9 | */
10 | trait WithConcurrentLoadBalancer[A <: Stack.Parameterized[A]] { self: Stack.Parameterized[A] =>
11 |
12 | /**
13 | * An entry point for configuring the client's load balancer that implements
14 | * a strategy for choosing one host/node from a replica set to service
15 | * a request.
16 | *
17 | * @see [[https://twitter.github.io/finagle/guide/Clients.html#load-balancing]]
18 | */
19 | val withLoadBalancer: ConcurrentLoadBalancingParams[A] = new ConcurrentLoadBalancingParams(self)
20 | }
21 |
--------------------------------------------------------------------------------
/finagle-mdns/src/main/scala/com/twitter/finagle/mdns/Local.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.mdns
2 |
3 | import com.twitter.finagle.{Announcement, Announcer, Addr, Resolver, Name}
4 | import com.twitter.util.{Future, Try, Var}
5 | import java.net.{InetSocketAddress, SocketAddress}
6 |
7 | private object Local {
8 | def mkAddr(name: String) = "mdns!" + name + "._finagle._tcp.local."
9 | }
10 |
11 | class LocalAnnouncer extends Announcer {
12 | val scheme = "local"
13 |
14 | def announce(ia: InetSocketAddress, addr: String): Future[Announcement] =
15 | Announcer.announce(ia, Local.mkAddr(addr))
16 | }
17 |
18 | class LocalResolver extends Resolver {
19 | val scheme = "local"
20 |
21 | def bind(arg: String): Var[Addr]= {
22 | val Name.Bound(va) = Resolver.eval(Local.mkAddr(arg))
23 | va
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/finagle-http/src/test/scala/com/twitter/finagle/http/EmptyParamMapTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http
2 |
3 | import org.junit.runner.RunWith
4 | import org.scalatest.FunSuite
5 | import org.scalatest.junit.JUnitRunner
6 |
7 | @RunWith(classOf[JUnitRunner])
8 | class EmptyParamMapTest extends FunSuite {
9 |
10 | test("isValid") {
11 | assert(EmptyParamMap.isValid == true)
12 | }
13 |
14 | test("get") {
15 | assert(EmptyParamMap.get("key") == None)
16 | }
17 |
18 | test("getAll") {
19 | assert(EmptyParamMap.getAll("key").isEmpty == true)
20 | }
21 |
22 | test("+") {
23 | val map = EmptyParamMap + ("key" -> "value")
24 | assert(map.get("key") == Some("value"))
25 | }
26 |
27 | test("-") {
28 | val map = EmptyParamMap - "key"
29 | assert(map.get("key") == None)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/finagle-serversets/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-serversets',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/com/fasterxml/jackson/core:jackson-core',
9 | '3rdparty/jvm/com/fasterxml/jackson/core:jackson-databind',
10 | 'science/src/java/com/twitter/common/zookeeper:client',
11 | 'science/src/java/com/twitter/common/zookeeper:server-set',
12 | 'science/src/thrift/com/twitter/thrift:thrift-java',
13 | '3rdparty/jvm/org/slf4j:slf4j-api',
14 | 'finagle/finagle-core',
15 | 'util/util-cache',
16 | 'util/util-core',
17 | 'util/util-zk-common'
18 | ],
19 | sources=rglobs('*.scala'),
20 | resources=[
21 | 'finagle/finagle-serversets/src/main/resources'
22 | ],
23 | )
24 |
--------------------------------------------------------------------------------
/finagle-zipkin/src/main/scala/BUILD:
--------------------------------------------------------------------------------
1 | scala_library(name='scala',
2 | provides = scala_artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-zipkin',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/com/fasterxml/jackson/core:jackson-core',
9 | '3rdparty/jvm/com/fasterxml/jackson/core:jackson-databind',
10 | '3rdparty/jvm/com/fasterxml/jackson/module:jackson-module-scala',
11 | '3rdparty/jvm/org/apache/thrift:thrift-0.5.0',
12 | 'finagle/finagle-core',
13 | 'finagle/finagle-thrift',
14 | 'finagle/finagle-zipkin/src/main/thrift:thrift-scala',
15 | 'util/util-app',
16 | 'util/util-codec',
17 | 'util/util-core',
18 | 'util/util-events',
19 | ],
20 | sources=rglobs('*.scala'),
21 | resources=[
22 | 'finagle/finagle-zipkin/src/main/resources'
23 | ],
24 | )
25 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/stats/CancelledCategorizer.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.stats
2 |
3 | import com.twitter.finagle.{CancelledConnectionException, CancelledRequestException}
4 | import com.twitter.util.Throwables.RootCause
5 |
6 | /**
7 | * Matcher for Throwables caused by some form of cancellation.
8 | */
9 | object CancelledCategorizer {
10 | val Cancelled = "cancelled"
11 |
12 | def unapply(exc: Throwable): Option[Throwable] = {
13 | exc match {
14 | case t: CancelledRequestException => Some(t)
15 | case t: CancelledConnectionException => Some(t)
16 | case RootCause(CancelledCategorizer(t)) => Some(t)
17 | case _ => None
18 | }
19 | }
20 |
21 | val Instance: PartialFunction[Throwable, String] = {
22 | case CancelledCategorizer(_) => Cancelled
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/finagle-serversets/src/main/scala/com/twitter/finagle/serverset2/client/EventDeliveryThread.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.serverset2.client
2 |
3 | import java.util.concurrent.LinkedBlockingDeque
4 | import com.twitter.util.{Monitor, Updatable}
5 |
6 | private[client] object EventDeliveryThread
7 | extends Thread("com.twitter.zookeeper.client.internal event delivery") {
8 | private val q = new LinkedBlockingDeque[(Updatable[WatchState], WatchState)]
9 |
10 | def offer(u: Updatable[WatchState], s: WatchState) {
11 | q.offer((u, s))
12 | }
13 |
14 | override def run() {
15 | while (true) {
16 | val (u, s) = q.take()
17 | try {
18 | u() = s
19 | } catch {
20 | case exc: Throwable => Monitor.handle(exc)
21 | }
22 | }
23 | }
24 |
25 | setDaemon(true)
26 | start()
27 | }
28 |
--------------------------------------------------------------------------------
/finagle-core/src/test/java/com/twitter/finagle/NamerCompilationTest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle;
2 |
3 | import org.junit.Assert;
4 | import org.junit.Test;
5 |
6 | import com.twitter.util.Activities;
7 | import com.twitter.util.Activity;
8 |
9 |
10 | public class NamerCompilationTest {
11 |
12 | private static class IdNamer extends AbstractNamer {
13 | public Activity> lookup(Path path) {
14 | return Activities.newValueActivity(
15 | (NameTree) new NameTree.Leaf(Name$.MODULE$.apply("/asdf")));
16 | }
17 | }
18 |
19 | @Test
20 | public void testIdNamerImplementation() {
21 | IdNamer idNamer = new IdNamer();
22 | Assert.assertEquals(
23 | new NameTree.Leaf(Name$.MODULE$.apply("/asdf")),
24 | idNamer.lookup(Path.read("/asdf")).sample());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/finagle-mux/src/main/scala/com/twitter/finagle/mux/lease/exp/GenerationalRandom.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.mux.lease.exp
2 |
3 | import scala.util.Random
4 |
5 | /**
6 | * A random number generation that is consistent in the same garbage collection.
7 | * However, if there has been an interstitial garbage collection since the last
8 | * time the generator was used, the random number will be recomputed.
9 | */
10 | private[lease] class GenerationalRandom private[lease](info: JvmInfo, rand: Random) {
11 | def this(info: JvmInfo) = this(info, new Random())
12 |
13 | private var last = rand.nextInt().abs
14 | private var gen = info.generation()
15 |
16 | def apply() = synchronized {
17 | if (gen != info.generation()) {
18 | gen = info.generation()
19 | last = rand.nextInt().abs
20 | }
21 | last
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/finagle-thrift/src/test/scala/BUILD:
--------------------------------------------------------------------------------
1 | junit_tests(name='scala',
2 | dependencies=[
3 | '3rdparty/jvm/junit',
4 | '3rdparty/jvm/org/mockito:mockito-all',
5 | '3rdparty/jvm/io/netty',
6 | '3rdparty/jvm/org/scalatest',
7 | '3rdparty/jvm/org/apache/thrift:thrift-0.5.0',
8 | 'finagle/finagle-core',
9 | 'finagle/finagle-thrift',
10 | 'finagle/finagle-thrift/src/test/java',
11 | 'finagle/finagle-thrift/src/test/thrift:thrift-java',
12 | 'finagle/finagle-thrift/src/test/thrift:thrift-scala',
13 | 'util/util-core',
14 |
15 | ':silly-thrift-dep',
16 | ],
17 | resources=[
18 | 'finagle/finagle-thrift/src/test/resources',
19 | ],
20 | sources=rglobs('*.scala')
21 | )
22 |
23 | jar_library(name='silly-thrift-dep',
24 | jars=[
25 | jar(org='silly', name='silly-thrift', rev='0.5.0'),
26 | ],
27 | )
28 |
--------------------------------------------------------------------------------
/finagle-mux/src/main/scala/com/twitter/finagle/mux/lease/exp/GarbageCollectorAddable.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.mux.lease.exp
2 |
3 | import java.lang.management.GarbageCollectorMXBean
4 |
5 | class GarbageCollectorAddable(self: GarbageCollectorMXBean) {
6 | def +(other: GarbageCollectorMXBean): GarbageCollectorMXBean = new GarbageCollectorMXBean {
7 | def getCollectionCount() =
8 | self.getCollectionCount() + other.getCollectionCount()
9 | def getCollectionTime() =
10 | self.getCollectionTime() + other.getCollectionTime()
11 | def getMemoryPoolNames() =
12 | Array.concat(self.getMemoryPoolNames(), other.getMemoryPoolNames())
13 | def getName() = self.getName() + "+" + other.getName()
14 | def isValid() = self.isValid || other.isValid
15 | def getObjectName = throw new UnsupportedOperationException
16 | }
17 | }
--------------------------------------------------------------------------------
/finagle-mux/src/main/scala/com/twitter/finagle/mux/stats/MuxCancelledCategorizer.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.mux.stats
2 |
3 | import com.twitter.finagle.mux.ClientDiscardedRequestException
4 | import com.twitter.finagle.stats.CancelledCategorizer
5 | import com.twitter.util.Throwables.RootCause
6 |
7 | /**
8 | * Matcher for Throwables caused by a ClientDiscardedRequestException.
9 | */
10 | object MuxCancelledCategorizer {
11 | def unapply(exc: Throwable): Option[ClientDiscardedRequestException] = {
12 | exc match {
13 | case t: ClientDiscardedRequestException => Some(t)
14 | case RootCause(MuxCancelledCategorizer(t)) => Some(t)
15 | case _ => None
16 | }
17 | }
18 |
19 | val Instance: PartialFunction[Throwable, String] = {
20 | case MuxCancelledCategorizer(_) => CancelledCategorizer.Cancelled
21 | }
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/finagle-redis/src/test/scala/com/twitter/finagle/redis/commands/server/ServerClientServerIntegrationSuite.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.redis.integration
2 |
3 | import com.twitter.finagle.redis.naggati.RedisClientServerIntegrationTest
4 | import com.twitter.finagle.redis.protocol._
5 | import com.twitter.finagle.redis.tags.{ClientServerTest, RedisTest}
6 | import com.twitter.util.Await
7 | import org.junit.Ignore
8 | import org.junit.runner.RunWith
9 | import org.scalatest.junit.JUnitRunner
10 |
11 | @Ignore
12 | @RunWith(classOf[JUnitRunner])
13 | final class ServerClientServerIntegrationSuite extends RedisClientServerIntegrationTest {
14 |
15 | test("FLUSHALL should return a StatusReply(\"OK\")", ClientServerTest, RedisTest) {
16 | withRedisClient { client =>
17 | assert(Await.result(client(FlushAll)) == OKStatusReply)
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/finagle-zipkin/src/test/scala/com/twitter/finagle/zipkin/thrift/AnnotationTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.zipkin.thrift
2 |
3 | import org.scalatest.FunSuite
4 | import com.twitter.util.Time
5 | import org.scalatest.junit.JUnitRunner
6 | import org.junit.runner.RunWith
7 |
8 | @RunWith(classOf[JUnitRunner])
9 | class AnnotationTest extends FunSuite {
10 | test("ZipkinAnnotation should serialize properly") {
11 | val ann = ZipkinAnnotation(Time.fromSeconds(123), "value", Endpoint(123, 123))
12 | val tann = ann.toThrift
13 |
14 | assert(tann.isSetHost)
15 | assert(tann.host.ipv4 == ann.endpoint.ipv4)
16 | assert(tann.host.port == ann.endpoint.port)
17 | assert(tann.isSetValue)
18 | assert(tann.value == ann.value)
19 | assert(tann.isSetTimestamp)
20 | assert(tann.timestamp == ann.timestamp.inMicroseconds)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/finagle-core/src/test/scala/com/twitter/finagle/netty3/NumWorkersTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.netty3
2 |
3 | import org.junit.runner.RunWith
4 |
5 | import org.scalatest.FunSpec
6 | import org.scalatest.junit.JUnitRunner
7 |
8 | @RunWith(classOf[JUnitRunner])
9 | class NumWorkersTest extends FunSpec {
10 | describe("numWorkers") {
11 | it("should have 2 * the number of available processors according to the runtime by default") {
12 | assert(System.getProperty("com.twitter.jvm.numProcs") == null)
13 | assert(numWorkers() == Runtime.getRuntime().availableProcessors() * 2)
14 | }
15 |
16 | it("should be settable as a flag") {
17 | val old = numWorkers()
18 | numWorkers.parse("20")
19 |
20 | assert(numWorkers() == 20)
21 |
22 | numWorkers.parse()
23 | assert(numWorkers() == old)
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/finagle-core/src/test/java/com/twitter/finagle/client/StatsScopingCompilationTest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.client;
2 |
3 | import scala.collection.immutable.Map;
4 |
5 | import org.junit.Test;
6 |
7 | import com.twitter.finagle.stats.StatsReceiver;
8 | import com.twitter.util.Function2;
9 |
10 | /**
11 | * Just a compilation test for Java.
12 | */
13 | public class StatsScopingCompilationTest {
14 | @Test
15 | public void testRetryFilter() {
16 | Function2, StatsReceiver> datfunk =
17 | new Function2, StatsReceiver>() {
18 | @Override
19 | public StatsReceiver apply(StatsReceiver stats, Map meta) {
20 | return stats;
21 | }
22 | };
23 |
24 | StatsScoping.Scoper scoper = new StatsScoping.Scoper(datfunk);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/finagle-example/src/main/java/BUILD:
--------------------------------------------------------------------------------
1 | java_library(name='java',
2 | provides = artifact(
3 | org = 'com.twitter',
4 | name = 'finagle-example-java',
5 | repo = artifactory,
6 | ),
7 | dependencies=[
8 | '3rdparty/jvm/io/netty',
9 | 'finagle/finagle-core',
10 | 'finagle/finagle-example/src/main/thrift:thrift-scala',
11 | 'finagle/finagle-http',
12 | 'finagle/finagle-kestrel',
13 | 'finagle/finagle-thrift',
14 | 'util/util-core',
15 | ],
16 | fatal_warnings=False,
17 | sources=rglobs('*.java')
18 | )
19 |
20 | jvm_binary(name='thrift-server',
21 | main='com.twitter.finagle.example.java.thrift.ThriftServer',
22 | dependencies=[
23 | ':java'
24 | ]
25 | )
26 |
27 | jvm_binary(name='thrift-client',
28 | main='com.twitter.finagle.example.java.thrift.ThriftClient',
29 | dependencies=[
30 | ':java'
31 | ]
32 | )
33 |
--------------------------------------------------------------------------------
/finagle-mysql/src/test/scala/com/twitter/finagle/mysql/unit/MockService.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.exp.mysql
2 |
3 | import com.twitter.finagle.{ClientConnection, ServiceFactory, Service}
4 | import com.twitter.util.{Time, Future}
5 |
6 | /**
7 | * Mock objects for testing.
8 | */
9 | class MockService extends Service[Request, Result] {
10 | var requests = List[Request]()
11 | val resultSet = new ResultSet(fields=Seq(), rows=Seq())
12 |
13 | def apply(request: Request): Future[Result] = {
14 | requests = requests ++ List(request)
15 | Future.value(resultSet)
16 | }
17 | }
18 |
19 | class MockServiceFactory(service: Service[Request, Result]) extends ServiceFactory[Request, Result] {
20 | def apply(conn: ClientConnection): Future[Service[Request, Result]] = Future.value(service)
21 | def close(deadline: Time): Future[Unit] = Future.Unit
22 | }
23 |
--------------------------------------------------------------------------------
/finagle-netty4-http/src/main/scala/com/twitter/finagle/netty4/http/TextualContentCompressor.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.netty4.http
2 |
3 | import com.twitter.finagle.http.codec.TextualContentCompressor.isTextual
4 | import io.netty.handler.codec.http._
5 | import io.netty.handler.codec.http.HttpContentEncoder.Result
6 |
7 | /**
8 | * Custom compressor that only handles text-like content-types with the default
9 | * compression level.
10 | */
11 | private[http] class TextualContentCompressor extends HttpContentCompressor {
12 |
13 | override def beginEncode(response: HttpResponse, acceptEncoding: String): Result = {
14 | response.headers.get(HttpHeaderNames.CONTENT_TYPE) match {
15 | case ct if ct != null && isTextual(ct) => super.beginEncode(response, acceptEncoding)
16 | case _ => null // null return value skips compression
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/finagle-core/src/test/java/com/twitter/finagle/AddressCompilationTest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle;
2 |
3 | import java.net.InetSocketAddress;
4 | import java.util.Map;
5 |
6 | import com.google.common.collect.Maps;
7 |
8 | import org.junit.Assert;
9 | import org.junit.Test;
10 |
11 | public class AddressCompilationTest {
12 |
13 | @Test
14 | public void testInet() {
15 | InetSocketAddress ia = new InetSocketAddress(0);
16 |
17 | Address a = Addresses.newInetAddress(ia);
18 | Assert.assertNotNull(a);
19 |
20 | Map meta = Maps.newHashMap();
21 | meta.put("foo", "bar");
22 | Address b = Addresses.newInetAddress(ia, meta);
23 | Assert.assertNotNull(b);
24 | }
25 |
26 | @Test
27 | public void testFailed() {
28 | Address a = Addresses.newFailedAddress(new Exception("boo"));
29 | Assert.assertNotNull(a);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/finagle-http/src/test/java/com/twitter/finagle/http/HttpMuxerCompilationTest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http;
2 |
3 | import org.junit.Test;
4 |
5 | import com.twitter.finagle.Service;
6 | import com.twitter.util.Function;
7 | import com.twitter.util.Future;
8 |
9 | /** Compilation tests for HttpMuxer */
10 | public class HttpMuxerCompilationTest {
11 |
12 | /** a comment */
13 | @Test
14 | public void testHttpMuxer() {
15 | HttpMuxers.apply(Request.apply("http://192.168.0.1/"));
16 |
17 | HttpMuxers.patterns();
18 |
19 | HttpMuxer.addHandler(
20 | "com/twitter/finagle/http/HttpMuxerCompilationTest",
21 | Service.mk(new Function>() {
22 | @Override
23 | public Future apply(Request req) {
24 | return Future.value(Response.apply());
25 | }
26 | }));
27 |
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/finagle-mux/src/main/scala/com/twitter/finagle/mux/lease/exp/GarbageCollector.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.mux.lease.exp
2 |
3 | import java.util.logging.Level
4 |
5 | private[lease] object GarbageCollector {
6 | private val log = java.util.logging.Logger.getLogger("GarbageCollector")
7 |
8 | val forceNewGc: () => Unit = try {
9 | // This is a method present in Twitter's JVMs to force
10 | // a minor collection.
11 | val meth = Class.forName("com.twitter.hotspot.System").getMethod("minorGc")
12 | log.log(Level.INFO, "Found com.twitter.hotspot.System.minorGc")
13 | () => meth.invoke(null)
14 | } catch {
15 | case exc: ClassNotFoundException =>
16 | log.log(
17 | Level.INFO,
18 | "Failed to resolve com.twitter.hotspot.System; falling "+
19 | "back to full GC",
20 | exc)
21 | () => System.gc()
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/param/ClientAdmissionControlParams.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.param
2 |
3 | import com.twitter.finagle.Stack
4 | import com.twitter.finagle.service.PendingRequestFilter
5 |
6 | /**
7 | * A collection of methods for configuring the admission control modules of Finagle clients.
8 | *
9 | * @tparam A a [[Stack.Parameterized]] client to configure
10 | */
11 | class ClientAdmissionControlParams[A <: Stack.Parameterized[A]](self: Stack.Parameterized[A]) {
12 |
13 | /**
14 | * Configures a limit on the maximum number of outstanding requests per
15 | * connection. Default is no limit.
16 | */
17 | def maxPendingRequests(requestLimit: Int): A = {
18 | val lim =
19 | if (requestLimit == Int.MaxValue) None
20 | else Some(requestLimit)
21 |
22 | self.configured(PendingRequestFilter.Param(limit = lim))
23 | }
24 | }
--------------------------------------------------------------------------------
/finagle-core/src/test/scala/com/twitter/finagle/socks/SocksProxyFlagsTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.socks
2 |
3 | import org.junit.runner.RunWith
4 | import org.scalatest.{BeforeAndAfter, FunSuite}
5 | import org.scalatest.junit.JUnitRunner
6 | import java.net.InetSocketAddress
7 |
8 | @RunWith(classOf[JUnitRunner])
9 | class SocksProxyFlagsTest extends FunSuite with BeforeAndAfter {
10 |
11 | test("SocksProxyFlags should respect -socksProxyHost / -socksProxyPort flags") {
12 | val port = 80 // never bound
13 | socksProxyHost.let("localhost") {
14 | socksProxyPort.let(port) {
15 | assert(SocksProxyFlags.socksProxy == Some(new InetSocketAddress("localhost", port)))
16 | }
17 | }
18 | }
19 |
20 | test("SocksProxyFlags should respect missing -socksProxyHost / -socksProxyPort flags") {
21 | assert(SocksProxyFlags.socksProxy == None)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/finagle-http/src/main/scala/com/twitter/finagle/http/ProxyCredentials.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http
2 |
3 | import com.twitter.util.Base64StringEncoder
4 | import scala.collection.JavaConversions._
5 |
6 | object ProxyCredentials {
7 | def apply(credentials: java.util.Map[String, String]): Option[ProxyCredentials] =
8 | apply(credentials.toMap)
9 |
10 | def apply(credentials: Map[String, String]): Option[ProxyCredentials] = {
11 | for {
12 | user <- credentials.get("http_proxy_user")
13 | pass <- credentials.get("http_proxy_pass")
14 | } yield {
15 | ProxyCredentials(user, pass)
16 | }
17 | }
18 | }
19 |
20 | case class ProxyCredentials(username: String, password: String) {
21 | lazy val basicAuthorization = {
22 | val bytes = "%s:%s".format(username, password).getBytes
23 | "Basic " + Base64StringEncoder.encode(bytes)
24 | }
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/finagle-http/src/main/scala/com/twitter/finagle/http/ResponseProxy.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http
2 |
3 | import org.jboss.netty.handler.codec.http.HttpResponse
4 |
5 | abstract class ResponseProxy extends Response {
6 | def response: Response
7 | override def isRequest = response.isRequest
8 | override def status: Status = response.status
9 | override def status_=(value: Status) = response.status_=(value)
10 | override def statusCode: Int = response.statusCode
11 | override def statusCode_=(value: Int) = response.statusCode_=(value)
12 | override def getStatusCode(): Int = response.getStatusCode()
13 | override def setStatusCode(value: Int) = response.setStatusCode(value)
14 | override def encodeString(): String = response.encodeString()
15 |
16 | protected[finagle] def httpResponse: HttpResponse = response.httpResponse
17 | }
18 |
--------------------------------------------------------------------------------
/finagle-redis/src/test/java/com/twitter/finagle/redis/TestCodec.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.redis;
2 |
3 | import org.jboss.netty.channel.ChannelPipelineFactory;
4 |
5 | import com.twitter.finagle.ClientCodecConfig;
6 | import com.twitter.finagle.Codec;
7 | import com.twitter.finagle.ServerCodecConfig;
8 | import com.twitter.finagle.redis.protocol.Command;
9 | import com.twitter.finagle.redis.protocol.Reply;
10 | import com.twitter.util.Function;
11 |
12 | /**
13 | * A compilation test for extending the Redis codec in java.
14 | */
15 |
16 | public class TestCodec extends Redis {
17 |
18 | public Function> client() {
19 | return null;
20 | }
21 |
22 | public Function> server() {
23 | return null;
24 | }
25 |
26 | public ChannelPipelineFactory pipelineFactory() {
27 | return null;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/finagle-core/src/test/scala/com/twitter/finagle/builder/ClusterInt.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.builder
2 |
3 | import com.twitter.concurrent.Spool
4 | import com.twitter.util.{Return, Promise}
5 | import collection.mutable
6 |
7 | case class WrappedInt(val value: Int)
8 |
9 | class ClusterInt extends Cluster[Int] {
10 | var set = mutable.HashSet.empty[Int]
11 | var changes = new Promise[Spool[Cluster.Change[Int]]]
12 |
13 | def add(value: Int) = {
14 | set += value
15 | performChange(Cluster.Add(value))
16 | }
17 |
18 | def del(value: Int) = {
19 | set -= value
20 | performChange(Cluster.Rem(value))
21 | }
22 |
23 | private[this] def performChange(change: Cluster.Change[Int]) = {
24 | val newTail = new Promise[Spool[Cluster.Change[Int]]]
25 | changes() = Return(change *:: newTail)
26 | changes = newTail
27 | }
28 |
29 | def snap = (set.toSeq, changes)
30 | }
31 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/service/ConstantService.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.service
2 |
3 | import com.twitter.util.Future
4 | import com.twitter.finagle.{NoStacktrace, Service, Status}
5 |
6 | /**
7 | * A [[com.twitter.finagle.Service]] that returns a constant result.
8 | */
9 | class ConstantService[Req, Rep](reply: Future[Rep]) extends Service[Req, Rep] {
10 | def apply(request: Req): Future[Rep] = reply
11 | }
12 |
13 | /**
14 | * A [[com.twitter.finagle.Service]] that fails with a constant Throwable.
15 | */
16 | class FailedService(failure: Throwable)
17 | extends ConstantService[Any, Nothing](Future.exception(failure))
18 | {
19 | override def status: Status = Status.Closed
20 | }
21 |
22 | /**
23 | * A static [[FailedService]] object.
24 | */
25 | object NilService
26 | extends FailedService(
27 | new Exception("dispatch to invalid service") with NoStacktrace)
28 |
--------------------------------------------------------------------------------
/finagle-http/src/main/scala/com/twitter/finagle/http/RequestProxy.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http
2 |
3 | import com.twitter.io.{Writer, Reader}
4 | import com.twitter.util.Closable
5 | import org.jboss.netty.handler.codec.http.HttpRequest
6 |
7 | /**
8 | * Proxy for Request. This can be used to create a richer request class
9 | * that wraps Request without exposing the underlying netty http type.
10 | */
11 | abstract class RequestProxy extends Request {
12 | def request: Request
13 |
14 | override def ctx = request.ctx
15 |
16 | protected[finagle] def httpRequest: HttpRequest = request.httpRequest
17 |
18 |
19 | override def reader: Reader = request.reader
20 | override def writer: Writer with Closable = request.writer
21 |
22 | override def params = request.params
23 | def remoteSocketAddress = request.remoteSocketAddress
24 |
25 | override lazy val response = request.response
26 | }
27 |
--------------------------------------------------------------------------------
/finagle-mux/src/test/java/com/twitter/finagle/StackParameterCompilationTest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle;
2 |
3 | import com.twitter.finagle.builder.ClientBuilder;
4 | import com.twitter.finagle.client.StackClient;
5 | import com.twitter.finagle.mux.FailureDetector;
6 | import com.twitter.finagle.mux.FailureDetectors;
7 | import com.twitter.util.Duration;
8 |
9 | public class StackParameterCompilationTest {
10 | void testParams() {
11 | StackClient client =
12 | ClientBuilder.stackClientOfCodec(null)
13 | .configured(new FailureDetector.Param(FailureDetectors.GLOBAL_FLAG_CONFIG).mk())
14 | .configured(new FailureDetector.Param(FailureDetectors.NULL_CONFIG).mk())
15 | .configured(
16 | new FailureDetector.Param(
17 | new FailureDetector.ThresholdConfig(Duration.Top(), 2, 5, Duration.Top())).mk());
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/finagle-mux/src/test/scala/com/twitter/finagle/mux/WindowedMaxTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.mux
2 |
3 | import org.junit.runner.RunWith
4 | import org.scalacheck.Gen
5 | import org.scalacheck.Prop.forAll
6 | import org.scalatest.FunSuite
7 | import org.scalatest.junit.JUnitRunner
8 | import org.scalatest.prop.Checkers
9 |
10 | @RunWith(classOf[JUnitRunner])
11 | class WindowedMaxTest extends FunSuite with Checkers {
12 | test("return max") {
13 | check {
14 | forAll { ary: Array[Long] =>
15 | forAll(Gen.posNum[Int]) { window: Int =>
16 | val w = new WindowedMax(window)
17 | for (v <- ary) w.add(v)
18 |
19 | val expected =
20 | if (ary.isEmpty) Long.MinValue
21 | else if (window > ary.length) ary.max
22 | else ary.takeRight(window).max
23 |
24 | expected == w.get
25 | }
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/finagle-core/src/test/scala/com/twitter/finagle/integration/DynamicCluster.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.integration
2 |
3 | import com.twitter.finagle.builder.Cluster
4 | import com.twitter.concurrent.Spool
5 | import com.twitter.util.{Return, Promise}
6 |
7 | class DynamicCluster[U](initial: Seq[U])
8 | extends Cluster[U] {
9 |
10 | def this() = this(Seq[U]())
11 |
12 | var set = initial.toSet
13 | var s = new Promise[Spool[Cluster.Change[U]]]
14 |
15 | def add(f: U) = {
16 | set += f
17 | performChange(Cluster.Add(f))
18 | }
19 |
20 | def del(f: U) = {
21 | set -= f
22 | performChange(Cluster.Rem(f))
23 | }
24 |
25 |
26 | private[this] def performChange(change: Cluster.Change[U]) = synchronized {
27 | val newTail = new Promise[Spool[Cluster.Change[U]]]
28 | s() = Return(change *:: newTail)
29 | s = newTail
30 | }
31 |
32 | def snap = (set.toSeq, s)
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/finagle-mysql/src/main/scala/com/twitter/finagle/mysql/PreparedStatement.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.exp.mysql
2 |
3 | import com.twitter.util.Future
4 |
5 | /**
6 | * A PreparedStatement represents a parameterized
7 | * sql statement which may be applied concurrently
8 | * with varying parameters.
9 | */
10 | trait PreparedStatement {
11 | /**
12 | * Executes the prepared statement with the
13 | * given `params`.
14 | */
15 | def apply(params: Parameter*): Future[Result]
16 |
17 | /**
18 | * Executes the prepared statement with the
19 | * given `params` and maps `f` to the rows
20 | * of the returned ResultSet. If no ResultSet
21 | * is returned, the function returns an empty Seq.
22 | */
23 | def select[T](params: Parameter*)(f: Row => T): Future[Seq[T]] =
24 | apply(params: _*) map {
25 | case rs: ResultSet => rs.rows.map(f)
26 | case _ => Nil
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/finagle-ostrich4/src/main/scala/com/twitter/finagle/builder/ServerBuilderToTwitterService.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.builder
2 |
3 | /**
4 | * Make a com.twitter.ostrich.admin.Service from a finagle ServerBuilder.
5 | */
6 |
7 | import com.twitter.ostrich.admin
8 | import com.twitter.util.Duration
9 | import com.twitter.conversions.time._
10 |
11 | import com.twitter.finagle.Service
12 |
13 | class ServerBuildertoTwitterService[Req, Rep](
14 | builder: ServerBuilder[Req, Rep, ServerConfig.Yes, ServerConfig.Yes, ServerConfig.Yes],
15 | service: Service[Req, Rep],
16 | gracePeriod: Duration = 10.seconds)
17 | extends admin.Service
18 | {
19 | private[this] var server: Option[Server] = None
20 |
21 | def start() {
22 | if (!server.isDefined)
23 | server = Some(builder.build(service))
24 | }
25 |
26 | def shutdown() {
27 | server foreach { _.close(gracePeriod) }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/param/WithSession.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.param
2 |
3 | import com.twitter.finagle.Stack
4 |
5 | /**
6 | * Provides the `withSession` API entry point.
7 | *
8 | * @see [[SessionParams]]
9 | */
10 | trait WithSession[A <: Stack.Parameterized[A]] { self: Stack.Parameterized[A] =>
11 |
12 | /**
13 | * An entry point for configuring the client's sessions.
14 | *
15 | * Session might be viewed as logical connection that wraps a physical connection
16 | * (i.e., [[com.twitter.finagle.transport.Transport transport]]) and controls its
17 | * lifecycle. Sessions are used in Finagle to maintain liveness, requests cancellation,
18 | * draining, and many more.
19 | *
20 | * The default setup for a Finagle client's sessions is to not put any
21 | * timeouts on it.
22 | */
23 | val withSession: SessionParams[A] = new SessionParams(self)
24 | }
25 |
--------------------------------------------------------------------------------
/finagle-core/src/test/java/com/twitter/finagle/stats/JavaStatsReceiverTest.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.stats;
2 |
3 | import org.junit.Test;
4 |
5 | public class JavaStatsReceiverTest {
6 |
7 | @Test
8 | public void testLoadedStatsReceiver() {
9 | StatsReceiver stats = LoadedStatsReceiver.self();
10 | }
11 |
12 | @Test
13 | public void testDefaultStatsReceiver() {
14 | StatsReceiver stats = DefaultStatsReceiver.self();
15 | StatsReceiver stats2 = DefaultStatsReceiver.get();
16 | }
17 |
18 | @Test
19 | public void testClientStatsReceiver() {
20 | StatsReceiver stats = ClientStatsReceiver.self();
21 | }
22 |
23 | @Test
24 | public void testServerStatsReceiver() {
25 | StatsReceiver stats = ServerStatsReceiver.self();
26 | }
27 |
28 | @Test
29 | public void testLoadedHostStatsReceiver() {
30 | StatsReceiver stats = LoadedHostStatsReceiver.self();
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/finagle-http2/src/main/scala/com/twitter/finagle/http2/Http2Listener.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http2
2 |
3 | import com.twitter.finagle.Stack
4 | import com.twitter.finagle.netty4.Netty4Listener
5 | import com.twitter.finagle.server.Listener
6 | import io.netty.channel.{ChannelHandler, ChannelPipeline}
7 |
8 | /**
9 | * Please note that the listener cannot be used for TLS yet.
10 | */
11 | private[http2] object Http2Listener {
12 | private[this] val init: ChannelPipeline => Unit = { pipeline: ChannelPipeline =>
13 | pipeline.addLast(new Http2ServerDowngrader())
14 | }
15 |
16 | def apply[In, Out](params: Stack.Params): Listener[In, Out] = Netty4Listener(
17 | // we turn off backpressure because Http2 only works with autoread on for now
18 | params + Netty4Listener.BackPressure(false),
19 | init,
20 | handlerDecorator = { handler: ChannelHandler => new Http2ServerInitializer(handler) })
21 | }
22 |
--------------------------------------------------------------------------------
/finagle-mux/src/main/scala/com/twitter/finagle/mux/Request.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.mux
2 |
3 | import com.twitter.io.Buf
4 | import com.twitter.finagle.Path
5 |
6 | /** A mux request. */
7 | sealed trait Request {
8 | /** The destination name specified by Tdispatch requests. Otherwise, Path.empty */
9 | def destination: Path
10 |
11 | /** The payload of the request. */
12 | def body: Buf
13 | }
14 |
15 | object Request {
16 | private case class Impl(destination: Path, body: Buf) extends Request {
17 | override def toString = s"mux.Request.Impl($destination, $body)"
18 | }
19 |
20 | val empty: Request = Impl(Path.empty, Buf.Empty)
21 |
22 | def apply(dst: Path, payload: Buf): Request = Impl(dst, payload)
23 | }
24 |
25 | /** For java compatibility */
26 | object Requests {
27 | val empty: Request = Request.empty
28 |
29 | def make(dst: Path, payload: Buf): Request = Request(dst, payload)
30 | }
--------------------------------------------------------------------------------
/finagle-mysql/src/test/scala/com/twitter/finagle/mysql/ParameterTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.mysql
2 |
3 | import com.twitter.finagle.exp.mysql.Parameter
4 | import com.twitter.finagle.exp.mysql.Parameter.NullParameter
5 | import org.junit.runner.RunWith
6 | import org.scalatest.FunSuite
7 | import org.scalatest.junit.JUnitRunner
8 |
9 | @RunWith(classOf[JUnitRunner])
10 | class ParameterTest extends FunSuite {
11 | test("Parameter coercion") {
12 | locally {
13 | val x: Parameter = null
14 | assert(x == null)
15 | }
16 |
17 | locally {
18 | val y: String = null
19 | val x: Parameter = y
20 | assert(x == NullParameter)
21 | }
22 |
23 | locally {
24 | val x: Parameter = "Howdy"
25 | assert(x.value == "Howdy")
26 | }
27 | }
28 |
29 | test("Parameter.unsafeWrap(null)") {
30 | assert(Parameter.unsafeWrap(null) == NullParameter)
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/finagle-http/src/main/scala/com/twitter/finagle/http/MediaType.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http
2 |
3 | object MediaType {
4 | // Common media types
5 | val Atom = "application/atom+xml"
6 | val Csv = "application/csv"
7 | val Gif = "image/gif"
8 | val Html = "text/html"
9 | val Iframe = "application/iframe"
10 | val Javascript = "application/javascript"
11 | val Jpeg = "image/jpeg"
12 | val Json = "application/json"
13 | val OctetStream = "application/octet-stream"
14 | val PlainText = "text/plain"
15 | val Png = "image/png"
16 | val Rss = "application/rss+xml"
17 | val Txt = "text/plain"
18 | val WwwForm = "application/x-www-form-urlencoded"
19 | val Xls = "application/vnd.ms-excel"
20 | val Xml = "application/xml"
21 | val Zip = "application/zip"
22 | }
23 |
--------------------------------------------------------------------------------
/finagle-mux/src/test/java/com/twitter/finagle/UseMux.java:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle;
2 |
3 | import com.twitter.finagle.mux.Request;
4 | import com.twitter.finagle.mux.Requests;
5 | import com.twitter.finagle.mux.Response;
6 | import com.twitter.finagle.mux.Responses;
7 | import com.twitter.io.Bufs;
8 | import com.twitter.util.Future;
9 |
10 | // A compilation test for the Mux API.
11 | public class UseMux {
12 | static {
13 | ServiceFactory client = Mux.newClient(":8080");
14 |
15 | Mux.serve("localhost:*", new Service() {
16 | public Future apply(Request req) {
17 | return Future.value(Responses.empty());
18 | }
19 | });
20 |
21 | Request request = Requests.empty();
22 | request = Requests.make(Path.empty(), Bufs.EMPTY);
23 |
24 | Response response = Responses.empty();
25 | response = Responses.make(Bufs.EMPTY);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/factory/RefcountedFactory.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.factory
2 |
3 | import com.twitter.finagle.{ServiceFactory, ServiceFactoryProxy, ClientConnection}
4 | import com.twitter.finagle.service.RefcountedService
5 |
6 | /**
7 | * A [[com.twitter.finagle.ServiceFactoryProxy]] that wraps all
8 | * [[com.twitter.finagle.Service Services]] created by the argument
9 | * [[com.twitter.finagle.ServiceFactory]] in
10 | * [[com.twitter.finagle.RefcountedService RefcountedServices]].
11 | *
12 | * In essence, this factory is used to guarantee that services delay closure
13 | * until all outstanding requests have been completed.
14 | */
15 | private[finagle] class RefcountedFactory[Req, Rep](
16 | self: ServiceFactory[Req, Rep]
17 | ) extends ServiceFactoryProxy(self) {
18 | override def apply(conn: ClientConnection) =
19 | super.apply(conn) map { new RefcountedService(_) }
20 | }
21 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/netty3/channel/IdleChannelHandler.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.netty3.channel
2 |
3 | import com.twitter.finagle.stats.StatsReceiver
4 | import org.jboss.netty.channel.ChannelHandlerContext
5 | import org.jboss.netty.handler.timeout.{IdleState, IdleStateAwareChannelHandler, IdleStateEvent}
6 |
7 | /**
8 | * This handler closes a channel if it receives an IDLE event.
9 | */
10 | class IdleChannelHandler(receiver: StatsReceiver) extends IdleStateAwareChannelHandler {
11 | private[this] val statsReceiver = receiver.scope("disconnects")
12 |
13 | override def channelIdle(ctx: ChannelHandlerContext, e: IdleStateEvent) {
14 | val state = e.getState
15 | if (state == IdleState.READER_IDLE || state == IdleState.WRITER_IDLE) {
16 | statsReceiver.counter(state.toString).incr()
17 | e.getChannel.close()
18 | }
19 |
20 | super.channelIdle(ctx, e)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/tracing/ClientRequestTracingFilter.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.tracing
2 |
3 | import com.twitter.finagle.{Service, SimpleFilter}
4 |
5 | /**
6 | * Adds the basic tracing information to a request.
7 | * Includes: rpc service name, method name, client sent and client received.
8 | */
9 | trait ClientRequestTracingFilter[Req, Res] extends SimpleFilter[Req, Res] {
10 | def apply(
11 | request: Req,
12 | service: Service[Req, Res]
13 | ) = {
14 | if (Trace.isActivelyTracing) {
15 | Trace.recordServiceName(serviceName)
16 | Trace.recordRpc(methodName(request))
17 | Trace.record(Annotation.ClientSend())
18 |
19 | service(request) onSuccess { _ =>
20 | Trace.record(Annotation.ClientRecv())
21 | }
22 | }
23 | else
24 | service(request)
25 | }
26 |
27 | val serviceName: String
28 | def methodName(req: Req): String
29 | }
30 |
--------------------------------------------------------------------------------
/finagle-thriftmux/src/main/scala/com/twitter/finagle/ThriftMuxUtil.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle
2 |
3 | private object ThriftMuxUtil {
4 | val role = Stack.Role("ProtocolRecorder")
5 |
6 | def classForName(name: String) =
7 | try Class.forName(name) catch {
8 | case cause: ClassNotFoundException =>
9 | throw new IllegalArgumentException("Iface is not a valid thrift iface", cause)
10 | }
11 |
12 | val protocolRecorder: Stackable[ServiceFactory[mux.Request, mux.Response]] =
13 | new Stack.Module1[param.Stats, ServiceFactory[mux.Request, mux.Response]] {
14 | val role = ThriftMuxUtil.role
15 | val description = "Record ThriftMux protocol usage"
16 | def make(_stats: param.Stats, next: ServiceFactory[mux.Request, mux.Response]) = {
17 | val param.Stats(stats) = _stats
18 | stats.scope("protocol").provideGauge("thriftmux")(1)
19 | next
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/service/OptionallyServableFilter.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.service
2 |
3 | import com.twitter.finagle.{NotServableException, SimpleFilter, Service}
4 | import com.twitter.util.Future
5 |
6 | /**
7 | * A [[com.twitter.finagle.Filter]] that uses an argument function to predicate
8 | * whether or not to apply the subsequent [[com.twitter.finagle.Service]]. In
9 | * cases where the function returns false, a the filter fails with a
10 | * [[com.twitter.finagle.NotServableException]].
11 | */
12 | class OptionallyServableFilter[Req, Rep](f: Req => Future[Boolean])
13 | extends SimpleFilter[Req, Rep]
14 | {
15 | private[this] val notServableException = new NotServableException
16 |
17 | def apply(req: Req, service: Service[Req, Rep]) = {
18 | f(req) flatMap {
19 | case true => service(req)
20 | case false => Future.exception(notServableException)
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/finagle-core/src/test/scala/com/twitter/finagle/tracing/TracingLogHandlerTest.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.tracing
2 |
3 | import com.twitter.finagle.tracing.Annotation.Message
4 | import com.twitter.logging.{Level, LogRecord}
5 | import org.scalatest.{BeforeAndAfter, FunSuite}
6 | import org.junit.runner.RunWith
7 | import org.scalatest.junit.JUnitRunner
8 |
9 | @RunWith(classOf[JUnitRunner])
10 | class TracingLogHandlerTest extends FunSuite with BeforeAndAfter {
11 | test("TracingLogHandler: send messages to Tracer") {
12 | val tracer = new BufferingTracer()
13 | Trace.letTracer(tracer) {
14 | val handler = new TracingLogHandler
15 | val msg1 = "hello"
16 | handler.publish(new LogRecord(Level.DEBUG, msg1))
17 |
18 | tracer.iterator.next().annotation match {
19 | case Message(s) => assert(s.trim == msg1)
20 | case _ => fail("Message does not match")
21 | }
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/finagle-core/src/main/java/com/twitter/finagle/service/ResponseClasses.java:
--------------------------------------------------------------------------------
1 | /* Copyright 2015 Twitter, Inc. */
2 | package com.twitter.finagle.service;
3 |
4 | /**
5 | * Java APIs for {@link ResponseClass}.
6 | */
7 | public final class ResponseClasses {
8 |
9 | private ResponseClasses() {
10 | throw new IllegalStateException();
11 | }
12 |
13 | /**
14 | * See {@link ResponseClass$#Success()}
15 | */
16 | public static final ResponseClass.Successful SUCCESS =
17 | ResponseClass$.MODULE$.Success();
18 |
19 | /**
20 | * See {@link ResponseClass$#NonRetryableFailure()}
21 | */
22 | public static final ResponseClass.Failed NON_RETRYABLE_FAILURE =
23 | ResponseClass$.MODULE$.NonRetryableFailure();
24 |
25 | /**
26 | * See {@link ResponseClass$#RetryableFailure()}
27 | */
28 | public static final ResponseClass.Failed RETRYABLE_FAILURE =
29 | ResponseClass$.MODULE$.RetryableFailure();
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/finagle-http/src/main/scala/com/twitter/finagle/http/codec/AnnotateCipher.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.http.codec
2 |
3 | import org.jboss.netty.channel.{ChannelHandlerContext, MessageEvent, SimpleChannelHandler}
4 | import org.jboss.netty.handler.codec.http.HttpRequest
5 | import org.jboss.netty.handler.ssl.SslHandler
6 |
7 | /**
8 | * Extract the cipher from the SslHandler and set it as a header on the HTTP
9 | * request befor sending it upstream.
10 | */
11 | private[http]
12 | class AnnotateCipher(headerName: String) extends SimpleChannelHandler {
13 | override def messageReceived(ctx: ChannelHandlerContext, e: MessageEvent) {
14 | (e.getMessage, ctx.getPipeline.get(classOf[SslHandler])) match {
15 | case (req: HttpRequest, ssl: SslHandler) =>
16 | req.headers.set(headerName, ssl.getEngine().getSession().getCipherSuite())
17 | case _ =>
18 | ()
19 | }
20 |
21 | super.messageReceived(ctx, e)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/service/RefcountedService.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.service
2 |
3 | import com.twitter.finagle.{Service, ServiceProxy}
4 | import com.twitter.finagle.util.AsyncLatch
5 | import com.twitter.util.{Future, Promise, Time}
6 |
7 | /**
8 | * A [[com.twitter.finagle.Service]] that delays closure until all outstanding
9 | * requests have been completed.
10 | */
11 | private[finagle] class RefcountedService[Req, Rep](underlying: Service[Req, Rep])
12 | extends ServiceProxy[Req, Rep](underlying)
13 | {
14 | protected[this] val replyLatch = new AsyncLatch
15 |
16 | override def apply(request: Req) = {
17 | replyLatch.incr()
18 | underlying(request) ensure { replyLatch.decr() }
19 | }
20 |
21 | override final def close(deadline: Time): Future[Unit] = {
22 | val p = new Promise[Unit]
23 | replyLatch.await {
24 | p.become(underlying.close(deadline))
25 | }
26 | p
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/finagle-mux/src/test/scala/com/twitter/finagle/mux/lease/exp/LocalConductors.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.mux.lease.exp
2 |
3 | import com.twitter.util.Local
4 | import org.scalatest.concurrent.{IntegrationPatience, Conductors}
5 |
6 | trait LocalConductors extends Conductors with IntegrationPatience {
7 |
8 | def localThread(conductor: Conductor)(fn: => Unit): Unit = {
9 | val outer = Local.save()
10 | conductor.thread {
11 | val saved = Local.save()
12 | Local.restore(outer)
13 | try {
14 | fn
15 | } finally {
16 | Local.restore(saved)
17 | }
18 | }
19 | }
20 |
21 | def localWhenFinished(conductor: Conductor)(fn: => Unit): Unit = {
22 | val outer = Local.save()
23 | conductor.whenFinished {
24 | val saved = Local.save()
25 | Local.restore(outer)
26 | try {
27 | fn
28 | } finally {
29 | Local.restore(saved)
30 | }
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/finagle-mysql/src/test/resources/data.sql:
--------------------------------------------------------------------------------
1 | # swimming records
2 | INSERT INTO swimming_record (id, event, time, name, nationality, date) VALUES (1, "50 m freestyle", 20.91, "Cesar Cielo", "Brazil", "2009-12-18");
3 | INSERT INTO swimming_record (id, event, time, name, nationality, date) VALUES (2, "100 m freestyle", 46.91, "Cesar Cielo", "Brazil", "2009-08-02");
4 | INSERT INTO swimming_record (id, event, time, name, nationality, date) VALUES (3, "50 m backstroke", 24.04, "Liam Tancock", "Great Britain", "2009-08-02");
5 | INSERT INTO swimming_record (id, event, time, name, nationality, date) VALUES (4, "100 m backstroke", 51.94, "Aaron Peirsol", "United States", "2009-07-08");
6 | INSERT INTO swimming_record (id, event, time, name, nationality, date) VALUES (5, "50 m butterfly", 22.43, "Rafael Munoz", "Spain", "2009-05-05");
7 | INSERT INTO swimming_record (id, event, time, name, nationality, date) VALUES (6, "100 m butterfly", 49.82, "Michael Phelps", "United States", "2009-07-29");
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/loadbalancer/NodeT.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.loadbalancer
2 |
3 | import com.twitter.finagle.ServiceFactory
4 |
5 | /**
6 | * The base type of nodes over which load is balanced.
7 | * Nodes define the load metric that is used; distributors
8 | * like P2C will use these to decide where to balance
9 | * the next request.
10 | */
11 | protected[loadbalancer] trait NodeT[Req, Rep] extends ServiceFactory[Req, Rep] {
12 | type This
13 |
14 | /**
15 | * The current load, in units of the active metric.
16 | */
17 | def load: Double
18 |
19 | /**
20 | * The number of pending requests to this node.
21 | */
22 | def pending: Int
23 |
24 | /**
25 | * A token is a random integer identifying the node.
26 | * It persists through node updates.
27 | */
28 | def token: Int
29 |
30 | /**
31 | * The underlying service factory.
32 | */
33 | def factory: ServiceFactory[Req, Rep]
34 | }
35 |
--------------------------------------------------------------------------------
/finagle-core/src/main/scala/com/twitter/finagle/naming/DefaultInterpreter.scala:
--------------------------------------------------------------------------------
1 | package com.twitter.finagle.naming
2 |
3 | import com.twitter.finagle._
4 | import com.twitter.util.Activity
5 |
6 | /**
7 | * Interpret names against the Dtab, using the default evaluation
8 | * strategy. Recursively look up and rewrite paths according to entries
9 | * matching the path prefix in the Dtab. If a path does not match any
10 | * Dtab entry prefix, the global Namer is invoked to resolve it. This is
11 | * how paths starting with `/$/` are bound.
12 | */
13 | object DefaultInterpreter extends NameInterpreter {
14 |
15 | override def bind(dtab: Dtab, path: Path): Activity[NameTree[Name.Bound]] = {
16 | def lookup(path: Path): Activity[NameTree[Name]] =
17 | dtab.lookup(path) match {
18 | case NameTree.Neg => Namer.global.lookup(path)
19 | case t => Activity.value(t)
20 | }
21 |
22 | Namer.bind(lookup, NameTree.Leaf(path))
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/finagle-native/src/test/resources/setup-chain/setup_intermediate.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | cd sslCA
4 |
5 | # now make the intermediate
6 | if [ ! -d ca2012 ]; then
7 | mkdir ca2012
8 | fi
9 |
10 | cp ../openssl-intermediate.conf ca2012/openssl.conf
11 | cd ca2012
12 |
13 | for d in certs private newcerts; do
14 | if [ ! -d $d ]; then
15 | mkdir $d
16 | fi
17 | done
18 |
19 | if [ ! -f serial ]; then
20 | echo 1000 > serial
21 | fi
22 |
23 | touch index.txt
24 |
25 | # request and sign the request
26 | echo "=== generate intermediate key ==="
27 | openssl genrsa -des3 -out private/cakey.pem 2048
28 | openssl req -new -sha1 -key private/cakey.pem -out ca2012.csr -config openssl.conf
29 |
30 | echo "=== sign intermediate key ==="
31 | mv ca2012.csr ..
32 | cd ..
33 | openssl ca -extensions v3_ca -days 1825 -out ca2012.crt -in ca2012.csr -config openssl.conf
34 |
35 | # move all the keys back to the ca2012 dir, and we're done.
36 | mv ca2012.csr ca2012.crt ca2012
37 |
--------------------------------------------------------------------------------