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

Moving plugin traits to top module such as to isolate plugin implementation details #58

Merged
merged 1 commit into from
Oct 9, 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
6 changes: 3 additions & 3 deletions did-endpoint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
async-trait = "0.1.73"
axum = { version = "0.6.20" }
chrono = { version = "0.4.26" }
did-utils = { path = "../did-utils"}
dotenv-flow = "0.15.0"
hyper = { version = "0.14.27", features = ["full"] }
lazy_static = "1.4.0"
multibase = { version = "0.8.0" } # earlier version due to 'did-utils'
serde_json = "1.0.104"
thiserror = "1.0.49"
tokio = { version = "1.30.0", features = ["full"] }
tower-http = { version = "0.4.3" }
tracing = "0.1.37"
url = { version = "2.4.0" }
uuid = { version = "1.4.1", features = ["v4"] }
zeroize = { version = "1.6.0" }

# Plugins traits
server-plugin = { path = "../server-plugin" }

[dev-dependencies]
json-canon = "0.1.3"
tower = { version = "0.4.13", features = ["util"] }
1 change: 1 addition & 0 deletions did-endpoint/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod didgen;
pub mod web;
pub mod plugin;

mod util;
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use axum::Router;
use did_endpoint::{didgen, web};

use super::traits::{Plugin, PluginError};
use super::{didgen, web};
use server_plugin::{Plugin, PluginError};

#[derive(Default)]
pub struct DidEndpointPlugin;
Expand Down
3 changes: 3 additions & 0 deletions generic-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ tower-http = { version = "0.4.3", features = ["catch-panic", "trace"] }
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.17", features = ["json"] }

# Plugins traits
server-plugin = { path = "../server-plugin" }

# optional
chrono = { version = "0.4.26", optional = true }
did-endpoint = { path = "../did-endpoint", optional = true }
Expand Down
29 changes: 0 additions & 29 deletions generic-server/src/bin/didgen.rs

This file was deleted.

6 changes: 2 additions & 4 deletions generic-server/src/plugin/container.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use std::collections::{HashMap, HashSet};

use axum::Router;
use server_plugin::{Plugin, PluginError};

use super::{
traits::{Plugin, PluginError},
PLUGINS,
};
use super::PLUGINS;

#[derive(Debug, PartialEq)]
pub enum PluginContainerError {
Expand Down
3 changes: 1 addition & 2 deletions generic-server/src/plugin/index/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
mod web;

use axum::Router;

use super::traits::{Plugin, PluginError};
use server_plugin::{Plugin, PluginError};

#[derive(Default)]
pub struct IndexPlugin;
Expand Down
8 changes: 2 additions & 6 deletions generic-server/src/plugin/mod.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
pub mod container;
pub mod traits;

use lazy_static::lazy_static;
use traits::Plugin;
use server_plugin::Plugin;

#[cfg(feature = "plugin-index")]
mod index;

#[cfg(feature = "plugin-did_endpoint")]
mod did_endpoint;

lazy_static! {
pub static ref PLUGINS: Vec<Box<dyn Plugin>> = vec![
#[cfg(feature = "plugin-index")]
Box::<index::IndexPlugin>::default(),
#[cfg(feature = "plugin-did_endpoint")]
Box::<did_endpoint::DidEndpointPlugin>::default(),
Box::<did_endpoint::plugin::DidEndpointPlugin>::default(),
];
}
2 changes: 1 addition & 1 deletion run_test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
for dir in ./did-utils/ ./did-endpoint/ ./generic-server/ ./mediator-server/
for dir in ./did-utils/ ./did-endpoint/ ./generic-server/
do
cd "${dir}"
if [ -f Cargo.toml ]; then
Expand Down
9 changes: 9 additions & 0 deletions server-plugin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "server-plugin"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
axum = { version = "0.6.20" }
File renamed without changes.