Tangle Job Call Listeners
Tangle Job Call Listeners are a powerful feature in the Gadget SDK that allow your blueprint to react to job calls on the Tangle network. These listeners leverage Rust's async capabilities and the tokio
runtime to efficiently handle incoming job requests.
Overview
Tangle Job Call Listeners enable your blueprint to:
- Listen for specific job calls on the Tangle network
- Execute custom logic in response to job calls
- Process and validate job parameters
Tangle Job Call Listeners are particularly useful for tasks such as:
- Executing on-chain operations based on job requests
- Validating and processing data submitted through jobs
- Triggering off-chain actions in response to on-chain events
- Implementing complex business logic that integrates with the Tangle network
These listeners form a crucial part of Tangle's native job system, allowing blueprints to interact seamlessly with the broader Tangle ecosystem and respond to network events in real-time.
TangleEventListener
The TangleEventListener
is a type that listens to the Tangle network for events. This is a required type if you expect your application to use the tangle network to listen to jobs.
The TangleEventListener
is already implemented and ready to use. Simply register it in the job
macro, and your application
will automatically work with the Tangle network.
Service pre/post processors
The SDK also provides a ready-to-use pre-processor and post-processor for the JobCalled event on Tangle. The pre-processor destructures the arguments of blueprint jobs so that jobs can be executed with the arguments they are defined with. The post-processors
Pre-processor
The pre-processor for Tangle job calls handles the following tasks:
- Extracts and validates the job parameters from the raw event data
- Deserializes the parameters into the expected types
- Prepares the data for processing by the job handler
Post-processor
The post-processor for Tangle job calls handles the following tasks:
- Takes the output from the job execution
- Formats and prepares the result for on-chain storage
- Handles any cleanup or finalization required after job execution