Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replica listing based on query #80

Merged
merged 4 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk

/rust-toolchain.toml
/rust-toolchain.toml
.idea
.vscode
14 changes: 7 additions & 7 deletions nix/sources.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"nixpkgs": {
"branch": "release-22.05",
"branch": "release-23.05",
"description": "Nix Packages collection",
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b8720c8492d2ad2f892a6e0a0064d6da2969aba4",
"sha256": "0lpnfb94qyrv7sw8vjrpdlrrn2n2q75r93mc8q5afm5a0pdzrkax",
"rev": "d540c6348227dff41a708db5c0b70cc3018080ea",
"sha256": "10348aq69kvxf3zvkn60dh53l85prbjpr2k2i7ianl31lvrgyaw9",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/b8720c8492d2ad2f892a6e0a0064d6da2969aba4.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/d540c6348227dff41a708db5c0b70cc3018080ea.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"rust-overlay": {
Expand All @@ -17,10 +17,10 @@
"homepage": "",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "b4fb0f8454fe4e6ebb0a564a28a87cc88cc3cb2c",
"sha256": "01912q23pd67q4adsl6b1ayi3kn92w0daj2dvihajmh8239iplf3",
"rev": "8f6d56270ec028a340583111609b12663f5d7490",
"sha256": "1nc55v895m9q592jjsjk5n8mbm769dw82j1x6638g8qkk2rjv6al",
"type": "tarball",
"url": "https://github.com/oxalica/rust-overlay/archive/b4fb0f8454fe4e6ebb0a564a28a87cc88cc3cb2c.tar.gz",
"url": "https://github.com/oxalica/rust-overlay/archive/8f6d56270ec028a340583111609b12663f5d7490.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
17 changes: 8 additions & 9 deletions protobuf/v1/replica.proto
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,17 @@ message ListReplicasResponse {
repeated Replica replicas = 1; // list of the replicas
}

/// ReplicaType enum is used to filter replica in listreplica response.
enum ReplicaType {
AllReplicas = 0; // Default value, to return all the replicas including snapshots and clones
AllReplicasExceptSnapshots = 1; // Return replicas and snapshot clones, without snapshots
OnlySnapshotClones = 2; // Returns only snapshot clones
OnlyReplicas = 3; // Returns only replicas
}

message ListReplicaOptions {
google.protobuf.StringValue name = 1; // list the replica with the name if provided
google.protobuf.StringValue poolname = 2; // list the replicas on the provided pool, by name
google.protobuf.StringValue uuid = 3; // list the replica with the uuid if provided
google.protobuf.StringValue pooluuid = 4; // list the replicas on the provided pool, by uuid
ReplicaType replicatype = 5; // list replica based on ReplicaType value
Query query = 5; // list replica based on Query value

/// Query used for getting specific types of replicas. These are mutually exclusive, ex. a snapshot cannot be clone.
message Query {
bool replica = 1; // query for selecting or normal replica types.
bool snapshot = 2; // query for selecting or snapshot types.
bool clone = 3; // query for selecting or clone types.
}
}
2 changes: 1 addition & 1 deletion shell.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ profile ? "nightly", date ? "2022-06-22", rustup ? false }:
{ profile ? "nightly", date ? "2023-08-10", rustup ? false }:
let
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs {
Expand Down
7 changes: 3 additions & 4 deletions src/v1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
///!module to access v1 version of grpc APIs
//! Module to access v1 version of grpc APIs
use std::str::FromStr;
// dont export the raw pb generated code
mod pb {
Expand Down Expand Up @@ -41,12 +41,11 @@ pub mod pool {

pub mod replica {
pub use super::pb::{
destroy_replica_request,
destroy_replica_request, list_replica_options,
replica_rpc_client::ReplicaRpcClient,
replica_rpc_server::{ReplicaRpc, ReplicaRpcServer},
CreateReplicaRequest, DestroyReplicaRequest, ListReplicaOptions, ListReplicasResponse,
Replica, ReplicaSpaceUsage, ReplicaType, ShareReplicaRequest, SnapshotInfo,
UnshareReplicaRequest,
Replica, ReplicaSpaceUsage, ShareReplicaRequest, SnapshotInfo, UnshareReplicaRequest,
};
}
pub mod snapshot {
Expand Down
Loading