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

Backport PR #2366 to release/v1.7 for Delete unnecessary code for mirror #2391

Merged
Merged
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
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 <vald@vdaas.org>
//
// 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
Loading