Class NatsBase

java.lang.Object
berlin.yuna.natsserver.logic.NatsBase
All Implemented Interfaces:
AutoCloseable
Direct Known Subclasses:
Nats

public abstract class NatsBase extends Object implements AutoCloseable
Since:
1.0
Author:
Yuna Morgenstern
See Also:
  • Field Details

  • Method Details

    • pid

      public int pid()
      get process id
      Returns:
      process id or -1 if process is not running
    • pidFile

      public Path pidFile()
      get process id file which only exists when the process is running
      Returns:
      process id file path
    • binaryFile

      public Path binaryFile()
      nats binary file which only exists after download or if its already placed there
      Returns:
      nats binary file path
    • downloadUrl

      public String downloadUrl()
      nats download url which is usually a zip file
      Returns:
      nats download url
    • url

      public String url()
      nats server URL from bind to host address
      Returns:
      nats server url
    • port

      public int port()
      Gets the port out of the configuration
      Returns:
      configured port of the server
      Throws:
      RuntimeException - when the port is not configured
    • args

      public NatsBase args(String... args)
      Adds custom arguments to the nats start command
      Parameters:
      args - arguments
      Returns:
      self NatsBase
    • args

      public List<String> args()
      Get customArguments
      Returns:
      list of custom arguments
    • getValue

      public String getValue(NatsConfig key)
      Gets resolved config value from key
      Parameters:
      key - config key
      Returns:
      config key value
    • getValue

      public String getValue(NatsConfig key, Supplier<String> or)
      Gets resolved config value from key
      Parameters:
      key - config key
      or - lazy loaded fallback value
      Returns:
      config key value
    • getConfigFile

      public Optional<Path> getConfigFile()
      Resolves the config file from the configuration e.g. Nats.config(NatsConfig, String)
      Returns:
      config file as optional path - not empty if file exists
    • toString

      public String toString()
      Overrides:
      toString in class Object