Class MyraServerConfig.Builder
java.lang.Object
express.mvp.myra.server.MyraServerConfig.Builder
- Enclosing class:
MyraServerConfig
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbufferSize(int bufferSize) Sets the size of each buffer in bytes.build()Builds a new MyraServerConfig with the configured values.cpuAffinity(int cpuAffinity) Sets the CPU core affinity for the server thread.Sets the host address to bind to.numBuffers(int numBuffers) Sets the number of registered buffers in the pool.port(int port) Sets the TCP port to listen on.sqPollCpuAffinity(int sqPollCpuAffinity) Sets the CPU core affinity for the SQPOLL kernel thread.sqPollEnabled(boolean enabled) Enables or disables SQPOLL mode.sqPollIdleTimeout(int timeout) Sets the SQPOLL idle timeout.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
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
Sets the TCP port to listen on.- Parameters:
port- the port number (1-65535)- Returns:
- this builder for method chaining
-
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
Sets the size of each buffer in bytes.- Parameters:
bufferSize- the buffer size in bytes- Returns:
- this builder for method chaining
-
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
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
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
Sets the SQPOLL idle timeout.- Parameters:
timeout- the idle timeout in microseconds- Returns:
- this builder for method chaining
-
build
Builds a new MyraServerConfig with the configured values.- Returns:
- a new immutable configuration instance
-