Class

org.scalawag.timber.backend.receiver

StackableReceiver

Related Doc: package receiver

Permalink

class StackableReceiver extends Receiver

A Receiver that allows the core behavior (what the receiver does) to be stacked with a BufferingPolicy and a ConcurrencyPolicy, provided by timber.

You can take advantage of the policy stacking in two ways. You can either create your receivers as extensions of Receiver and then instantiate them like this:

import org.scalawag.timber.api._
import org.scalawag.timber.backend.receiver._
import org.scalawag.timber.backend.receiver.buffering.PeriodicFlushing
import org.scalawag.timber.backend.receiver.concurrency.Locking

class MyReceiver extends Receiver {
  override def receive(entry: Entry) = ???
  override def flush() = ???
  override def close() = ???
}

val r = new StackableReceiver(new MyReceiver) with Locking with PeriodicFlushing

You can, alternatively extends StackableReceiver directly, in which case your instantiation code looks a bit nicer.

import org.scalawag.timber.api._
import org.scalawag.timber.backend.receiver._
import org.scalawag.timber.backend.receiver.buffering.PeriodicFlushing
import org.scalawag.timber.backend.receiver.concurrency.Locking

class MyReceiver extends StackableReceiver(new Receiver {
  override def receive(entry: Entry) = ???
  override def flush() = ???
  override def close() = ???
})

val r = new MyReceiver with Locking with PeriodicFlushing

The downside is that your receiver can't be subclassed as easily. To get the best of both worlds, it may be wise to produce a pair of classes: one that extends Receiver and one that extends StackableReceiver.

import org.scalawag.timber.api._
import org.scalawag.timber.backend.receiver._
import org.scalawag.timber.backend.receiver.buffering.PeriodicFlushing
import org.scalawag.timber.backend.receiver.concurrency.Locking

class MyReceiver extends Receiver {
  override def receive(entry: Entry) = ???
  override def flush() = ???
  override def close() = ???
}

class MyStackableReceiver extends StackableReceiver(new MyReceiver)

val r = new MyStackableReceiver with Locking with PeriodicFlushing
Linear Supertypes
Receiver, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. StackableReceiver
  2. Receiver
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Instance Constructors

  1. new StackableReceiver(coreBehavior: Receiver)

    Permalink

    coreBehavior

    the essential behavior of this receiver (i.e., what it does with entries)

Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def close(): Unit

    Permalink

    Closes the receiver.

    Closes the receiver. This means that the resources held by this receiver should be released in preparation for it being decommissioned. This usually happens before system shutdown, but it does not necessarily mean that this receiver will not receive any more entries. Receviers can be closed simply to release file system or network resources.

    This method must handle any flushing that is required prior to any resource deallocation. Timber will not necessarily call flush() before close().

    Definition Classes
    StackableReceiverReceiver
  7. final val coreBehavior: Receiver

    Permalink

    the essential behavior of this receiver (i.e., what it does with entries)

    the essential behavior of this receiver (i.e., what it does with entries)

    Attributes
    protected[this]
  8. final def eq(arg0: AnyRef): Boolean

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

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def flush(): Unit

    Permalink

    Tells this receiver to flush any buffered entries that it has received but not yet fully processed.

    Tells this receiver to flush any buffered entries that it has received but not yet fully processed. This makes it possible for this receiver to improve performance by batching I/O work.

    Definition Classes
    StackableReceiverReceiver
  12. final def getClass(): Class[_]

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

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

    Permalink
    Definition Classes
    Any
  15. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  16. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. final def receive(entry: Entry): Unit

    Permalink

    Receives an Entry for processing.

    Receives an Entry for processing. There is no initialization method for receivers, so this method must handle resource initialization on the first call after construction or after closure.

    entry

    the entry being received by this receiver

    Definition Classes
    StackableReceiverReceiver
  19. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  20. def toString(): String

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

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Receiver

Inherited from AnyRef

Inherited from Any

Ungrouped