Skip to content

Commit

Permalink
style: fix code lint
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb0225 committed Sep 19, 2023
1 parent 423e4a5 commit 72b5388
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 18 deletions.
3 changes: 2 additions & 1 deletion components/cryption/aliyun/kms.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion components/cryption/aws/kms.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pkg/common/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
package common

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestGetFileSize(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions pkg/runtime/pluggable.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ func (m *MosnRuntime) RegisterPluggableComponent() error {
}

// 1. discover pluggable component
services, err := m.Discover()
services, err := m.discover()
if err != nil {
return err
}

// 2. callback to register factory into MosnRuntime
m.Callback(services)
m.callback(services)
return nil
}

// Discover use grpc reflect to get services information.
func (m *MosnRuntime) Discover() ([]pluggableComponentService, error) {
// discover use grpc reflect to get services information.
func (m *MosnRuntime) discover() ([]pluggableComponentService, error) {
ctx := context.TODO()
services, err := serviceDiscovery(func(socket string) (client reflectServiceClient, closer func(), err error) {
conn, err := grpcdial.SocketDial(
Expand Down Expand Up @@ -189,8 +189,8 @@ func serviceDiscovery(reflectClientFactory func(socket string) (client reflectSe
return services, nil
}

// Callback use callback function to register pluggable component factories into MosnRuntime
func (m *MosnRuntime) Callback(services []pluggableComponentService) {
// callback use callback function to register pluggable component factories into MosnRuntime
func (m *MosnRuntime) callback(services []pluggableComponentService) {
for _, service := range services {
callback, ok := onServiceDiscovered[service.protoRef]
if !ok {
Expand Down
16 changes: 9 additions & 7 deletions pkg/runtime/pluggable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ package runtime

import (
"errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
grpcdial "mosn.io/layotto/pkg/grpc"
"net"
"os"
"runtime"
"sync"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

grpcdial "mosn.io/layotto/pkg/grpc"
)

type fakeReflectService struct {
Expand Down Expand Up @@ -83,7 +85,7 @@ func TestMosnRuntime_Callback(t *testing.T) {
called++
assert.Equal(t, name, fakeComponentName)
})
m.Callback([]pluggableComponentService{{protoRef: fakeServiceName, componentName: fakeComponentName}})
m.callback([]pluggableComponentService{{protoRef: fakeServiceName, componentName: fakeComponentName}})
assert.Equal(t, 1, called)
})
}
Expand Down Expand Up @@ -193,11 +195,11 @@ func Test_serviceDiscovery(t *testing.T) {

func TestConnectionCloser(t *testing.T) {
t.Run("connection closer should call grpc close and client reset", func(t *testing.T) {
const close, reset = "close", "reset"
const closed, reset = "closed", "reset"
callOrder := []string{}
fakeCloser := &fakeGrpcCloser{
onCloseCalled: func() {
callOrder = append(callOrder, close)
callOrder = append(callOrder, closed)
},
}
fakeService := &fakeReflectService{
Expand All @@ -208,6 +210,6 @@ func TestConnectionCloser(t *testing.T) {
closer := reflectServiceConnectionCloser(fakeCloser, fakeService)
closer()
assert.Len(t, callOrder, 2)
assert.Equal(t, callOrder, []string{reset, close})
assert.Equal(t, callOrder, []string{reset, closed})
})
}
5 changes: 3 additions & 2 deletions spec/proto/extension/v1/cryption/cryption.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions spec/proto/extension/v1/cryption/cryption_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 72b5388

Please sign in to comment.