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

Ftr: add extension module #181

Merged
merged 10 commits into from
Mar 15, 2024
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
7 changes: 7 additions & 0 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ jobs:
- 2181:2181
env:
ZOO_MY_ID: 1
nacos:
image: nacos/nacos-server:v2.3.1
ports:
- 8848:8848
- 9848:9848
env:
MODE: standalone
steps:
- uses: actions/checkout@main
- uses: actions-rs/toolchain@v1
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ serde_yaml = "0.9.4" # yaml file parser
once_cell = "1.16.0"
itertools = "0.10.1"
bytes = "1.0"
url = "2.5.0"



5 changes: 2 additions & 3 deletions common/base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
urlencoding.workspace = true
http = "0.2"
dubbo-logger.workspace = true
dubbo-logger.workspace = true
url.workspace = true
85 changes: 85 additions & 0 deletions common/base/src/extension_param.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use crate::{url::UrlParam, StdError};
use std::{borrow::Cow, convert::Infallible, str::FromStr};

pub struct ExtensionName(String);

impl ExtensionName {
pub fn new(name: String) -> Self {
ExtensionName(name)
}
}

impl UrlParam for ExtensionName {
type TargetType = String;

fn name() -> &'static str {
"extension-name"
}

fn value(&self) -> Self::TargetType {
self.0.clone()
}

fn as_str(&self) -> Cow<str> {
self.0.as_str().into()
}
}

impl FromStr for ExtensionName {
type Err = StdError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(ExtensionName::new(s.to_string()))
}
}

pub enum ExtensionType {
Registry,
}

impl UrlParam for ExtensionType {
type TargetType = String;

fn name() -> &'static str {
"extension-type"
}

fn value(&self) -> Self::TargetType {
match self {
ExtensionType::Registry => "registry".to_owned(),
}
}

fn as_str(&self) -> Cow<str> {
match self {
ExtensionType::Registry => Cow::Borrowed("registry"),
}
}
}

impl FromStr for ExtensionType {
type Err = Infallible;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"registry" => Ok(ExtensionType::Registry),
_ => panic!("the extension type enum is not in range"),
}
}
}
4 changes: 4 additions & 0 deletions common/base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
allow(dead_code, unused_imports, unused_variables, unused_mut)
)]
pub mod constants;
pub mod extension_param;
pub mod node;
pub mod registry_param;
pub mod url;

pub use node::Node;
pub use url::Url;

pub type StdError = Box<dyn std::error::Error + Send + Sync + 'static>;
Loading
Loading