提交 4295063b 编写于 作者: A Adam Ji

docs: remove db in sml struct

上级 d3540a75
...@@ -24,6 +24,9 @@ async fn put_json() -> anyhow::Result<()> { ...@@ -24,6 +24,9 @@ async fn put_json() -> anyhow::Result<()> {
.exec(format!("create database if not exists {db}")) .exec(format!("create database if not exists {db}"))
.await?; .await?;
// should specify database before insert
client.exec(format!("use {db}")).await?;
// SchemalessProtocol::Json // SchemalessProtocol::Json
let data = [ let data = [
r#"[{"metric": "meters.current", "timestamp": 1681345954000, "value": 10.3, "tags": {"location": "California.SanFrancisco", "groupid": 2}}, {"metric": "meters.voltage", "timestamp": 1648432611249, "value": 219, "tags": {"location": "California.LosAngeles", "groupid": 1}}, {"metric": "meters.current", "timestamp": 1648432611250, "value": 12.6, "tags": {"location": "California.SanFrancisco", "groupid": 2}}, {"metric": "meters.voltage", "timestamp": 1648432611250, "value": 221, "tags": {"location": "California.LosAngeles", "groupid": 1}}]"# r#"[{"metric": "meters.current", "timestamp": 1681345954000, "value": 10.3, "tags": {"location": "California.SanFrancisco", "groupid": 2}}, {"metric": "meters.voltage", "timestamp": 1648432611249, "value": 219, "tags": {"location": "California.LosAngeles", "groupid": 1}}, {"metric": "meters.current", "timestamp": 1648432611250, "value": 12.6, "tags": {"location": "California.SanFrancisco", "groupid": 2}}, {"metric": "meters.voltage", "timestamp": 1648432611250, "value": 221, "tags": {"location": "California.LosAngeles", "groupid": 1}}]"#
...@@ -33,7 +36,6 @@ async fn put_json() -> anyhow::Result<()> { ...@@ -33,7 +36,6 @@ async fn put_json() -> anyhow::Result<()> {
// demo with all fields // demo with all fields
let sml_data = SmlDataBuilder::default() let sml_data = SmlDataBuilder::default()
.db(db.to_string())
.protocol(SchemalessProtocol::Json) .protocol(SchemalessProtocol::Json)
.precision(SchemalessPrecision::Millisecond) .precision(SchemalessPrecision::Millisecond)
.data(data.clone()) .data(data.clone())
...@@ -44,7 +46,6 @@ async fn put_json() -> anyhow::Result<()> { ...@@ -44,7 +46,6 @@ async fn put_json() -> anyhow::Result<()> {
// demo with default precision // demo with default precision
let sml_data = SmlDataBuilder::default() let sml_data = SmlDataBuilder::default()
.db(db.to_string())
.protocol(SchemalessProtocol::Json) .protocol(SchemalessProtocol::Json)
.data(data.clone()) .data(data.clone())
.ttl(1000) .ttl(1000)
...@@ -54,7 +55,6 @@ async fn put_json() -> anyhow::Result<()> { ...@@ -54,7 +55,6 @@ async fn put_json() -> anyhow::Result<()> {
// demo with default ttl // demo with default ttl
let sml_data = SmlDataBuilder::default() let sml_data = SmlDataBuilder::default()
.db(db.to_string())
.protocol(SchemalessProtocol::Json) .protocol(SchemalessProtocol::Json)
.data(data.clone()) .data(data.clone())
.req_id(302u64) .req_id(302u64)
...@@ -63,7 +63,6 @@ async fn put_json() -> anyhow::Result<()> { ...@@ -63,7 +63,6 @@ async fn put_json() -> anyhow::Result<()> {
// demo with default req_id // demo with default req_id
let sml_data = SmlDataBuilder::default() let sml_data = SmlDataBuilder::default()
.db(db.to_string())
.protocol(SchemalessProtocol::Json) .protocol(SchemalessProtocol::Json)
.data(data.clone()) .data(data.clone())
.build()?; .build()?;
......
...@@ -25,6 +25,9 @@ async fn put_line() -> anyhow::Result<()> { ...@@ -25,6 +25,9 @@ async fn put_line() -> anyhow::Result<()> {
.exec(format!("create database if not exists {db}")) .exec(format!("create database if not exists {db}"))
.await?; .await?;
// should specify database before insert
client.exec(format!("use {db}")).await?;
let data = [ let data = [
"measurement,host=host1 field1=2i,field2=2.0 1577837300000", "measurement,host=host1 field1=2i,field2=2.0 1577837300000",
"measurement,host=host1 field1=2i,field2=2.0 1577837400000", "measurement,host=host1 field1=2i,field2=2.0 1577837400000",
...@@ -36,7 +39,6 @@ async fn put_line() -> anyhow::Result<()> { ...@@ -36,7 +39,6 @@ async fn put_line() -> anyhow::Result<()> {
// demo with all fields // demo with all fields
let sml_data = SmlDataBuilder::default() let sml_data = SmlDataBuilder::default()
.db(db.to_string())
.protocol(SchemalessProtocol::Line) .protocol(SchemalessProtocol::Line)
.precision(SchemalessPrecision::Millisecond) .precision(SchemalessPrecision::Millisecond)
.data(data.clone()) .data(data.clone())
...@@ -47,7 +49,6 @@ async fn put_line() -> anyhow::Result<()> { ...@@ -47,7 +49,6 @@ async fn put_line() -> anyhow::Result<()> {
// demo with default ttl // demo with default ttl
let sml_data = SmlDataBuilder::default() let sml_data = SmlDataBuilder::default()
.db(db.to_string())
.protocol(SchemalessProtocol::Line) .protocol(SchemalessProtocol::Line)
.precision(SchemalessPrecision::Millisecond) .precision(SchemalessPrecision::Millisecond)
.data(data.clone()) .data(data.clone())
...@@ -57,7 +58,6 @@ async fn put_line() -> anyhow::Result<()> { ...@@ -57,7 +58,6 @@ async fn put_line() -> anyhow::Result<()> {
// demo with default ttl and req_id // demo with default ttl and req_id
let sml_data = SmlDataBuilder::default() let sml_data = SmlDataBuilder::default()
.db(db.to_string())
.protocol(SchemalessProtocol::Line) .protocol(SchemalessProtocol::Line)
.precision(SchemalessPrecision::Millisecond) .precision(SchemalessPrecision::Millisecond)
.data(data.clone()) .data(data.clone())
...@@ -66,7 +66,6 @@ async fn put_line() -> anyhow::Result<()> { ...@@ -66,7 +66,6 @@ async fn put_line() -> anyhow::Result<()> {
// demo with default precision // demo with default precision
let sml_data = SmlDataBuilder::default() let sml_data = SmlDataBuilder::default()
.db(db.to_string())
.protocol(SchemalessProtocol::Line) .protocol(SchemalessProtocol::Line)
.data(data) .data(data)
.req_id(103u64) .req_id(103u64)
......
...@@ -24,6 +24,8 @@ async fn put_telnet() -> anyhow::Result<()> { ...@@ -24,6 +24,8 @@ async fn put_telnet() -> anyhow::Result<()> {
.exec(format!("create database if not exists {db}")) .exec(format!("create database if not exists {db}"))
.await?; .await?;
// should specify database before insert
client.exec(format!("use {db}")).await?;
let data = [ let data = [
"meters.current 1648432611249 10.3 location=California.SanFrancisco group=2", "meters.current 1648432611249 10.3 location=California.SanFrancisco group=2",
...@@ -40,7 +42,6 @@ async fn put_telnet() -> anyhow::Result<()> { ...@@ -40,7 +42,6 @@ async fn put_telnet() -> anyhow::Result<()> {
// demo with all fields // demo with all fields
let sml_data = SmlDataBuilder::default() let sml_data = SmlDataBuilder::default()
.db(db.to_string())
.protocol(SchemalessProtocol::Telnet) .protocol(SchemalessProtocol::Telnet)
.precision(SchemalessPrecision::Millisecond) .precision(SchemalessPrecision::Millisecond)
.data(data.clone()) .data(data.clone())
...@@ -51,7 +52,6 @@ async fn put_telnet() -> anyhow::Result<()> { ...@@ -51,7 +52,6 @@ async fn put_telnet() -> anyhow::Result<()> {
// demo with default precision // demo with default precision
let sml_data = SmlDataBuilder::default() let sml_data = SmlDataBuilder::default()
.db(db.to_string())
.protocol(SchemalessProtocol::Telnet) .protocol(SchemalessProtocol::Telnet)
.data(data.clone()) .data(data.clone())
.ttl(1000) .ttl(1000)
...@@ -61,7 +61,6 @@ async fn put_telnet() -> anyhow::Result<()> { ...@@ -61,7 +61,6 @@ async fn put_telnet() -> anyhow::Result<()> {
// demo with default ttl // demo with default ttl
let sml_data = SmlDataBuilder::default() let sml_data = SmlDataBuilder::default()
.db(db.to_string())
.protocol(SchemalessProtocol::Telnet) .protocol(SchemalessProtocol::Telnet)
.data(data.clone()) .data(data.clone())
.req_id(202u64) .req_id(202u64)
...@@ -70,7 +69,6 @@ async fn put_telnet() -> anyhow::Result<()> { ...@@ -70,7 +69,6 @@ async fn put_telnet() -> anyhow::Result<()> {
// demo with default req_id // demo with default req_id
let sml_data = SmlDataBuilder::default() let sml_data = SmlDataBuilder::default()
.db(db.to_string())
.protocol(SchemalessProtocol::Telnet) .protocol(SchemalessProtocol::Telnet)
.data(data.clone()) .data(data.clone())
.build()?; .build()?;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册