Class MyraServerConfig.Builder

java.lang.Object
express.mvp.myra.server.MyraServerConfig.Builder
Enclosing class:
MyraServerConfig

public static class MyraServerConfig.Builder extends Object
Builder for creating MyraServerConfig instances.

Provides a fluent API for configuring all server options with sensible defaults.

Default Values

  • host: "0.0.0.0" (all interfaces)
  • port: 8080
  • numBuffers: 1024
  • bufferSize: 4096 bytes
  • cpuAffinity: -1 (no affinity)
  • sqPollCpuAffinity: -1 (no affinity)
  • sqPollEnabled: false
  • sqPollIdleTimeout: 2000 microseconds
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • host

      public MyraServerConfig.Builder host(String host)
      Sets the host address to bind to.
      Parameters:
      host - the host address (e.g., "0.0.0.0" for all interfaces)
      Returns:
      this builder for method chaining
    • port

      public MyraServerConfig.Builder port(int port)
      Sets the TCP port to listen on.
      Parameters:
      port - the port number (1-65535)
      Returns:
      this builder for method chaining
    • numBuffers

      public MyraServerConfig.Builder numBuffers(int numBuffers)
      Sets the number of registered buffers in the pool.
      Parameters:
      numBuffers - the number of buffers (should be power of 2 for efficiency)
      Returns:
      this builder for method chaining
    • bufferSize

      public MyraServerConfig.Builder bufferSize(int bufferSize)
      Sets the size of each buffer in bytes.
      Parameters:
      bufferSize - the buffer size in bytes
      Returns:
      this builder for method chaining
    • cpuAffinity

      public MyraServerConfig.Builder cpuAffinity(int cpuAffinity)
      Sets the CPU core affinity for the server thread.
      Parameters:
      cpuAffinity - the CPU core index, or -1 for no affinity
      Returns:
      this builder for method chaining
    • sqPollCpuAffinity

      public MyraServerConfig.Builder sqPollCpuAffinity(int sqPollCpuAffinity)
      Sets the CPU core affinity for the SQPOLL kernel thread.
      Parameters:
      sqPollCpuAffinity - the CPU core index, or -1 for no affinity
      Returns:
      this builder for method chaining
    • sqPollEnabled

      public MyraServerConfig.Builder sqPollEnabled(boolean enabled)
      Enables or disables SQPOLL mode.

      When enabled, the kernel continuously polls the submission queue, eliminating system call overhead at the cost of CPU usage.

      Parameters:
      enabled - true to enable SQPOLL mode
      Returns:
      this builder for method chaining
    • sqPollIdleTimeout

      public MyraServerConfig.Builder sqPollIdleTimeout(int timeout)
      Sets the SQPOLL idle timeout.
      Parameters:
      timeout - the idle timeout in microseconds
      Returns:
      this builder for method chaining
    • build

      public MyraServerConfig build()
      Builds a new MyraServerConfig with the configured values.
      Returns:
      a new immutable configuration instance