dubbo_config/
service.rs

1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18use serde::{Deserialize, Serialize};
19
20#[derive(Debug, Default, Serialize, Deserialize, Clone)]
21pub struct ServiceConfig {
22    pub version: String,
23    pub group: String,
24    pub protocol: String,
25    pub interface: String,
26}
27
28impl ServiceConfig {
29    pub fn interface(self, interface: String) -> Self {
30        Self { interface, ..self }
31    }
32
33    pub fn version(self, version: String) -> Self {
34        Self { version, ..self }
35    }
36
37    pub fn group(self, group: String) -> Self {
38        Self { group, ..self }
39    }
40
41    pub fn protocol(self, protocol: String) -> Self {
42        Self { protocol, ..self }
43    }
44
45    // pub fn get_url(&self) -> Vec<Url> {
46    //     let mut urls = Vec::new();
47    //     for (_, conf) in self.protocol_configs.iter() {
48    //         urls.push(Url {
49    //             url: conf.to_owned().to_url(),
50    //             service_key: "".to_string(),
51    //         });
52    //     }
53
54    //     urls
55    // }
56}