dubbo_config/provider.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 std::collections::HashMap;
19
20use serde::{Deserialize, Serialize};
21
22use super::service::ServiceConfig;
23
24#[derive(Debug, Default, Serialize, Deserialize, Clone)]
25pub struct ProviderConfig {
26 #[serde(default)]
27 pub registry_ids: Vec<String>,
28 #[serde(default)]
29 pub protocol_ids: Vec<String>,
30 #[serde(default)]
31 pub services: HashMap<String, ServiceConfig>,
32}
33
34impl ProviderConfig {
35 pub fn new() -> Self {
36 ProviderConfig {
37 registry_ids: vec![],
38 protocol_ids: vec![],
39 services: HashMap::new(),
40 }
41 }
42
43 pub fn with_registry_ids(mut self, registry_ids: Vec<String>) -> Self {
44 self.registry_ids = registry_ids;
45 self
46 }
47
48 pub fn with_protocol_ids(mut self, protocol_ids: Vec<String>) -> Self {
49 self.protocol_ids = protocol_ids;
50 self
51 }
52
53 pub fn with_services(mut self, services: HashMap<String, ServiceConfig>) -> Self {
54 self.services = services;
55 self
56 }
57}