Skip to content

Commit 96239c1

Browse files
committed
resolve comments
1 parent 06b84b0 commit 96239c1

File tree

2 files changed

+7
-47
lines changed

2 files changed

+7
-47
lines changed

internal/provider/adc/cache/schema.go

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -79,42 +79,3 @@ var (
7979
},
8080
}
8181
)
82-
83-
/*
84-
"ssl": {
85-
Name: "ssl",
86-
Indexes: map[string]*memdb.IndexSchema{
87-
"id": {
88-
Name: "id",
89-
Unique: true,
90-
Indexer: &memdb.StringFieldIndex{Field: "ID"},
91-
},
92-
KindLabelIndex: {
93-
Name: KindLabelIndex,
94-
Unique: false,
95-
AllowMissing: true,
96-
Indexer: &KindLabelIndexer,
97-
},
98-
},
99-
},
100-
"global_rule": {
101-
Name: "global_rule",
102-
Indexes: map[string]*memdb.IndexSchema{
103-
"id": {
104-
Name: "id",
105-
Unique: true,
106-
Indexer: &memdb.StringFieldIndex{Field: "ID"},
107-
},
108-
"name": {
109-
Name: "name",
110-
Unique: true,
111-
Indexer: &memdb.StringFieldIndex{Field: "Name"},
112-
AllowMissing: true,
113-
},
114-
},
115-
},
116-
117-
},
118-
}
119-
)
120-
*/

internal/provider/adc/store.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,20 @@ type Store struct {
1515
globalruleMap map[string]adctypes.GlobalRule
1616
pluginMetadataMap map[string]adctypes.PluginMetadata
1717

18-
mux *sync.Mutex
18+
sync.Mutex
1919
}
2020

2121
func NewStore() *Store {
2222
return &Store{
2323
cacheMap: make(map[string]cache.Cache),
2424
globalruleMap: make(map[string]adctypes.GlobalRule),
2525
pluginMetadataMap: make(map[string]adctypes.PluginMetadata),
26-
mux: &sync.Mutex{},
2726
}
2827
}
2928

3029
func (s *Store) Insert(name string, resourceTypes []string, resources adctypes.Resources, Labels map[string]string) error {
31-
s.mux.Lock()
32-
defer s.mux.Unlock()
30+
s.Lock()
31+
defer s.Unlock()
3332
targetCache, ok := s.cacheMap[name]
3433
if !ok {
3534
db, err := cache.NewMemDBCache()
@@ -105,8 +104,8 @@ func (s *Store) Insert(name string, resourceTypes []string, resources adctypes.R
105104
}
106105

107106
func (s *Store) Delete(name string, resourceTypes []string, Labels map[string]string) error {
108-
s.mux.Lock()
109-
defer s.mux.Unlock()
107+
s.Lock()
108+
defer s.Unlock()
110109
targetCache, ok := s.cacheMap[name]
111110
if !ok {
112111
return nil
@@ -160,8 +159,8 @@ func (s *Store) Delete(name string, resourceTypes []string, Labels map[string]st
160159
}
161160

162161
func (s *Store) GetResources(name string) (*adctypes.Resources, error) {
163-
s.mux.Lock()
164-
defer s.mux.Unlock()
162+
s.Lock()
163+
defer s.Unlock()
165164
targetCache, ok := s.cacheMap[name]
166165
if !ok {
167166
return nil, nil

0 commit comments

Comments
 (0)