Package

com.gilt.gfc

util

Permalink

package util

Visibility
  1. Public
  2. All

Type Members

  1. class JRateLimiter extends ThreadSafeRateLimiter

    Permalink

    Java-friendly version of ThreadSafeRateLimiter.

  2. trait LimitCallback[T <: AnyRef] extends AnyRef

    Permalink

    Used by JRateLimiter in lieu of call-by-name from java.

  3. class RateLimiter extends AnyRef

    Permalink

    Used to rate-limit calls to a work function, e.g.

    Used to rate-limit calls to a work function, e.g. that writes to a db.

    Note you can disable the rate limiter by setting the frequency to 0.

    The math is as follows (mod some conversions between seconds and nano-seconds):

    After n samples, we can computer Ri as the "immediate rate" like:

    Ri = (n-1) / (timestamp(n) - timestamp(0))

    which is essentially the 1/average interval.

    Given a target rate, Rt ("maxFreqHz"), we can compute it like:

    Rt = n / (S + (timestamp(n) - timestamp(0))

    S here is how long to sleep before we invoke the next operation. Solving for S:

    S = n / Rt - (timestamp(n) - timestamp(0))

  4. class SingletonCache[K] extends AnyRef

    Permalink

    For objects that need their lifecycle to be managed and can't be just throw-away.

    For objects that need their lifecycle to be managed and can't be just throw-away. E.g. for when ConcurrentHashMap.putIfAbsent(new Something()) may result in a Something instance that need to be closed if another thread's putIfAbsent was successful.

    In this case it's easier to not create unnecessary instances in the first place.

  5. class ThreadSafeRateLimiter extends RateLimiter

    Permalink

    Fairly heavy-handed thread safe version of the above.

    Fairly heavy-handed thread safe version of the above. There's not a lot of point to trying to avoid locking here, since the whole point of this thing is to block writes, so we might as well keep it simple.

  6. trait VersionUtil extends AnyRef

    Permalink

    Used to get hold of the version of a particular item in the manifest.

  7. trait ExponentialBackoff extends AnyRef

    Permalink

    To avoid tight loops around errors.

    To avoid tight loops around errors.

    Annotations
    @deprecated
    Deprecated

    (Since version 0.1.0) Use the more flexible Retry functions

Value Members

  1. object BlobUtils

    Permalink

    Prepares an object to be sent over the wire

  2. object Retry

    Permalink

    Helper to retry potentially failing functions

    Helper to retry potentially failing functions

    Since

    10/Apr/2015 16:55

  3. object Throwables

    Permalink
  4. object VersionUtil extends VersionUtil

    Permalink
  5. object ZipUtils

    Permalink

    Util to zip/unzip an object/binary blob in/to a binary blob/object.

    Util to zip/unzip an object/binary blob in/to a binary blob/object.

    Actual impl of the compression is plain GZIP classes from the Java JDK.

  6. package types

    Permalink

    Church boolean types for use in type-level programming

    Church boolean types for use in type-level programming

    Inspired by: https://apocalisp.wordpress.com/2010/06/08/type-level-programming-in-scala/ https://en.wikipedia.org/wiki/Church_encoding#Church_Booleans http://downloads.typesafe.com/website/presentations/ScalaDaysSF2015/T4_Barnes_Typelevel_Prog.pdf

    Since

    20/Aug/2015 22:50

Ungrouped