CredentialsBefore starting this section be sure to retrieve your API key and the appropriate Sift URL for your provisioned environment. Instructions
on how to retrieve the API key and URL and can be found in the authentication section of the documentation.
NostromoLV426, and then stream that data to Sift.
NostromoLV426 will contain a single mainmotor.velocity channel whose
values are of type double.
For full code examples, documentation, as well as the library’s source code, refer to the following:
Installing Dependencies
For this exercise we will needsift_rs, rand, pbjson_types, chrono, and tokio_stream. Inside of your new Rust project:
TokioNote that we don’t actually require the full feature set of Tokio. The Tokio runtime flavor to use is dependent on your requirements,
however, Tokio is required to work with
sift_rs that is the runtime that tonic relies on.Imports
With our dependencies installed, we’re going to begin by importing everything we will use for this example in advance. Inside ofmain.rs:
Data Source
Next we’re going to define a data source which will provide us with mock sensor data. The data source will simply send a timestamp and afloat
over the course of a minute and sleep for 0.5s between each send. This will represent the time-series coming from the velocity channel:
Config
Now we will define our channels in a function calledchannel_configs. Right now we only have one velocity channel but
we are free to add more later.
get_or_create_ingestion config which retrieves an existing
ingestion config
by client key or creates it if it does not exist. This function will use the channel_configs function that we created
in the previous step:
Client KeysAs mentioned in the ingestion config section, specifying
a client key is highly recommended as it simplifies lookups for users after creation as shown above.
Creating a Run
Now we will make acreate_run function so we can group together our asset data.
Runs are OptionalCreating a run is not required to send data to Sift. It’s a mechanism to group together data for a single asset or multiple assets. Read
more.
Sending Data
Now all that’s left to do is to assemble ourmain function:
NostromoLV426, the run we just created, as well as
data for the velocity channel.