Teravolt is an executor for handling streaming data from multiple sources and enabling seamless communication between them.
Getting started
There are two main components to getting Teravolt up and running:
- [
Connection
][executor::Connection] - [
Executor
][executor]
Creating a Connection
To create a new connection, we need to create a blank struct, like so:
;
It is very important that our struct is cloneable. Next
we need to implement the actual [Connection
]. When implementing a
connection we need to create a global error type that will be used across
all connections running in the executor. This can reasonably be anything but
for now, ()
will be adequate for demonstration. An implementation for a
[Connection
] will look like this:
Config
This is how we determine the name of the connection. A name must be unique. For instance, a config will look this:
Restart Policy
The restart policy will determine what happens when the task either completes or fails. It takes the result produced by the task and it is up to you to determine what circumstances will cause a Restart or a Shutdown. A restart policy will sometimes look like this:
Task
Each connection has an asynchronous task that is responsible for reading in messages and sending them to other connections. A task will sometimes look like this:
async
A task has the ability to read messages sent from other connections and send
messages from other connections. The ability to read and write is determined
by the connection's [ConnectionBehaviour
][config::ConnectionBehaviour].
Executor
The executor is the main manager for all of the connections you'll be running. Setting up the executor is quite simple, first you need to create a tokio runtime with the right features enabled for your use-case:
let runtime = new_multi_thread
.thread_name
.thread_stack_size
.enable_time
.build
.unwrap;
Then once you've made the runtime you can create an instance of the executor, add your connections, set the maximum message capacity, and you're good to go!
let mut teravolt = new.unwrap;
teravolt.add_connection;
teravolt.start.await;