Skip to content

Commit

Permalink
Ftr: add extension module (#181)
Browse files Browse the repository at this point in the history
* Ftr: add extension module

- adapt static registry by extension
- adapt nacos  registry by extension

link #180

* cargo fmt all

* fix ci error

* fix nacos image version error

* Rft: re-design extension register

* Fix: cargo fix

* Fix: add some license for every files

- extract UrlParam to single file
- fix github ci error

* Fix: fmt all

* Fix: Add license for extension_param.rs and registry_param.rs

* Fix: rename query_param_by_kv method name
  • Loading branch information
onewe authored Mar 15, 2024
1 parent ab18d57 commit 7ee9e73
Show file tree
Hide file tree
Showing 57 changed files with 2,398 additions and 1,258 deletions.
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

0 comments on commit 7ee9e73

Please sign in to comment.