forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
43 lines (34 loc) · 1.44 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2014, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/*
Package grpcmysqlctlserver contains the gRPC implementation of the server
side of the remote execution of mysqlctl commands.
*/
package grpcmysqlctlserver
import (
"google.golang.org/grpc"
"github.com/youtube/vitess/go/vt/mysqlctl"
"golang.org/x/net/context"
pb "github.com/youtube/vitess/go/vt/proto/mysqlctl"
)
// server is our gRPC server.
type server struct {
mysqld *mysqlctl.Mysqld
}
// Start implements the server side of the MysqlctlClient interface.
func (s *server) Start(ctx context.Context, request *pb.StartRequest) (*pb.StartResponse, error) {
return &pb.StartResponse{}, s.mysqld.Start(ctx)
}
// Shutdown implements the server side of the MysqlctlClient interface.
func (s *server) Shutdown(ctx context.Context, request *pb.ShutdownRequest) (*pb.ShutdownResponse, error) {
return &pb.ShutdownResponse{}, s.mysqld.Shutdown(ctx, request.WaitForMysqld)
}
// RunMysqlUpgrade implements the server side of the MysqlctlClient interface.
func (s *server) RunMysqlUpgrade(ctx context.Context, request *pb.RunMysqlUpgradeRequest) (*pb.RunMysqlUpgradeResponse, error) {
return &pb.RunMysqlUpgradeResponse{}, s.mysqld.RunMysqlUpgrade()
}
// StartServer registers the Server for RPCs.
func StartServer(s *grpc.Server, mysqld *mysqlctl.Mysqld) {
pb.RegisterMysqlCtlServer(s, &server{mysqld})
}