Skip to content

Commit

Permalink
*: prepare for 0.2.0 (#28)
Browse files Browse the repository at this point in the history
* chore: apply clippy suggestions

* docs: update examples

* chore: apply clippy suggestion

* chore: bump version to v0.2.0
  • Loading branch information
Chojan Shang authored Aug 17, 2022
1 parent 1287c32 commit a873ec4
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 40 deletions.
4 changes: 2 additions & 2 deletions clickhouse/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "opensrv-clickhouse"
version = "0.1.0"
version = "0.2.0"
authors = ["Databend Authors <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
Expand All @@ -26,7 +26,7 @@ chrono-tz = "0.6.1"
combine = "4.6.3"
hostname = "0.3.1"
lz4 = "1.23.2"
micromarshal = "0.1.0"
micromarshal = { version = "0.2.0" , path = "../components/micromarshal"}
naive-cityhash = "0.2.0"
once_cell = "1.9.0"
thiserror = "1.0.30"
Expand Down
30 changes: 3 additions & 27 deletions clickhouse/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ See the full example [here](./examples/simple.rs)
```rust
struct Session {
last_progress_send: Instant,
metadata: ClickHouseMetadata,
}

#[async_trait::async_trait]
Expand Down Expand Up @@ -72,33 +73,8 @@ impl opensrv_clickhouse::ClickHouseSession for Session {
Ok(())
}

fn dbms_name(&self) -> &str {
"ClickHouse-X"
}

fn dbms_version_major(&self) -> u64 {
2021
}

fn dbms_version_minor(&self) -> u64 {
5
}

// the MIN_SERVER_REVISION for suggestions is 54406
fn dbms_tcp_protocol_version(&self) -> u64 {
54405
}

fn timezone(&self) -> &str {
"UTC"
}

fn server_display_name(&self) -> &str {
"ClickHouse-X"
}

fn dbms_version_patch(&self) -> u64 {
0
fn metadata(&self) -> &ClickHouseMetadata {
&self.metadata
}

fn get_progress(&self) -> Progress {
Expand Down
2 changes: 1 addition & 1 deletion clickhouse/src/types/column/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ pub fn new_column<K: ColumnType>(
}
}

#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Either<L, R>
where
L: fmt::Debug + PartialEq + Clone,
Expand Down
3 changes: 3 additions & 0 deletions clickhouse/src/types/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ impl convert::From<Certificate> for native_tls::Certificate {
}

/// Clickhouse connection options.
// the trait `std::cmp::Eq` is not implemented for `types::options::Certificate`
// so we can't use `derive(Eq)` in tls feature.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq)]
pub struct Options {
/// Address of clickhouse server (defaults to `127.0.0.1:9000`).
Expand Down
2 changes: 1 addition & 1 deletion clickhouse/src/types/value_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ impl<'a> From<&'a Value> for ValueRef<'a> {
let value_ref: ValueRef<'a> = From::from(v);
ref_vec.push(value_ref)
}
ValueRef::Array(*t, Arc::new(ref_vec))
ValueRef::Array(t, Arc::new(ref_vec))
}
Value::Decimal(v) => ValueRef::Decimal(v.clone()),
Value::Enum8(values, v) => ValueRef::Enum8(values.to_vec(), *v),
Expand Down
2 changes: 1 addition & 1 deletion components/micromarshal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "micromarshal"
version = "0.1.0"
version = "0.2.0"
authors = ["Databend Authors <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
4 changes: 4 additions & 0 deletions components/micromarshal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

Submit [issues](https://github.com/datafuselabs/opensrv/issues/new/choose) for bug report or asking questions in [discussion](https://github.com/datafuselabs/opensrv/discussions/new?category=q-a).

## Tips

As the functionality of this crate is largely stable, its version will mostly just change as other crates change.

## Credits

This project is extracted from the Databend's common-io module. Now released as a separate crate.
Expand Down
12 changes: 7 additions & 5 deletions mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,23 @@ all commands with a "no results" reply:

```rust
use std::io;
use tokio::io::AsyncWrite;

use opensrv_mysql::*;
use tokio::net::TcpListener;

struct Backend;

#[async_trait::async_trait]
impl<W: io::Write + Send> AsyncMysqlShim<W> for Backend {
impl<W: AsyncWrite + Send + Unpin> AsyncMysqlShim<W> for Backend {
type Error = io::Error;

async fn on_prepare<'a>(
&'a mut self,
_: &'a str,
info: StatementMetaWriter<'a, W>,
) -> io::Result<()> {
info.reply(42, &[], &[])
info.reply(42, &[], &[]).await
}

async fn on_execute<'a>(
Expand All @@ -42,7 +43,7 @@ impl<W: io::Write + Send> AsyncMysqlShim<W> for Backend {
_: opensrv_mysql::ParamParser<'a>,
results: QueryResultWriter<'a, W>,
) -> io::Result<()> {
results.completed(OkResponse::default())
results.completed(OkResponse::default()).await
}

async fn on_close(&mut self, _: u32) {}
Expand All @@ -53,7 +54,7 @@ impl<W: io::Write + Send> AsyncMysqlShim<W> for Backend {
results: QueryResultWriter<'a, W>,
) -> io::Result<()> {
println!("execute sql {:?}", sql);
results.start(&[])?.finish()
results.start(&[]).await?.finish().await
}
}

Expand All @@ -63,7 +64,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

loop {
let (stream, _) = listener.accept().await?;
tokio::spawn(async move { AsyncMysqlIntermediary::run_on(Backend, stream).await });
let (r, w) = stream.into_split();
tokio::spawn(async move { AsyncMysqlIntermediary::run_on(Backend, r, w).await });
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion mysql/src/packet_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<'a> AsRef<[u8]> for Packet<'a> {
if self.1.is_empty() {
self.0
} else {
&*self.1
&self.1
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions mysql/src/value/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,10 @@ impl ToMysqlValue for [u8] {

impl ToMysqlValue for Vec<u8> {
fn to_mysql_text<W: Write>(&self, w: &mut W) -> io::Result<()> {
(&self[..]).to_mysql_text(w)
(self[..]).to_mysql_text(w)
}
fn to_mysql_bin<W: Write>(&self, w: &mut W, c: &Column) -> io::Result<()> {
(&self[..]).to_mysql_bin(w, c)
(self[..]).to_mysql_bin(w, c)
}
}

Expand Down

0 comments on commit a873ec4

Please sign in to comment.