Files
steampipe/pluginmanager/grpc/shared/grpc.go
kaidaguerre e0ff19a280 Update package naming to be consistent and follow Go standards. Closes #1282
General code spring cleaning:
* move file paths from `consts` package to `filepaths`
* move InitData and ExportData to query and control packages
2022-01-04 12:28:36 +00:00

40 lines
1.1 KiB
Go

package shared
import (
"context"
pb "github.com/turbot/steampipe/pluginmanager/grpc/proto"
)
// GRPCClient is an implementation of PluginManager service that talks over GRPC.
type GRPCClient struct {
// Proto client use to make the grpc service calls.
client pb.PluginManagerClient
// this context is created by the plugin package, and is canceled when the
// plugin process ends.
ctx context.Context
}
func (c *GRPCClient) Get(req *pb.GetRequest) (*pb.GetResponse, error) {
return c.client.Get(c.ctx, req)
}
func (c *GRPCClient) Shutdown(req *pb.ShutdownRequest) (*pb.ShutdownResponse, error) {
return c.client.Shutdown(c.ctx, req)
}
// GRPCServer is the gRPC server that GRPCClient talks to.
type GRPCServer struct {
pb.UnimplementedPluginManagerServer
// This is the real implementation
Impl PluginManager
}
func (m *GRPCServer) Get(_ context.Context, req *pb.GetRequest) (*pb.GetResponse, error) {
return m.Impl.Get(req)
}
func (m *GRPCServer) Shutdown(_ context.Context, req *pb.ShutdownRequest) (*pb.ShutdownResponse, error) {
return m.Impl.Shutdown(req)
}