Stdlib index
- Captured-borrow migration worklist (3.3.3)
- Owned-bind migration worklist (8.2.7)
- Return-side title audit — the ride-through enumeration
- stdlib ownership audit
- stdlib ownership dispositions (plan 1.3.1 / 4.3.1)
aot
codec
codec / csv
codec / json
collection
- ArrayList
- BPlusTree
- Cache
- Collectors
- HashMap
- HashSet
- Heap
- ImmutableList
- ImmutableMap
- ImmutableSet
- LinkedList
- RedBlackTree
- Sort
collection / ltm
concurrent
error
- Exception
- NoOptionalValueException
- NotProvidedException
- RecoverableException
- ScopedBuildFailedException
- ScopeNotActiveException
- Throwable
- UnrecoverableException
gfx
hash
ifx
io
io / file
io / net
io / net / dns
io / net / uri
lang
lang / stream
math
math / fft
math / linalg
math / npio
math / poly
math / random
math / stats
nucleo
- Columns — the Arrow-laid-out substrate
- Fused tensor expressions — Fuse
- Table — the lazy, typed dataframe
- Tape — define-by-run autograd
- Transform intrinsics — Grad, Vmap, Jit
process
reflect
search / distance
search / fuzzy
search / ngram
session
time
- Clock
- DateTimeFormatter
- Duration
- Instant
- LocalDate
- LocalDateTime
- LocalTime
- Period
- ZonedDateTime
- ZoneId
- ZoneOffset
wire
xpu
xpu / mesh
ServerBuilder
cajeta.io.net.ServerBuilder — the model-selection builder for a
Server, opened with Server.builder(). It is the single fluent
surface for picking which accept stack a server uses — Model A
(fiber-per-connection, the default) or Model B (event-driven shared-pool, via
ServerModel.sharedPool(n)) — without naming the concrete server class.
bind (or bindAddress) and handler are required; backlog defaults to
the platform listen backlog (UNSET_BACKLOG). The builder is a pure value
until build() is called — no I/O happens while recording choices.
ServerBuilder b #= Server.builder();
b.bind("127.0.0.1:0");
b.model(ServerModel.fiberPerConnection());
b.handler((TcpStream conn) -> { conn.close(); });
Server s #= b.build();
Each setter returns the builder as a plain borrow. The builder that
Server.builder() returns is an owned temporary when nothing names it, and it
is freed at the end of its statement. So bind the builder to a local first, as
above, or end a single chain with build(), which returns an owned #Server:
Server s #= Server.builder()
.bind("127.0.0.1:0")
.model(ServerModel.fiberPerConnection())
.handler((TcpStream conn) -> { conn.close(); })
.build();
Keeping a setter’s result is rejected:
ServerBuilder b #= Server.builder().bind("127.0.0.1:0").handler(h); // CAJETA_ERROR_BORROW_OF_TEMPORARY
Methods
| Signature | |
|---|---|
ServerBuilder bind(String addr) | Bind to a host:port (or [v6]:port) string, parsed via SocketAddress.parse |
ServerBuilder bindAddress(SocketAddress addr) | Bind to an already-parsed SocketAddress |
ServerBuilder model(ServerModel m) | Select the accept model — ServerModel.fiberPerConnection() (Model A) or ServerModel.sharedPool(n) (Model B) |
ServerBuilder handler((TcpStream) -> void h) | Set the per-connection handler, invoked once per accepted connection with the owned TcpStream |
ServerBuilder backlog(int32 backlog) | Set an explicit listen(2) backlog (the accept-queue depth) |
#Server build() ⚑ | Build the configured Server; either model returns a Server, so the caller drives the same serve() / shutdown() surface |
void serve() | Terminal convenience: build the selected server, then run its accept loop synchronously |
⚑ = @EntryPoint
See also
- Source:
runtime/src/cajeta/io/net/ServerBuilder.cajeta - Server — what it builds; HttpServerBuilder — the HTTP-layer counterpart