Skip to content

Commit e18346a

Browse files
committed
CR comment - rename directory and interfaces comments
1 parent 5f6ef19 commit e18346a

File tree

6 files changed

+53
-25
lines changed

6 files changed

+53
-25
lines changed
Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,6 @@ import (
2727
"github.com/nuclio/logger"
2828
)
2929

30-
type IngressHostsTree interface {
31-
SetFunctionName(path string, function string) error // will overwrite existing values if exists
32-
DeleteFunctionName(path string, function string) error
33-
GetFunctionName(path string) ([]string, error)
34-
IsEmpty() bool
35-
}
36-
37-
type IngressHostCache interface {
38-
Set(host string, path string, function string) error // will overwrite existing values if exists
39-
Delete(host string, path string, function string) error
40-
Get(host string, path string) ([]string, error)
41-
}
42-
4330
type IngressCache struct {
4431
syncMap *sync.Map
4532
logger logger.Logger
@@ -115,7 +102,7 @@ func (ic *IngressCache) Get(host, path string) ([]string, error) {
115102
return nil, errors.Errorf("cache get failed: invalid path tree value: got: %t", urlTree)
116103
}
117104

118-
result, err := ingressHostsTree.GetFunctionName(path)
105+
result, err := ingressHostsTree.GetFunctionNames(path)
119106
if err != nil {
120107
return nil, errors.Wrap(err, "cache get failed")
121108
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ package ingresscache
2323
import (
2424
"testing"
2525

26-
"github.com/v3io/scaler/pkg/ingressCache/mock"
26+
"github.com/v3io/scaler/pkg/ingresscache/mock"
2727

2828
"github.com/nuclio/errors"
2929
"github.com/nuclio/logger"
@@ -85,7 +85,7 @@ func (suite *IngressCacheTest) TestGet() {
8585
expectedResult: []string{testFunctionName1, testFunctionName2},
8686
testMocks: func() *mock.SafeTrie {
8787
m := &mock.SafeTrie{}
88-
m.On("GetFunctionName", testPath).Return([]string{testFunctionName1, testFunctionName2}, nil)
88+
m.On("GetFunctionNames", testPath).Return([]string{testFunctionName1, testFunctionName2}, nil)
8989
return m
9090
},
9191
}, {
@@ -94,7 +94,7 @@ func (suite *IngressCacheTest) TestGet() {
9494
expectedResult: []string{testFunctionName1},
9595
testMocks: func() *mock.SafeTrie {
9696
m := &mock.SafeTrie{}
97-
m.On("GetFunctionName", testPath).Return([]string{testFunctionName1}, nil)
97+
m.On("GetFunctionNames", testPath).Return([]string{testFunctionName1}, nil)
9898
return m
9999
},
100100
}, {
@@ -143,7 +143,7 @@ func (suite *IngressCacheTest) TestSet() {
143143
args: testIngressCacheArgs{testHost, testPath, testFunctionName2},
144144
testMocks: func() *mock.SafeTrie {
145145
m := &mock.SafeTrie{}
146-
m.On("GetFunctionName", testPath).Return([]string{testFunctionName1}, nil).Once()
146+
m.On("GetFunctionNames", testPath).Return([]string{testFunctionName1}, nil).Once()
147147
m.On("SetFunctionName", testPath, testFunctionName2).Return(nil).Once()
148148
return m
149149
},
@@ -216,7 +216,7 @@ func (suite *IngressCacheTest) TestDelete() {
216216
testMocks: func() *mock.SafeTrie {
217217
m := &mock.SafeTrie{}
218218
m.On("DeleteFunctionName", testPath, testFunctionName2).Return(errors.New("mock error")).Once()
219-
m.On("GetFunctionName", testPath).Return([]string{testFunctionName2}, nil).Once()
219+
m.On("GetFunctionNames", testPath).Return([]string{testFunctionName2}, nil).Once()
220220
return m
221221
},
222222
getAfterDeleteArgs: []getFunctionAfterDeleteArgs{
@@ -234,7 +234,7 @@ func (suite *IngressCacheTest) TestDelete() {
234234
m := &mock.SafeTrie{}
235235
m.On("DeleteFunctionName", testPath, testFunctionName2).Return(nil).Once()
236236
m.On("IsEmpty").Return(false).Once()
237-
m.On("GetFunctionName", testPath).Return([]string{testFunctionName1}, nil).Once()
237+
m.On("GetFunctionNames", testPath).Return([]string{testFunctionName1}, nil).Once()
238238
return m
239239
},
240240
getAfterDeleteArgs: []getFunctionAfterDeleteArgs{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (_m *SafeTrie) DeleteFunctionName(path string, function string) error {
5656
}
5757

5858
//nolint:gocritic, // this function is being generated by mockery
59-
func (_m *SafeTrie) GetFunctionName(path string) ([]string, error) {
59+
func (_m *SafeTrie) GetFunctionNames(path string) ([]string, error) {
6060
ret := _m.Called(path)
6161

6262
var r0 []string
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ func (st *SafeTrie) DeleteFunctionName(path string, function string) error {
107107
return nil
108108
}
109109

110-
// GetFunctionName retrieve the closest prefix matching the path and returns the associated functions
111-
func (st *SafeTrie) GetFunctionName(path string) ([]string, error) {
110+
// GetFunctionNames retrieve the closest prefix matching the path and returns the associated functions
111+
func (st *SafeTrie) GetFunctionNames(path string) ([]string, error) {
112112
var walkPathResult interface{}
113113
if path == "" {
114114
return nil, errors.New("path is empty")
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ func (suite *SafeTrieTest) TestPathTreeGet() {
274274
{testPathWithMultipleFunctions, testFunctionName2},
275275
})
276276
suite.Run(testCase.name, func() {
277-
result, err := suite.safeTrie.GetFunctionName(testCase.arg)
277+
result, err := suite.safeTrie.GetFunctionNames(testCase.arg)
278278
if testCase.shouldFail {
279279
suite.Require().Error(err)
280280
suite.Require().Contains(err.Error(), testCase.errorMessage)
@@ -390,7 +390,7 @@ func (suite *SafeTrieTest) TestPathTreeDelete() {
390390

391391
// After delete, check that the expected paths and functions are still there
392392
for _, getAfterDeleteArgs := range testCase.getFunctionAfterDeleteArgs {
393-
result, err := suite.safeTrie.GetFunctionName(getAfterDeleteArgs.path)
393+
result, err := suite.safeTrie.GetFunctionNames(getAfterDeleteArgs.path)
394394
if getAfterDeleteArgs.shouldFail {
395395
suite.Require().Error(err)
396396
suite.Require().Contains(err.Error(), getAfterDeleteArgs.errorMessage)

pkg/ingresscache/types.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright 2025 Iguazio Systems Ltd.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License") with
5+
an addition restriction as set forth herein. You may not use this
6+
file except in compliance with the License. You may obtain a copy of
7+
the License at http://www.apache.org/licenses/LICENSE-2.0.
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12+
implied. See the License for the specific language governing
13+
permissions and limitations under the License.
14+
15+
In addition, you may not use the software for any purposes that are
16+
illegal under applicable law, and the grant of the foregoing license
17+
under the Apache 2.0 license is conditioned upon your compliance with
18+
such restriction.
19+
*/
20+
21+
package ingresscache
22+
23+
type IngressHostCache interface {
24+
// Set adds a new item to the cache for the given host, path and function name. Will overwrite existing values if any
25+
Set(host string, path string, function string) error
26+
// Delete removes the specified function from the cache for the given host and path. Will do nothing if host, path or function do not exist
27+
Delete(host string, path string, function string) error
28+
// Get retrieves all function names for the given host and path
29+
Get(host string, path string) ([]string, error)
30+
}
31+
32+
type IngressHostsTree interface {
33+
// SetFunctionName sets a function for a given path. Will overwrite existing values if the path already exists
34+
SetFunctionName(path string, function string) error
35+
// DeleteFunctionName removes the function from the given path and deletes the deepest suffix used only by that function; does nothing if the path or function doesn't exist.
36+
DeleteFunctionName(path string, function string) error
37+
// GetFunctionNames retrieves the best matching function names for a given path based on longest prefix match
38+
GetFunctionNames(path string) ([]string, error)
39+
// IsEmpty checks if the tree is empty
40+
IsEmpty() bool
41+
}

0 commit comments

Comments
 (0)