Packages

package util

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. util
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Package Members

  1. package retry

Type Members

  1. trait BatchAggregator[A, B] extends AnyRef

    This batch aggregator exposes a BatchAggregator.run method that allows for batching scala.concurrent.Future computations, defined by a BatchAggregator.Processor.

    This batch aggregator exposes a BatchAggregator.run method that allows for batching scala.concurrent.Future computations, defined by a BatchAggregator.Processor.

    Note: it is required that getter and batchGetter do not throw an exception. If they do, the number of in-flight requests could fail to be decremented which would result in degraded performance or even prevent calls to the getters.

  2. class BatchAggregatorImpl[A, B] extends BatchAggregator[A, B]
  3. final case class ByteString190(str: ByteString)(name: Option[String] = None) extends LengthLimitedByteString with Product with Serializable
  4. final case class ByteString256(str: ByteString)(name: Option[String] = None) extends LengthLimitedByteString with Product with Serializable
  5. final case class ByteString4096(str: ByteString)(name: Option[String] = None) extends LengthLimitedByteString with Product with Serializable
  6. final case class ByteString6144(str: ByteString)(name: Option[String] = None) extends LengthLimitedByteString with Product with Serializable
  7. sealed abstract class Checked[+A, +N, +R] extends Product with Serializable

    A monad for aborting and non-aborting errors.

    A monad for aborting and non-aborting errors. Non-aborting errors are accumulated in a cats.data.Chain until the first aborting error is hit. You can think of com.digitalasset.canton.util.Checked as an extension of Either to also support errors that should not cause the computation to abort.

    A

    Type of aborting errors

    N

    Type of non-aborting errors

    R

    Result type of the monad

  8. final case class CheckedT[F[_], A, N, R](value: F[Checked[A, N, R]]) extends Product with Serializable

    Monad Transformer for Checked, allowing the effect of a monad F to be combined with the aborting and non-aborting failure effect of Checked.

    Monad Transformer for Checked, allowing the effect of a monad F to be combined with the aborting and non-aborting failure effect of Checked. Similar to cats.data.EitherT.

    Annotations
    @FutureTransformer(transformedTypeArgumentPosition = 0)
  9. trait CheckedTInstances extends CheckedTInstances1
  10. trait CheckedTInstances1 extends CheckedTInstances2
  11. trait CheckedTInstances2 extends AnyRef
  12. type ErrorLoggingLazyVal[T] = LazyValWithContext[T, ErrorLoggingContext]
  13. trait HasFlushFuture extends NamedLogging

    Provides a single flush scala.concurrent.Future that runs asynchronously.

    Provides a single flush scala.concurrent.Future that runs asynchronously. Tasks can be chained onto the flush future, although they will not run sequentially.

  14. trait HasReadWriteLock extends AnyRef
  15. final class LazyValWithContext[T, Context] extends AnyRef

    "Implements" a lazy val field whose initialization expression can refer to implicit context information of type Context.

    "Implements" a lazy val field whose initialization expression can refer to implicit context information of type Context. The "val" is initialized upon the first call to get, using the context information supplied for this call, like a lazy val.

    Instead of a plain lazy val field without context

    class C { lazy val f: T = initializer }
    
    use the following code to pass in a Context:
    class C {
      private[this] val _f: LazyValWithContext[T, Context] = new LazyValWithContext[T, Context](context => initializer)
      def f(implicit context: Context): T = _f.get
    }
    

    This class implements the same scheme as how the Scala 2.13 compiler implements lazy vals, as explained on https://docs.scala-lang.org/sips/improved-lazy-val-initialization.html (version V1) along with its caveats.

    See also

    TracedLazyVal To be used when the initializer wants to log something using the logger of the surrounding class

    ErrorLoggingLazyVal To be used when the initializer wants to log errors using the logger of the caller

  16. trait LazyValWithContextCompanion[Context] extends AnyRef
  17. sealed trait LengthLimitedByteString extends NoCopy

    This trait wraps a ByteString that is limited to a certain maximum length.

    This trait wraps a ByteString that is limited to a certain maximum length. Classes implementing this trait expose create and tryCreate methods to safely (and non-safely) construct such a ByteString.

    The canonical use case is ensuring that we don't encrypt more data than the underlying crypto algorithm can: for example, Rsa2048OaepSha256 can only encrypt 190 bytes at a time.

  18. trait LengthLimitedByteStringCompanion[A <: LengthLimitedByteString] extends AnyRef

    Trait that implements method commonly needed in the companion object of an LengthLimitedByteString

  19. final case class LengthLimitedByteStringVar(str: ByteString, maxLength: Int)(name: Option[String] = None) extends LengthLimitedByteString with Product with Serializable
  20. class MessageRecorder extends FlagCloseable with NamedLogging

    Persists data for replay tests.

  21. type NamedLoggingLazyVal[T] = LazyValWithContext[T, NamedLoggingContext]
  22. trait NoCopy extends AnyRef

    Prevents auto-generation of the copy method in a case class.

    Prevents auto-generation of the copy method in a case class. Case classes with private constructors typically shouldn't have a copy method.

  23. class NoOpBatchAggregator[A, B] extends BatchAggregator[A, B]
  24. class RateLimiter extends AnyRef

    Utility class that allows clients to keep track of a rate limit.

    Utility class that allows clients to keep track of a rate limit.

    The decay rate limiter keeps track of the current rate, allowing temporary bursts. This allows temporary bursts at the risk of overloading the system too quickly.

    Clients need to tell an instance whenever they intend to start a new task. The instance will inform the client whether the task can be executed while still meeting the rate limit.

    Guarantees:

    • Maximum burst size: if checkAndUpdateRate is called n times in parallel, at most max 1, maxTasksPerSecond * maxBurstFactor calls may return true.
    • Average rate: if checkAndUpdateRate is called at a rate of at least maxTasksPerSecond during n seconds, then the number of calls that return true divided by n is roughly maxTasksPerSecond .*
  25. trait ShowUtil extends ShowSyntax
  26. class SimpleExecutionQueue extends PrettyPrinting with NamedLogging with FlagCloseableAsync

    Functions executed with this class will only run when all previous calls have completed executing.

    Functions executed with this class will only run when all previous calls have completed executing. This can be used when async code should not be run concurrently.

    The default semantics is that a task is only executed if the previous tasks have completed successfully, i.e., they did not fail nor was the task aborted due to shutdown.

    If the queue is shutdown, the tasks' execution is aborted due to shutdown too.

  27. class SingleUseCell[A] extends AnyRef

    This class provides a mutable container for a single value of type A.

    This class provides a mutable container for a single value of type A. The value may be put at most once. A SingleUseCell therefore provides the following immutability guarantee: The value of a cell cannot change; once it has been put there, it will remain in the cell.

  28. class SnapshottableList[A] extends AnyRef

    A mutable list to which elements can be prepended and where snapshots can be taken atomically.

    A mutable list to which elements can be prepended and where snapshots can be taken atomically. Both operations are constant-time. Thread safe.

  29. trait Thereafter[F[_], Content[_]] extends Any

    Typeclass for computations with an operation that can run a side effect after the computation has finished.

    Typeclass for computations with an operation that can run a side effect after the computation has finished.

    The typeclass abstracts the following patterns so that it can be used for types other than scala.concurrent.Future.

    future.transform { result => val () = body(result); result } // synchronous body
    future.transform { result => body(result).transform(_ => result) } // asynchronous body

    Usage:

    import com.digitalasset.canton.util.Thereafter.syntax.*
    
    myAsyncComputation.thereafter(result => ...)
    

    F

    The computation's type functor.

    Content

    The container type for computation result. Functionally dependent on F.

  30. type TracedLazyVal[T] = LazyValWithContext[T, TraceContext]
  31. final case class UByte(signed: Byte) extends NoCopy with Product with Serializable

