Repository navigation
Hew 0.11.3
Hew services can stop accepting new requests and finish sending the responses they have already promised. Short-lived actors give their memory back during the run, and independent actors exchange messages faster. This release also expands the standard library available on WASI and in the browser sandbox.
Shutting down a service
Returning from main ends the root task. The program continues while its actors have work, including queued turns, sleeps and pending one-shot timers. Stop hooks run once that work finishes. The five-second drain used by Hew 0.11.2 is gone. Mark an actor #[background] if its work should never keep the program alive.
Call shutdown() to close admission, or shutdown(within: 25s) to set a deadline for finishing accepted work. The call returns immediately. An HTTP server can finish reading a partially received request body and send its response. A WebSocket server finishes the current message before starting its closing handshake. A stream reaches EOF when its source ends. If the deadline cuts unfinished work, Hew reports what it cancelled and exits with status 1.
Use os.wait_for_shutdown() in a daemon's main, or select on it when deciding whether to start another operation. It wakes on shutdown, stays ready for later callers and leaves default signal handling active. Once main has accepted a connection it can still spawn a session actor and submit its first turn during shutdown.
For a managed service, set HEW_SHUTDOWN_WITHIN below the service manager's termination grace period, allowing time for stop hooks. This sets the finishing deadline for default signal handling. A program that takes over signal handling with os.shutdown_signal() sets its own deadline in shutdown(within: ...). On Unix, a completed Ctrl-C shutdown now ends by SIGINT (shell status 130), and SIGTERM uses the program's final status. Update scripts that expect the old hew run grace period or status 124.
C embedders should replace hew_shutdown_initiate(drain_timeout_ms) with hew_shutdown_request(within_ns, code, has_code). The deadline is in nanoseconds. For example, hew_shutdown_request(25000000000LL, 0, false) requests 25 seconds with no requested exit status. Pass -1 as the first argument to finish without a deadline.
Actors and performance
- Actors on different workers can send independently. A stopped or crashed actor releases its allocation after terminal cleanup. An outstanding handle can still report how that actor ended, even after another actor has started.
- On one Linux x86-64 host, eight pairs of actors exchanging messages on four workers took a median of 88 ms, down from 249 ms. Spawning, calling and stopping 80,000 actors took 309 ms, down from 974 ms, and peak process memory fell from 184 MiB to 5.5 MiB. These were seven alternating O2 runs against development build
3d4004a2d. On the same host, 25 million scalarVec.setcalls took 46 ms, down from 272 ms. - Calls and sends to a supervised role can return
.Restartingduring a restart, backoff or circuit-breaker cooldown. Add that case to exhaustive matches onActorErrorandSendError. A child that crashes while accepted work is finishing still follows its restart policy. A child cancelled by the shutdown deadline stops without a replacement. - Local wait-cycle diagnostics account for forked work and actors under construction. A fault in a fork interrupts its scope's parked body, runs cleanup and delivers the original fault.
- Actor IDs in crash reports, metrics and traces use spawn order consistently. Update mailbox-loss queries that select the removed
spawn_seriallabel to useactor. Usemailbox_dropped_on_stop_by_type_totalfor losses across actors that have already stopped. The heap counters count allocator traffic, so reusing a pooled frame leaves them unchanged.
Language, tools and libraries
A literal's first constraining use can determine its type through a collection, record, function call or closure. An out-of-range literal is diagnosed where it was written, including in an imported module. Closures, tasks and generators inside an actor can capture snapshots of its state fields. Actor methods still run in the actor's own turn.
- Use
fmt.fixed(value, decimals)for fixed-point output,math.is_nan,math.is_infiniteandmath.is_finiteto classify floats, andos.args_tail()to get command-line arguments after the program name. String helpers strip prefixes and suffixes or trim either end.path.stemextracts the file stem. - Typed TOML encoding accepts records with scalar fields after table fields and diagnoses nested shapes TOML cannot encode. File and network errors recognize the error-number space of the target, including WASI preview 1.
- On WASI, Hew can generate random bytes and UUIDs, encrypt with AES-256-GCM, sign and verify with Ed25519, parse URLs, and use the compression, Markdown, MessagePack, Protobuf and XML modules. The browser sandbox gains native-compatible Unicode properties, URL operations, hashes and HMACs. Browser hosts can import
bridgesFromWasmModulefrom@hew-lang/sandbox-vmand passbridgesFromWasmModule(compiler)as the options torunBytecodeafter initializing@hew-lang/wasm. TherunProgramresult includesstderrfor displaying shutdown reports separately from compiler diagnostics. hew eval 'let x = [1, 2]; x.len()'evaluates the trailing expression directly. Editor hover and signature help resolve an actor method ahead of a same-named module function. Workspace search can find a symbol in an unsaved file even when its containing directory has yet to be created.
Security updates
Hew includes snow 0.10.3, which restores cipher state correctly after a failed Noise handshake, and curve25519-dalek 5.1.0, which fixes a scalar multiplication error on the AVX-512 backend. RustSec handshake advisory · RustSec arithmetic advisory