1+ /*
2+ * Copyright The Kmesh Authors.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at:
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
117package workload
218
319import (
@@ -12,6 +28,10 @@ import (
1228 "kmesh.net/kmesh/pkg/dns"
1329)
1430
31+ const (
32+ WorkloadDnsRefreshRate = 200 * time .Millisecond // 200ms, used for workload dns refresh rate
33+ )
34+
1535type dnsController struct {
1636 workloadsChan chan []* workloadapi.Workload
1737 cache cache.WorkloadCache
@@ -70,7 +90,7 @@ func (r *dnsController) processDomains(workload []*workloadapi.Workload) {
7090 r .pendingHostnames [workloadName ] = []string {hostname }
7191 r .workloadCache [hostname ] = & pendingResolveDomain {
7292 Workloads : []* workloadapi.Workload {workload },
73- RefreshRate : 15 * time . Second ,
93+ RefreshRate : WorkloadDnsRefreshRate ,
7494 }
7595 }
7696
@@ -116,7 +136,7 @@ func (r *dnsController) refreshWorker(stop <-chan struct{}) {
116136
117137func (r * dnsController ) updateWorkloads (pendingDomain * pendingResolveDomain , domain string , addrs []string ) {
118138 isWorkerUpdate := false
119- if pendingDomain == nil || addrs == nil {
139+ if pendingDomain == nil || addrs == nil {
120140 return
121141 }
122142 log .Infof ("dnsController updateWorkloads: pendingDomain %v, domain %s, addrs %v" , pendingDomain , domain , addrs )
0 commit comments