Your First Signal Handler
This guide walks through building a simple application that emits and processes NTL signals.What We’re Building
A basic key-value store that:- Accepts
Commandsignals to store values - Accepts
Querysignals to retrieve values - Responds with
Datasignals containing results
Setup
Define Signal Handlers
Wire It Together
Test It
In another terminal, use the NTL CLI:What Just Happened
- Your KV store node registered handlers for
CommandandQuerysignals tagged withkv - It announced its capabilities via a
Discoverysignal - The CLI emitted signals that propagated through the network
- Your handlers processed the signals and emitted correlated responses
- The CLI received the responses via correlation matching
Key Patterns
Handler Registration
Handlers declare what signal types and tags they process. The node’s propagation controller uses this to determine which incoming signals to route to which handlers.Discovery Announcement
By emitting aDiscovery signal, your node tells the network what it can do. Other nodes learn about your capabilities and can route relevant signals your way.
Correlation for Request-Response
When you need a response to a specific signal, use correlation. The emitter sets a signal ID, the handler includes that ID ascorrelation_id in its response. The --wait-correlation flag in the CLI demonstrates this pattern.
Returning None
Handlers can returnNone to process a signal without emitting a response. Useful for event logging, metrics collection, or side effects.
Next Steps
Building Adapters
Expose your signal handlers via HTTP
SiafuDB Integration
Persist state across signal handlers