https://github.com/akka/akka/issues/25429: add direction & throttler instances accessors to ThrottlerTransportAdapter module. add java compile only tests. (#25465)

This commit is contained in:
Vladimir Leletko 2018-08-13 06:35:59 +03:00 committed by Konrad `ktoso` Malawski
parent 545160e107
commit 973e8bfa23
2 changed files with 51 additions and 0 deletions

View file

@ -165,6 +165,31 @@ object ThrottlerTransportAdapter {
*/
def getInstance = this
}
/**
* Java API: get the Direction.Send instance
*/
def sendDirection() = Direction.Send
/**
* Java API: get the Direction.Receive instance
*/
def receiveDirection() = Direction.Receive
/**
* Java API: get the Direction.Both instance
*/
def bothDirection() = Direction.Both
/**
* Java API: get the ThrottleMode.Blackhole instance
*/
def blackholeThrottleMode() = Blackhole
/**
* Java API: get the ThrottleMode.Unthrottled instance
*/
def unthrottledThrottleMode() = Unthrottled
}
class ThrottlerTransportAdapter(_wrappedTransport: Transport, _system: ExtendedActorSystem) extends ActorTransportAdapter(_wrappedTransport, _system) {

View file

@ -0,0 +1,26 @@
/*
* Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
*/
package akka.remote.transport;
// compile only; verify java interop
public class ThrottlerTransportAdapterTest {
public void compileThrottlerTransportAdapterDirections() {
acceptDirection(ThrottlerTransportAdapter.bothDirection());
acceptDirection(ThrottlerTransportAdapter.receiveDirection());
acceptDirection(ThrottlerTransportAdapter.sendDirection());
}
public void compleThrottleMode() {
acceptThrottleMode(ThrottlerTransportAdapter.unthrottledThrottleMode());
acceptThrottleMode(ThrottlerTransportAdapter.blackholeThrottleMode());
acceptThrottleMode(new ThrottlerTransportAdapter.TokenBucket(0, 0.0, 0, 0));
}
void acceptDirection(ThrottlerTransportAdapter.Direction dir) {}
void acceptThrottleMode(ThrottlerTransportAdapter.ThrottleMode mode) {}
}