You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/11/21 08:28:13 UTC

[GitHub] [dubbo-rust] Rianico opened a new pull request, #79: Ftr: Add the ClusterFilter

Rianico opened a new pull request, #79:
URL: https://github.com/apache/dubbo-rust/pull/79

   Currently, the `ClusterFilter` is implemented as a tower's `Layer`, which can let us take full advantage of the other middleware provided by `tower-http`.  
   
   close: #78 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-rust] Rianico commented on a diff in pull request #79: Ftr: Add the ClusterFilter

Posted by GitBox <gi...@apache.org>.
Rianico commented on code in PR #79:
URL: https://github.com/apache/dubbo-rust/pull/79#discussion_r1028174964


##########
dubbo/src/filter/mod.rs:
##########
@@ -14,11 +14,85 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+//! Filters which can preprocess or postprocess request.  
+//!
+//! TODO: Add the `ClusterFilter` according to the name.  
+//!
+//! # Example
+//! ## ClusterFilter
+//! ```no_run
+//! const USER_AGENT: &str = "user-agent";
+//! const USER_AGENT_VAL: &str = "dubbo-test";
+//! const USER_AGENT_VAL_2: &str = "dubbo-test-2";
+//!
+//! #[derive(Clone, Copy)]
+//! struct MyFilter;
+//!
+//! impl ClusterFilter for MyFilter1 {
+//!     fn call(&mut self, req: Request<()>) -> Result<Request<()>, crate::status::Status> {
+//!         req.metadata_mut().get_mut().insert(
+//!             USER_AGENT.to_string(),
+//!             USER_AGENT_VAL.to_string(),
+//!         );
+//!         Ok::<_, Status>(req)
+//!     }
+//! }
+//!
+//! impl ClusterFilter for MyFilter2 {
+//!     fn call(&mut self, req: Request<()>) -> Result<Request<()>, crate::status::Status> {
+//!         assert_eq!(
+//!             req.metadata()
+//!                 .get_ref()
+//!                 .get(USER_AGENT)
+//!                 .expect("missing user-agent."),
+//!             USER_AGENT_VAL
+//!         );
+//!         req.metadata_mut().get_mut().insert(
+//!             USER_AGENT.to_string(),
+//!             USER_AGENT_VAL_2.to_string(),
+//!         );
+//!         Ok::<_, Status>(req)
+//!     }
+//! }
+//!
+//! #[tokio::main]
+//! async fn main() {
+//!    let svc = service_fn(|req: http::Request<BoxBody>| async move {
+//!        assert_eq!(
+//!            req.headers().get(USER_AGENT).map(|v| v.to_str().unwrap()),
+//!            Some(USER_AGENT_VAL_2)
+//!        );
+//!        Ok::<_, Status>(http::Response::new(empty_body()))
+//!    });
+//!    let svc = ServiceBuilder::new()
+//!        .layer(cluster_filter(MyFilter1))
+//!        .layer(cluster_filter(MyFilter2))
+//!        .service(svc);
+//!    let req = http::Request::builder()
+//!        .body(empty_body())
+//!        .unwrap();
+//!    svc.oneshot(req).await.unwrap();
+//! }
+//! ```
 
-pub mod service;
+use crate::codegen::Request;

Review Comment:
   Ok, I have change it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-rust] yang20150702 commented on pull request #79: Ftr: Add the ClusterFilter

Posted by GitBox <gi...@apache.org>.
yang20150702 commented on PR #79:
URL: https://github.com/apache/dubbo-rust/pull/79#issuecomment-1322843978

   LGTM


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-rust] yang20150702 commented on a diff in pull request #79: Ftr: Add the ClusterFilter

Posted by GitBox <gi...@apache.org>.
yang20150702 commented on code in PR #79:
URL: https://github.com/apache/dubbo-rust/pull/79#discussion_r1028129363


##########
dubbo/src/filter/mod.rs:
##########
@@ -14,11 +14,85 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+//! Filters which can preprocess or postprocess request.  
+//!
+//! TODO: Add the `ClusterFilter` according to the name.  
+//!
+//! # Example
+//! ## ClusterFilter
+//! ```no_run
+//! const USER_AGENT: &str = "user-agent";
+//! const USER_AGENT_VAL: &str = "dubbo-test";
+//! const USER_AGENT_VAL_2: &str = "dubbo-test-2";
+//!
+//! #[derive(Clone, Copy)]
+//! struct MyFilter;
+//!
+//! impl ClusterFilter for MyFilter1 {
+//!     fn call(&mut self, req: Request<()>) -> Result<Request<()>, crate::status::Status> {
+//!         req.metadata_mut().get_mut().insert(
+//!             USER_AGENT.to_string(),
+//!             USER_AGENT_VAL.to_string(),
+//!         );
+//!         Ok::<_, Status>(req)
+//!     }
+//! }
+//!
+//! impl ClusterFilter for MyFilter2 {
+//!     fn call(&mut self, req: Request<()>) -> Result<Request<()>, crate::status::Status> {
+//!         assert_eq!(
+//!             req.metadata()
+//!                 .get_ref()
+//!                 .get(USER_AGENT)
+//!                 .expect("missing user-agent."),
+//!             USER_AGENT_VAL
+//!         );
+//!         req.metadata_mut().get_mut().insert(
+//!             USER_AGENT.to_string(),
+//!             USER_AGENT_VAL_2.to_string(),
+//!         );
+//!         Ok::<_, Status>(req)
+//!     }
+//! }
+//!
+//! #[tokio::main]
+//! async fn main() {
+//!    let svc = service_fn(|req: http::Request<BoxBody>| async move {
+//!        assert_eq!(
+//!            req.headers().get(USER_AGENT).map(|v| v.to_str().unwrap()),
+//!            Some(USER_AGENT_VAL_2)
+//!        );
+//!        Ok::<_, Status>(http::Response::new(empty_body()))
+//!    });
+//!    let svc = ServiceBuilder::new()
+//!        .layer(cluster_filter(MyFilter1))
+//!        .layer(cluster_filter(MyFilter2))
+//!        .service(svc);
+//!    let req = http::Request::builder()
+//!        .body(empty_body())
+//!        .unwrap();
+//!    svc.oneshot(req).await.unwrap();
+//! }
+//! ```
 
-pub mod service;
+use crate::codegen::Request;

Review Comment:
   suggest that use crate::invocation::Request
   codegen mod is usually used  for external references.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-rust] yang20150702 merged pull request #79: Ftr: Add the ClusterFilter

Posted by GitBox <gi...@apache.org>.
yang20150702 merged PR #79:
URL: https://github.com/apache/dubbo-rust/pull/79


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org