Class RuntimeOptions

java.lang.Object
me.ahoo.cosid.runtime.RuntimeOptions

public final class RuntimeOptions extends Object
What a CosIdRuntime starts with besides its RuntimeSpec: everything that is not configuration. Immutable; built with builder(), the only way to create one, so fields can be added with a default (api-freeze.md ยง4); toBuilder() changes one.
  • Method Details

    • builder

      public static RuntimeOptions.Builder builder()
      A builder starting from the defaults (defaults()).
      Returns:
      the builder
    • defaults

      public static RuntimeOptions defaults()
      The system clock, an own executor, no listener, providers from ServiceLoader only, no clients, the local host, no port, custom codecs by class name, no custom generators, no counting.
      Returns:
      the default options
    • toBuilder

      public RuntimeOptions.Builder toBuilder()
      A builder holding these options, to change them.
      Returns:
      the builder
    • time

      public TimeSource time()
      The time source.
      Returns:
      the time source; default TimeSource.SYSTEM
    • executor

      public Optional<Executor> executor()
      Runs refills and renewals.
      Returns:
      the executor; when empty (the default) the runtime creates a virtual thread executor and closes it
    • listener

      public GeneratorListener listener()
      The event listener.
      Returns:
      the listener; default GeneratorListener.NOOP
    • storeProviders

      public List<StoreProvider> storeProviders()
      Providers besides those ServiceLoader finds; they win for the same type.
      Returns:
      the providers, unmodifiable; default none
    • clients

      public Map<String,Object> clients()
      Existing client objects by store name, passed as StoreConfig.client.
      Returns:
      the clients, unmodifiable; default none
    • hostResolver

      public HostResolver hostResolver()
      The host of a derived owner key.
      Returns:
      the resolver; default HostResolver.LOCAL
    • port

      public OptionalInt port()
      The port of a derived owner key, host:port.
      Returns:
      the port; when empty (the default) the owner key is host:pid
    • codecs

      public Function<String,Optional<IdCodec>> codecs()
      Resolves CodecSpec.Custom references.
      Returns:
      the resolver, empty for an unknown reference; default by class name
    • generators

      public Function<String,Optional<IdGenerator>> generators()
      Resolves GeneratorSpec.Custom references (D41).
      Returns:
      the resolver, empty for an unknown reference; by default always empty, so a custom reference fails the start
    • countGenerated

      public boolean countGenerated()
      Whether to count the ids each generator issues through the views the runtime hands out (CosIdRuntime.generated(String)).
      Returns:
      whether to count; off by default, which leaves the hot path unchanged
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object