Skip to content
This repository has been archived by the owner on Dec 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #15 from naomijub/issue-4/put_delete_evict
Browse files Browse the repository at this point in the history
Issue 4/ put-delete-evict transactions
  • Loading branch information
naomijub authored May 22, 2023
2 parents 715b6ef + 65b78f9 commit 786f793
Show file tree
Hide file tree
Showing 28 changed files with 1,622 additions and 133 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ "*" ]

env:
cd gxtdb-rs && CARGO_TERM_COLOR: always
CARGO_TERM_COLOR: always

jobs:
build:
Expand All @@ -20,7 +20,7 @@ jobs:
- name: Install alsa and udev
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
- name: Build
run: cd gxtdb-rs && cargo build --all-features --release --verbose
run: cargo build --all-features --release --verbose

test:
runs-on: ubuntu-latest
Expand All @@ -32,15 +32,15 @@ jobs:
- name: Install alsa and udev
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
- name: tests
run: cd gxtdb-rs && cargo test --all-features -- --nocapture
run: cargo test --all-features -- --nocapture

fmt:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: FMT
run: cd gxtdb-rs && cargo fmt -- --check
run: cargo fmt -- --check

clippy:
runs-on: ubuntu-latest
Expand All @@ -54,4 +54,4 @@ jobs:
- name: install-clippy
run: rustup component add clippy
- name: clippy
run: cd gxtdb-rs && cargo clippy --all-features -- -W clippy::all --deny "warnings"
run: cargo clippy --all-features -- -W clippy::all --deny "warnings"
77 changes: 39 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[workspace]
members=["gxtdb-rs"]
members = ["gxtdb-rs"]
23 changes: 21 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
all:
protoc --clojure_out=grpc-client,grpc-server:src --proto_path=resources resources/service.proto
fmt:
lein cljfmt fix

kibit:
lein kibit --replace

lint: fmt kibit

proto:
protoc --clojure_out=grpc-client,grpc-server:src --proto_path=resources resources/transactions.proto resources/service.proto

all: proto lint

run:
lein run

jar:
lein uberjar

test:
lein test
7 changes: 0 additions & 7 deletions gxtdb-rs/Cargo.lock

This file was deleted.

9 changes: 8 additions & 1 deletion gxtdb-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::configure()
.build_server(true)
.compile_well_known_types(true)
.compile(&["../resources/service.proto"], &["../resources/"])?;
.include_file("mod.rs")
.compile(
&[
"../resources/service.proto",
"../resources/transactions.proto",
],
&["../resources/"],
)?;
Ok(())
}
21 changes: 13 additions & 8 deletions gxtdb-rs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
pub mod api {
tonic::include_proto!("com.xtdb.protos");
mod api {
#![allow(clippy::enum_variant_names)]
tonic::include_proto!("mod");
}

use api::{grpc_api_client::GrpcApiClient, Empty};
pub use crate::api::com::xtdb::protos as proto_api;
use crate::api::com::xtdb::protos::{grpc_api_client::GrpcApiClient, Empty};

use tonic::transport::Channel;

impl From<api::OptionString> for Option<String> {
fn from(value: api::OptionString) -> Self {
impl From<proto_api::OptionString> for Option<String> {
fn from(value: proto_api::OptionString) -> Self {
value.value.and_then(|val| match val {
api::option_string::Value::None(_) => None,
api::option_string::Value::Some(s) => Some(s),
proto_api::option_string::Value::None(_) => None,
proto_api::option_string::Value::Some(s) => Some(s),
})
}
}
Expand All @@ -33,7 +36,9 @@ impl Client {
}
}

pub async fn status(&mut self) -> Result<tonic::Response<api::StatusResponse>, tonic::Status> {
pub async fn status(
&mut self,
) -> Result<tonic::Response<proto_api::StatusResponse>, tonic::Status> {
let request = tonic::Request::new(Empty {});
self.client.status(request).await
}
Expand Down
8 changes: 4 additions & 4 deletions gxtdb-rs/tests/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
pub mod api {
tonic::include_proto!("com.xtdb.protos");
}
// pub mod api {
// tonic::include_proto!("com.xtdb.protos");
// }

pub mod mock;

#[tokio::test]
async fn test_status_response() {
let expected = gxtdb_rs::api::StatusResponse::default();
let expected = gxtdb_rs::proto_api::StatusResponse::default();
let mut client = mock::client().await;
let status = client.status().await.unwrap();
assert_eq!(status.into_inner(), expected);
Expand Down
Loading

0 comments on commit 786f793

Please sign in to comment.