Skip to content

Commit

Permalink
Delete unnecessary code for mirror (#2366) (#2391)
Browse files Browse the repository at this point in the history
* fix: delete unnecessary code for mirror



* fix: make deps/install and format



* improve Backport Pull Request Title & Description Quality (#2373)




* fix: naming of variable



---------

Signed-off-by: hlts2 <[email protected]>
Signed-off-by: kpango <[email protected]>
Co-authored-by: Hiroto Funakoshi <[email protected]>
Co-authored-by: Yusuke Kato <[email protected]>
Co-authored-by: Kosuke Morimoto <[email protected]>
  • Loading branch information
4 people committed Feb 20, 2024
1 parent 8942871 commit 7a29424
Show file tree
Hide file tree
Showing 13 changed files with 293 additions and 272 deletions.
23 changes: 23 additions & 0 deletions apis/grpc/v1/mirror/mirror.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Copyright (C) 2019-2024 vdaas.org vald team <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

// Package mirror provides vald server interface
package mirror

const (
RPCServiceName = "Mirror"
RegisterRPCName = "Register"
)
36 changes: 0 additions & 36 deletions apis/grpc/v1/vald/vald.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package vald

import (
"github.com/vdaas/vald/apis/grpc/v1/mirror"
grpc "google.golang.org/grpc"
)

Expand All @@ -36,11 +35,6 @@ type ServerWithFilter interface {
FilterServer
}

type ServerWithMirror interface {
Server
mirror.MirrorServer
}

type UnimplementedValdServer struct {
UnimplementedInsertServer
UnimplementedUpdateServer
Expand All @@ -55,11 +49,6 @@ type UnimplementedValdServerWithFilter struct {
UnimplementedFilterServer
}

type UnimplementedValdServerWithMirror struct {
UnimplementedValdServer
mirror.UnimplementedMirrorServer
}

type Client interface {
InsertClient
UpdateClient
Expand All @@ -74,11 +63,6 @@ type ClientWithFilter interface {
FilterClient
}

type ClientWithMirror interface {
Client
mirror.MirrorClient
}

const PackageName = "vald.v1"

const (
Expand All @@ -89,7 +73,6 @@ const (
RemoveRPCServiceName = "Remove"
ObjectRPCServiceName = "Object"
FilterRPCServiceName = "Filter"
MirrorRPCServiceName = "Mirror"
)

const (
Expand Down Expand Up @@ -143,8 +126,6 @@ const (
GetTimestampRPCName = "GetTimestamp"
StreamGetObjectRPCName = "StreamGetObject"
StreamListObjectRPCName = "StreamListObject"

RegisterRPCName = "Register"
)

type client struct {
Expand All @@ -156,11 +137,6 @@ type client struct {
ObjectClient
}

type clientWithMirror struct {
Client
mirror.MirrorClient
}

func RegisterValdServer(s *grpc.Server, srv Server) {
RegisterInsertServer(s, srv)
RegisterUpdateServer(s, srv)
Expand All @@ -175,11 +151,6 @@ func RegisterValdServerWithFilter(s *grpc.Server, srv ServerWithFilter) {
RegisterFilterServer(s, srv)
}

func RegisterValdServerWithMirror(s *grpc.Server, srv ServerWithMirror) {
RegisterValdServer(s, srv)
mirror.RegisterMirrorServer(s, srv)
}

func NewValdClient(conn *grpc.ClientConn) Client {
return &client{
NewInsertClient(conn),
Expand All @@ -190,10 +161,3 @@ func NewValdClient(conn *grpc.ClientConn) Client {
NewObjectClient(conn),
}
}

func NewValdClientWithMirror(conn *grpc.ClientConn) ClientWithMirror {
return &clientWithMirror{
Client: NewValdClient(conn),
MirrorClient: mirror.NewMirrorClient(conn),
}
}
3 changes: 1 addition & 2 deletions internal/client/v1/client/mirror/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (

"github.com/vdaas/vald/apis/grpc/v1/mirror"
"github.com/vdaas/vald/apis/grpc/v1/payload"
"github.com/vdaas/vald/apis/grpc/v1/vald"
"github.com/vdaas/vald/internal/errors"
"github.com/vdaas/vald/internal/net/grpc"
"github.com/vdaas/vald/internal/observability/trace"
Expand Down Expand Up @@ -69,7 +68,7 @@ func (c *client) GRPCClient() grpc.Client {
}

func (c *client) Register(ctx context.Context, in *payload.Mirror_Targets, opts ...grpc.CallOption) (res *payload.Mirror_Targets, err error) {
ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+vald.RegisterRPCName), apiName+"/"+vald.RegisterRPCName)
ctx, span := trace.StartSpan(grpc.WrapGRPCMethod(ctx, "internal/client/"+mirror.RegisterRPCName), apiName+"/"+mirror.RegisterRPCName)
defer func() {
if span != nil {
span.End()
Expand Down
4 changes: 3 additions & 1 deletion internal/test/mock/client/mirror_client_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ package client
import (
"context"

"github.com/vdaas/vald/apis/grpc/v1/mirror"
"github.com/vdaas/vald/apis/grpc/v1/payload"
"github.com/vdaas/vald/apis/grpc/v1/vald"
"github.com/vdaas/vald/internal/net/grpc"
)

type MirrorClientMock struct {
vald.ClientWithMirror
vald.Client
mirror.MirrorClient

InsertFunc func(ctx context.Context, in *payload.Insert_Request, opts ...grpc.CallOption) (*payload.Object_Location, error)
UpdateFunc func(ctx context.Context, in *payload.Update_Request, opts ...grpc.CallOption) (*payload.Object_Location, error)
Expand Down
Loading

0 comments on commit 7a29424

Please sign in to comment.