-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ add individual config to services
- Loading branch information
1 parent
e22afe0
commit ea6e075
Showing
19 changed files
with
227 additions
and
33 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ members = [ | |
"crates/rsjudge-rabbitmq", | ||
"crates/rsjudge-rest", | ||
"crates/rsjudge-runner", | ||
"crates/rsjudge-traits", | ||
"crates/rsjudge-utils", | ||
"xtask", | ||
] | ||
|
@@ -48,8 +49,8 @@ assets = [ | |
"644", | ||
], | ||
[ | ||
"templates/server.toml", | ||
"etc/rsjudge/server.toml", | ||
"templates/services.toml", | ||
"etc/rsjudge/services.toml", | ||
"644", | ||
], | ||
[ | ||
|
@@ -81,7 +82,7 @@ assets = [ | |
copyright = "2023-2024 NJUPT-SAST" | ||
changelog = "packaging/deb/changelog" | ||
features = ["default"] | ||
conf-files = ["/etc/rsjudge/server.toml", "/etc/rsjudge/executors.toml"] | ||
conf-files = ["/etc/rsjudge/services.toml", "/etc/rsjudge/executors.toml"] | ||
extended-description = "An online judge sandbox server in Rust, inspired by go-judge, for SASTOJ." | ||
maintainer = "Xiaoqing Xuan <[email protected]>" | ||
maintainer-scripts = "packaging/deb/" | ||
|
@@ -152,24 +153,24 @@ clap = { version = "4.5.4", features = ["derive"] } | |
env_logger = "0.11.3" | ||
log.workspace = true | ||
mimalloc = "0.1.39" | ||
serde = { version = "1.0.197", features = ["derive"] } | ||
sysinfo = { version = "0.30.10", features = ["serde"] } | ||
tokio = { version = "1.37.0", features = ["fs", "rt-multi-thread", "macros", "process"] } | ||
toml = "0.8.12" | ||
|
||
# Unused for now: | ||
# nix = { version = "0.27.1", features = ["fs"] } | ||
# serde = { version = "1.0.197", features = ["derive"] } | ||
# strfmt = "0.2.4" | ||
# uzers = "0.11.3" | ||
|
||
# [dev-dependencies] | ||
# tokio = { version = "1.37.0", features = ["rt-multi-thread", "macros"] } | ||
|
||
[features] | ||
grpc = ["dep:rsjudge-grpc"] | ||
grpc = ["dep:rsjudge-grpc", "rsjudge-grpc/serde"] | ||
rest = ["dep:rsjudge-rest"] | ||
rabbitmq = ["dep:rsjudge-rabbitmq"] | ||
default = ["grpc"] | ||
rabbitmq = ["dep:rsjudge-rabbitmq", "rsjudge-rabbitmq/serde"] | ||
default = ["grpc", "rest", "rabbitmq"] | ||
|
||
[build-dependencies] | ||
clap = { version = "4.5.4", features = ["derive"] } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use std::net::SocketAddr; | ||
|
||
#[derive(Debug, PartialEq)] | ||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] | ||
pub struct GrpcConfig { | ||
pub listen: Vec<SocketAddr>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#[derive(Debug, Clone)] | ||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] | ||
pub struct RabbitMqConfig { | ||
pub uri: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use std::net::SocketAddr; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Deserialize, PartialEq, Serialize)] | ||
pub struct RestConfig { | ||
pub listen: Vec<SocketAddr>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
[package] | ||
name = "rsjudge-traits" | ||
version.workspace = true | ||
authors.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
repository.workspace = true | ||
rust-version.workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
async-trait = "0.1.80" | ||
serde = "1.0.198" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pub trait Judger { | ||
type Result; | ||
fn accept_languages(&self) -> Vec<String>; | ||
fn judge(&self, lang: &str, code: &str, input: &str) -> Self::Result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
mod judger; | ||
mod service; | ||
|
||
pub use crate::{judger::Judger, service::Service}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use async_trait::async_trait; | ||
use serde::de::DeserializeOwned; | ||
|
||
use crate::Judger; | ||
|
||
#[async_trait] | ||
pub trait Service<J, C> | ||
where | ||
J: Judger, | ||
C: Config, | ||
{ | ||
type Result; | ||
async fn startup(&mut self, judger: J, config: C) -> Self::Result; | ||
async fn shutdown(&mut self); | ||
} | ||
|
||
pub trait Config: DeserializeOwned {} |
Oops, something went wrong.