mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
add Token RPC endpoint to grab a machine token for adding it to a cluster
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
@@ -20,6 +21,7 @@ const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
Machine_InitCluster_FullMethodName = "/api.Machine/InitCluster"
|
||||
Machine_Token_FullMethodName = "/api.Machine/Token"
|
||||
)
|
||||
|
||||
// MachineClient is the client API for Machine service.
|
||||
@@ -27,6 +29,7 @@ const (
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type MachineClient interface {
|
||||
InitCluster(ctx context.Context, in *InitClusterRequest, opts ...grpc.CallOption) (*InitClusterResponse, error)
|
||||
Token(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*TokenResponse, error)
|
||||
}
|
||||
|
||||
type machineClient struct {
|
||||
@@ -47,11 +50,22 @@ func (c *machineClient) InitCluster(ctx context.Context, in *InitClusterRequest,
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *machineClient) Token(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*TokenResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(TokenResponse)
|
||||
err := c.cc.Invoke(ctx, Machine_Token_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MachineServer is the server API for Machine service.
|
||||
// All implementations must embed UnimplementedMachineServer
|
||||
// for forward compatibility.
|
||||
type MachineServer interface {
|
||||
InitCluster(context.Context, *InitClusterRequest) (*InitClusterResponse, error)
|
||||
Token(context.Context, *emptypb.Empty) (*TokenResponse, error)
|
||||
mustEmbedUnimplementedMachineServer()
|
||||
}
|
||||
|
||||
@@ -65,6 +79,9 @@ type UnimplementedMachineServer struct{}
|
||||
func (UnimplementedMachineServer) InitCluster(context.Context, *InitClusterRequest) (*InitClusterResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method InitCluster not implemented")
|
||||
}
|
||||
func (UnimplementedMachineServer) Token(context.Context, *emptypb.Empty) (*TokenResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Token not implemented")
|
||||
}
|
||||
func (UnimplementedMachineServer) mustEmbedUnimplementedMachineServer() {}
|
||||
func (UnimplementedMachineServer) testEmbeddedByValue() {}
|
||||
|
||||
@@ -104,6 +121,24 @@ func _Machine_InitCluster_Handler(srv interface{}, ctx context.Context, dec func
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Machine_Token_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(emptypb.Empty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MachineServer).Token(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Machine_Token_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MachineServer).Token(ctx, req.(*emptypb.Empty))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Machine_ServiceDesc is the grpc.ServiceDesc for Machine service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@@ -115,6 +150,10 @@ var Machine_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "InitCluster",
|
||||
Handler: _Machine_InitCluster_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Token",
|
||||
Handler: _Machine_Token_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "internal/machine/api/pb/machine.proto",
|
||||
|
||||
Reference in New Issue
Block a user