Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: import packages only once #995

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/layotto/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ import (

"github.com/urfave/cli"
"google.golang.org/grpc"
_ "mosn.io/mosn/pkg/filter/network/grpc"
mgrpc "mosn.io/mosn/pkg/filter/network/grpc"
_ "mosn.io/mosn/pkg/filter/network/proxy"
_ "mosn.io/mosn/pkg/filter/stream/flowcontrol"
Expand Down
3 changes: 1 addition & 2 deletions cmd/layotto_multiple_api/helloworld/grpc_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

"mosn.io/layotto/cmd/layotto_multiple_api/helloworld/component"
"mosn.io/layotto/components/lock"
"mosn.io/layotto/pkg/grpc"
grpc_api "mosn.io/layotto/pkg/grpc"
)

Expand All @@ -35,7 +34,7 @@ const kind = "helloworld"
// This demo will always use this component name.
const componentName = "demo"

func NewHelloWorldAPI(ac *grpc_api.ApplicationContext) grpc.GrpcAPI {
func NewHelloWorldAPI(ac *grpc_api.ApplicationContext) grpc_api.GrpcAPI {
// 1. convert custom components
name2component := make(map[string]component.HelloWorld)
if len(ac.CustomComponent) != 0 {
Expand Down
1 change: 0 additions & 1 deletion cmd/layotto_multiple_api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ import (

"github.com/urfave/cli"
"google.golang.org/grpc"
_ "mosn.io/mosn/pkg/filter/network/grpc"
mgrpc "mosn.io/mosn/pkg/filter/network/grpc"
_ "mosn.io/mosn/pkg/filter/network/proxy"
_ "mosn.io/mosn/pkg/filter/stream/flowcontrol"
Expand Down
1 change: 0 additions & 1 deletion cmd/layotto_without_xds/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ import (

"github.com/urfave/cli"
"google.golang.org/grpc"
_ "mosn.io/mosn/pkg/filter/network/grpc"
mgrpc "mosn.io/mosn/pkg/filter/network/grpc"
_ "mosn.io/mosn/pkg/filter/network/proxy"
_ "mosn.io/mosn/pkg/filter/stream/flowcontrol"
Expand Down
15 changes: 7 additions & 8 deletions pkg/grpc/dapr/dapr_api_pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/golang/protobuf/ptypes/empty"
jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
rawGRPC "google.golang.org/grpc"
"google.golang.org/grpc/test/bufconn"
"mosn.io/pkg/log"
Expand Down Expand Up @@ -117,14 +116,14 @@ func TestMosnRuntime_publishMessageGRPC(t *testing.T) {
mockAppCallbackServer.EXPECT().OnTopicEvent(gomock.Any(), gomock.Any()).Return(subResp, nil)

lis := bufconn.Listen(1024 * 1024)
s := grpc.NewServer()
s := rawGRPC.NewServer()
dapr_v1pb.RegisterAppCallbackServer(s, mockAppCallbackServer)
go func() {
s.Serve(lis)
}()

// init callback client
callbackClient, err := grpc.DialContext(context.Background(), "bufnet", rawGRPC.WithInsecure(), rawGRPC.WithContextDialer(func(ctx context.Context, s string) (net.Conn, error) {
callbackClient, err := rawGRPC.DialContext(context.Background(), "bufnet", rawGRPC.WithInsecure(), rawGRPC.WithContextDialer(func(ctx context.Context, s string) (net.Conn, error) {
return lis.Dial()
}))
assert.Nil(t, err)
Expand Down Expand Up @@ -192,23 +191,23 @@ func TestMosnRuntime_publishMessageGRPC(t *testing.T) {
type mockClient struct {
}

func (m *mockClient) OnInvoke(ctx context.Context, in *dapr_common_v1pb.InvokeRequest, opts ...grpc.CallOption) (*dapr_common_v1pb.InvokeResponse, error) {
func (m *mockClient) OnInvoke(ctx context.Context, in *dapr_common_v1pb.InvokeRequest, opts ...rawGRPC.CallOption) (*dapr_common_v1pb.InvokeResponse, error) {
return nil, nil
}

func (m *mockClient) ListInputBindings(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*dapr_v1pb.ListInputBindingsResponse, error) {
func (m *mockClient) ListInputBindings(ctx context.Context, in *empty.Empty, opts ...rawGRPC.CallOption) (*dapr_v1pb.ListInputBindingsResponse, error) {
return nil, nil
}

func (m *mockClient) OnBindingEvent(ctx context.Context, in *dapr_v1pb.BindingEventRequest, opts ...grpc.CallOption) (*dapr_v1pb.BindingEventResponse, error) {
func (m *mockClient) OnBindingEvent(ctx context.Context, in *dapr_v1pb.BindingEventRequest, opts ...rawGRPC.CallOption) (*dapr_v1pb.BindingEventResponse, error) {
return nil, nil
}

func (m *mockClient) ListTopicSubscriptions(arg0 context.Context, arg1 *empty.Empty, opts ...grpc.CallOption) (*dapr_v1pb.ListTopicSubscriptionsResponse, error) {
func (m *mockClient) ListTopicSubscriptions(arg0 context.Context, arg1 *empty.Empty, opts ...rawGRPC.CallOption) (*dapr_v1pb.ListTopicSubscriptionsResponse, error) {
return nil, nil
}

func (m *mockClient) OnTopicEvent(ctx context.Context, in *dapr_v1pb.TopicEventRequest, opts ...grpc.CallOption) (*dapr_v1pb.TopicEventResponse, error) {
func (m *mockClient) OnTopicEvent(ctx context.Context, in *dapr_v1pb.TopicEventRequest, opts ...rawGRPC.CallOption) (*dapr_v1pb.TopicEventResponse, error) {
return nil, nil
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/grpc/default_api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"mosn.io/layotto/pkg/grpc/dapr"
dapr_common_v1pb "mosn.io/layotto/pkg/grpc/dapr/proto/common/v1"
dapr_v1pb "mosn.io/layotto/pkg/grpc/dapr/proto/runtime/v1"
"mosn.io/layotto/spec/proto/runtime/v1"
runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1"
)

Expand All @@ -63,7 +62,7 @@ var (

type API interface {
//Layotto Service methods
runtime.RuntimeServer
runtimev1pb.RuntimeServer
// GrpcAPI related
grpc_api.GrpcAPI
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/grpc/lifecycle/grpc_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ import (
"mosn.io/layotto/components/pkg/common"
"mosn.io/layotto/pkg/runtime/lifecycle"

"mosn.io/layotto/pkg/grpc"
grpc_api "mosn.io/layotto/pkg/grpc"
runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1"
)

func NewLifecycleAPI(ac *grpc_api.ApplicationContext) grpc.GrpcAPI {
func NewLifecycleAPI(ac *grpc_api.ApplicationContext) grpc_api.GrpcAPI {
return &server{
components: ac.DynamicComponents,
}
Expand Down
Loading