Value Members

  1. val ErrorLoggingLazyVal: LazyValWithContextCompanion[ErrorLoggingContext]
  2. val NamedLoggingLazyVal: LazyValWithContextCompanion[NamedLoggingContext]
  3. val TracedLazyVal: LazyValWithContextCompanion[TraceContext]
  4. object AkkaUtil extends HasLoggerName
  5. object BatchAggregator
  6. object BinaryFileUtil

    Write and read byte strings to files.

  7. object ByteString190 extends LengthLimitedByteStringCompanion[ByteString190] with Serializable
  8. object ByteString256 extends LengthLimitedByteStringCompanion[ByteString256] with Serializable
  9. object ByteString4096 extends LengthLimitedByteStringCompanion[ByteString4096] with Serializable
  10. object ByteString6144 extends LengthLimitedByteStringCompanion[ByteString6144] with Serializable
  11. object ByteStringUtil
  12. object ChainUtil

    Provides utility functions for the cats implementation of a Chain.

    Provides utility functions for the cats implementation of a Chain. This is a data-structure similar to a List, with constant time prepend and append. Note that the Chain has a performance hit when pattern matching as there is no constant-time uncons operation.

    Documentation on the cats Chain: https://typelevel.org/cats/datatypes/chain.html.

  13. object Checked extends Serializable
  14. object CheckedT extends CheckedTInstances with Serializable
  15. object DamlPackageLoader

    Wrapper that retrieves parsed packages from a DAR file consumable by the Daml interpreter.

  16. object DelayUtil extends NamedLogging

    Utility to create futures that succeed after a given delay.

    Utility to create futures that succeed after a given delay.

    Inspired by the odelay library, but with a restricted interface to avoid hazardous effects that could be caused by the use of a global executor service.

    TODO(i4245): Replace all usages by Clock.

  17. object EitherTUtil

    Utility functions for the cats cats.data.EitherT monad transformer.

    Utility functions for the cats cats.data.EitherT monad transformer. https://typelevel.org/cats/datatypes/eithert.html

  18. object EitherUtil
  19. object ErrorUtil
  20. object FutureInstances
  21. object FutureUtil
  22. object HasFlushFuture
  23. object HexString

    Conversion functions to and from hex strings.

  24. object IdUtil

    Contains instances for the Id functor.

  25. object IterableUtil
  26. object LengthLimitedByteString
  27. object LengthLimitedByteStringVar extends Serializable
  28. object LfTransactionUtil

    Helper functions to work with com.digitalasset.daml.lf.transaction.GenTransaction.

    Helper functions to work with com.digitalasset.daml.lf.transaction.GenTransaction. Using these helper functions is useful to provide a buffer from upstream changes.

  29. object LoggerUtil
  30. object MapsUtil
  31. object MessageRecorder
  32. object MonadUtil
  33. object OptionUtil
  34. object OptionUtils
  35. object PathUtils
  36. object PriorityBlockingQueueUtil
  37. object RangeUtil
  38. object ResourceUtil

    Utility code for doing proper resource management.

    Utility code for doing proper resource management. A lot of it is based on https://medium.com/@dkomanov/scala-try-with-resources-735baad0fd7d

  39. object SeqUtil
  40. object SetsUtil
  41. object ShowUtil extends ShowUtil

    Utility class for clients who want to make use of pretty printing.

    Utility class for clients who want to make use of pretty printing. Import this as follows:

    import com.digitalasset.canton.util.ShowUtil._
    
    In some cases, an import at the top of the file will not make the show interpolator available. To work around this, you need to import this INSIDE of the using class.

    To enforce pretty printing, the show interpolator should be used for creating strings. That is, show"s$myComplexObject" will result in a compile error, if pretty printing is not implemented for myComplexObject. In contrast, s"$myComplexObject" will fall back to the default (non-pretty) toString implementation, if pretty printing is not implemented for myComplexObject. Even if pretty printing is implemented for the type T of myComplexObject, s"$myComplexObject" will not use it, if the compiler fails to infer T: Pretty.

  42. object SimpleExecutionQueue
  43. object SnapshottableList
  44. object StackTraceUtil
  45. object TextFileUtil
  46. object Thereafter
  47. object TrieMapUtil
  48. object TryUtil
  49. object UByte extends Serializable
  50. object VersionUtil

Inherited from AnyRef

Inherited from Any

Ungrouped