nl.grons.sentries.examples.SentryExampleApp

Example2

class Example2 extends SentrySupport

Load balancer example.

In this example we'll show the load balancer support. The default load balancer requires you to implement 'resources' that returns all available resources. When this is not dynamic, simply implement 'resources' as a val (as done in this example).

Upon invoking the load balancer it randomly picks one of the given resources and tries to use it. When a NotAvailable exception is caught, the next resource is attempted.

If the resource throws any other error, the error is simply rethrown and not further attempt to invoke another resource is done.

Linear Supertypes
SentrySupport, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Example2
  2. SentrySupport
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Example2()

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def callService(param: String): Int

    Here we use the load balancer.

    Here we use the load balancer.

    Note that the code block will be executed in the context of the resource's sentry. Note that the code might be invoked multiple times when a NotAvailableException is caught in the load balancer.

    You can also use this fact to your advantage; if inside the code block it becomes clear that another resource should be called, explicitly throw a NotAvailableException and the load balancer will invoke the next resource.

  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  9. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  11. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  12. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  13. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  14. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  15. val loadBalancer: LoadBalancer[SimpleExampleService] { ... /* 2 definitions in type refinement */ }

    LoadBalancer is abstract and requires us to implement 'resources'.

  16. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. final def notify(): Unit

    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  19. def sentry(resourceName: String): SentryBuilder

    Returns a new sentry builder with the current class as owner.

    Returns a new sentry builder with the current class as owner.

    Definition Classes
    SentrySupport
  20. def sentryRegistry: SentriesRegistry

    Returns the default SentriesRegistry.

    Returns the default SentriesRegistry. Override to use another.

    Definition Classes
    SentrySupport
  21. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  22. def toString(): String

    Definition Classes
    AnyRef → Any
  23. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  24. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  25. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from SentrySupport

Inherited from AnyRef

Inherited from Any

Ungrouped