Skip to content

Commit b70faf0

Browse files
authored
docs(ilp): add rust auth example (#25)
1 parent 4d6a64b commit b70faf0

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

ci/run_tests_pipeline.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ stages:
6868
- script: |
6969
cd questdb-rs
7070
cargo build --example basic
71+
cargo build --example auth
7172
cargo build --example auth_tls
7273
displayName: Build Rust examples.
7374
- script: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release

examples.manifest.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,49 @@
1717
header: |-
1818
[Rust client library docs](https://docs.rs/crate/questdb-rs/latest)
1919
20+
# ILP Auth Examples
21+
- name: ilp-auth
22+
lang: c
23+
path: examples/line_sender_c_example_auth.c
24+
header: |-
25+
[C client library docs](https://github.com/questdb/c-questdb-client/blob/main/doc/C.md)
26+
auth:
27+
kid: testUser1
28+
d: 5UjEMuA0Pj5pjK8a-fa24dyIf-Es5mYny3oE_Wmus48
29+
x: fLKYEaoEb9lrn3nkwLDA-M_xnuFOdSt9y0Z7_vWSHLU
30+
y: Dt5tbS1dEDMSYfym3fgMv0B99szno-dFc1rYF9t0aac
31+
addr:
32+
host: localhost
33+
port: 9009
34+
35+
- name: ilp-auth
36+
lang: cpp
37+
path: examples/line_sender_cpp_example_auth.cpp
38+
header: |-
39+
[C++ client library docs](https://github.com/questdb/c-questdb-client/blob/main/doc/CPP.md)
40+
auth:
41+
kid: testUser1
42+
d: 5UjEMuA0Pj5pjK8a-fa24dyIf-Es5mYny3oE_Wmus48
43+
x: fLKYEaoEb9lrn3nkwLDA-M_xnuFOdSt9y0Z7_vWSHLU
44+
y: Dt5tbS1dEDMSYfym3fgMv0B99szno-dFc1rYF9t0aac
45+
addr:
46+
host: localhost
47+
port: 9009
48+
49+
- name: ilp-auth
50+
lang: rust
51+
path: questdb-rs/examples/auth.rs
52+
header: |-
53+
[Rust client library docs](https://docs.rs/crate/questdb-rs/latest)
54+
auth:
55+
kid: testUser1
56+
d: 5UjEMuA0Pj5pjK8a-fa24dyIf-Es5mYny3oE_Wmus48
57+
x: fLKYEaoEb9lrn3nkwLDA-M_xnuFOdSt9y0Z7_vWSHLU
58+
y: Dt5tbS1dEDMSYfym3fgMv0B99szno-dFc1rYF9t0aac
59+
addr:
60+
host: localhost
61+
port: 9009
62+
2063
# ILP Auth + TLS Examples
2164
- name: ilp-auth-tls
2265
lang: c

questdb-rs/examples/auth.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use questdb::{
2+
Result,
3+
ingress::{
4+
Buffer,
5+
SenderBuilder}};
6+
7+
fn main() -> Result<()> {
8+
let host: String = std::env::args().nth(1)
9+
.unwrap_or("localhost".to_string());
10+
let port: u16 = std::env::args().nth(2)
11+
.unwrap_or("9009".to_string()).parse().unwrap();
12+
let mut sender = SenderBuilder::new(host, port)
13+
.auth(
14+
"testUser1", // kid
15+
"5UjEMuA0Pj5pjK8a-fa24dyIf-Es5mYny3oE_Wmus48", // d
16+
"fLKYEaoEb9lrn3nkwLDA-M_xnuFOdSt9y0Z7_vWSHLU", // x
17+
"Dt5tbS1dEDMSYfym3fgMv0B99szno-dFc1rYF9t0aac") // y
18+
.connect()?;
19+
let mut buffer = Buffer::new();
20+
buffer
21+
.table("sensors")?
22+
.symbol("id", "toronto1")?
23+
.column_f64("temperature", 20.0)?
24+
.column_i64("humidity", 50)?
25+
.at_now()?;
26+
sender.flush(&mut buffer)?;
27+
Ok(())
28+
}

0 commit comments

Comments
 (0)