Build a Data Connector

Quick Start

Code Structure

Clone the following repo: https://github.com/CliqueOfficial/clique-sibyl-demo-data-connector.

Assume the Data Connector is named SibylDemoDataConnector, the file structure should look like the following:

├── Dockerfile.sibyl
├── Dockerfile.DCsv2.sibyl
├── Dockerfile.DCsv2.pccs
├── docker-compose.yml
├── docker-compose-dcap.yml
├── connectors
│   └── SibylDemoDataConnector
│       ├── .cargo
│       │   └── config.toml
│       ├── Cargo.toml
│       └── src
│           ├── demo.rs
│           └── lib.rs
└── sibyl.toml
  • Dockerfile.sibyl : build the sibyl image:

  • Dockerfile.DCsv2.sibyl : build the DCsv2 sibyl image:

  • Dockerfile.DCsv2.pccs : build the custom DCAP Service for DCsv2 :

  • docker-compose.yml: deploy sibyl :

  • docker-compose-dcap.yml: deploy sibyl with custom DCAP service:

  • connectors: source codes of the Data Connectors.

  • sibyl.toml: sibyl config file.

Implement A Data Connector

  • Generate connectors/SibylDemoDataConnector/.cargo/config.toml:

  • Generate connectors/SibylDemoDataConnector/Cargo.toml:

  • Generate connectors/SibylDemoDataConnector/src/lib.rs:

  • Generate connectors/SibylDemoDataConnector/src/demo.rs:

Sibyl Config

We need to generate sibyl.toml to configurate the data connector:

We will integrate sibyl_demo_data_connector into the Sibyl Service from the specified path.

Route

In connectors/SibylDemoDataConnector/src/demo.rs, query_type_str must start with demo.You can configure it through route :

Now we will load the connector code from sibyl_demo_data_connector::demo_query::DemoConnector, and you should:

  • Rename connectors/SibylDemoDataConnector/src/demo.rs to connectors/SibylDemoDataConnector/src/demo_query.rs.

  • Replace demo_post and demo_get with demo_query_post and demo_query_get in connectors/SibylDemoDataConnector/src/demo_query.rs.

  • Replace pub mod demo; with pub mod demo_query; in connectors/SibylDemoDataConnector/src/lib.rs.

Connector

By default, we will load the connector code from sibyl_demo_data_connector::demo::DemoConnector . You can configure it through connector:

Now you can replace DemoConnector with DemoQueryConnector in connectors/SibylDemoDataConnector/src/demo.rs, and load the connector code from sibyl_demo_data_connector::demo::DemoQueryConnector.

Build & Deploy

  • Build Sibyl:

  • Build DCsv2 Sibyl:

  • Build DCsv2 with custom DCAP service:

  • Deploy Sibyl:

  • Deploy Sibyl with custom DCAP service:

Then Sibyl will run and listen on port 3443.

For Azure VMs, custom DCAP service is only avaiable for DCsv2 and is not supported in DCsv3.

Test

For example, if you want to make a get query for https://api.github.com/repos/github/repo-name:

Last updated