mirror of
https://codeberg.org/cunicu/cunicu.git
synced 2025-10-19 15:14:58 +08:00
daemon: use per-interface features
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
@@ -29,9 +29,11 @@ type DaemonClient interface {
|
||||
Stop(ctx context.Context, in *proto.Empty, opts ...grpc.CallOption) (*proto.Empty, error)
|
||||
Restart(ctx context.Context, in *proto.Empty, opts ...grpc.CallOption) (*proto.Empty, error)
|
||||
Sync(ctx context.Context, in *proto.Empty, opts ...grpc.CallOption) (*proto.Empty, error)
|
||||
GetStatus(ctx context.Context, in *StatusParams, opts ...grpc.CallOption) (*StatusResp, error)
|
||||
GetStatus(ctx context.Context, in *GetStatusParams, opts ...grpc.CallOption) (*GetStatusResp, error)
|
||||
SetConfig(ctx context.Context, in *SetConfigParams, opts ...grpc.CallOption) (*proto.Empty, error)
|
||||
GetConfig(ctx context.Context, in *GetConfigParams, opts ...grpc.CallOption) (*GetConfigResp, error)
|
||||
ReloadConfig(ctx context.Context, in *proto.Empty, opts ...grpc.CallOption) (*proto.Empty, error)
|
||||
AddPeer(ctx context.Context, in *AddPeerParams, opts ...grpc.CallOption) (*AddPeerResp, error)
|
||||
}
|
||||
|
||||
type daemonClient struct {
|
||||
@@ -119,8 +121,8 @@ func (c *daemonClient) Sync(ctx context.Context, in *proto.Empty, opts ...grpc.C
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *daemonClient) GetStatus(ctx context.Context, in *StatusParams, opts ...grpc.CallOption) (*StatusResp, error) {
|
||||
out := new(StatusResp)
|
||||
func (c *daemonClient) GetStatus(ctx context.Context, in *GetStatusParams, opts ...grpc.CallOption) (*GetStatusResp, error) {
|
||||
out := new(GetStatusResp)
|
||||
err := c.cc.Invoke(ctx, "/cunicu.rpc.Daemon/GetStatus", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -146,6 +148,24 @@ func (c *daemonClient) GetConfig(ctx context.Context, in *GetConfigParams, opts
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *daemonClient) ReloadConfig(ctx context.Context, in *proto.Empty, opts ...grpc.CallOption) (*proto.Empty, error) {
|
||||
out := new(proto.Empty)
|
||||
err := c.cc.Invoke(ctx, "/cunicu.rpc.Daemon/ReloadConfig", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *daemonClient) AddPeer(ctx context.Context, in *AddPeerParams, opts ...grpc.CallOption) (*AddPeerResp, error) {
|
||||
out := new(AddPeerResp)
|
||||
err := c.cc.Invoke(ctx, "/cunicu.rpc.Daemon/AddPeer", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// DaemonServer is the server API for Daemon service.
|
||||
// All implementations must embed UnimplementedDaemonServer
|
||||
// for forward compatibility
|
||||
@@ -156,9 +176,11 @@ type DaemonServer interface {
|
||||
Stop(context.Context, *proto.Empty) (*proto.Empty, error)
|
||||
Restart(context.Context, *proto.Empty) (*proto.Empty, error)
|
||||
Sync(context.Context, *proto.Empty) (*proto.Empty, error)
|
||||
GetStatus(context.Context, *StatusParams) (*StatusResp, error)
|
||||
GetStatus(context.Context, *GetStatusParams) (*GetStatusResp, error)
|
||||
SetConfig(context.Context, *SetConfigParams) (*proto.Empty, error)
|
||||
GetConfig(context.Context, *GetConfigParams) (*GetConfigResp, error)
|
||||
ReloadConfig(context.Context, *proto.Empty) (*proto.Empty, error)
|
||||
AddPeer(context.Context, *AddPeerParams) (*AddPeerResp, error)
|
||||
mustEmbedUnimplementedDaemonServer()
|
||||
}
|
||||
|
||||
@@ -184,7 +206,7 @@ func (UnimplementedDaemonServer) Restart(context.Context, *proto.Empty) (*proto.
|
||||
func (UnimplementedDaemonServer) Sync(context.Context, *proto.Empty) (*proto.Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Sync not implemented")
|
||||
}
|
||||
func (UnimplementedDaemonServer) GetStatus(context.Context, *StatusParams) (*StatusResp, error) {
|
||||
func (UnimplementedDaemonServer) GetStatus(context.Context, *GetStatusParams) (*GetStatusResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetStatus not implemented")
|
||||
}
|
||||
func (UnimplementedDaemonServer) SetConfig(context.Context, *SetConfigParams) (*proto.Empty, error) {
|
||||
@@ -193,6 +215,12 @@ func (UnimplementedDaemonServer) SetConfig(context.Context, *SetConfigParams) (*
|
||||
func (UnimplementedDaemonServer) GetConfig(context.Context, *GetConfigParams) (*GetConfigResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetConfig not implemented")
|
||||
}
|
||||
func (UnimplementedDaemonServer) ReloadConfig(context.Context, *proto.Empty) (*proto.Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ReloadConfig not implemented")
|
||||
}
|
||||
func (UnimplementedDaemonServer) AddPeer(context.Context, *AddPeerParams) (*AddPeerResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AddPeer not implemented")
|
||||
}
|
||||
func (UnimplementedDaemonServer) mustEmbedUnimplementedDaemonServer() {}
|
||||
|
||||
// UnsafeDaemonServer may be embedded to opt out of forward compatibility for this service.
|
||||
@@ -318,7 +346,7 @@ func _Daemon_Sync_Handler(srv interface{}, ctx context.Context, dec func(interfa
|
||||
}
|
||||
|
||||
func _Daemon_GetStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(StatusParams)
|
||||
in := new(GetStatusParams)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -330,7 +358,7 @@ func _Daemon_GetStatus_Handler(srv interface{}, ctx context.Context, dec func(in
|
||||
FullMethod: "/cunicu.rpc.Daemon/GetStatus",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DaemonServer).GetStatus(ctx, req.(*StatusParams))
|
||||
return srv.(DaemonServer).GetStatus(ctx, req.(*GetStatusParams))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
@@ -371,6 +399,42 @@ func _Daemon_GetConfig_Handler(srv interface{}, ctx context.Context, dec func(in
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Daemon_ReloadConfig_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(proto.Empty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DaemonServer).ReloadConfig(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cunicu.rpc.Daemon/ReloadConfig",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DaemonServer).ReloadConfig(ctx, req.(*proto.Empty))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Daemon_AddPeer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AddPeerParams)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DaemonServer).AddPeer(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/cunicu.rpc.Daemon/AddPeer",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DaemonServer).AddPeer(ctx, req.(*AddPeerParams))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Daemon_ServiceDesc is the grpc.ServiceDesc for Daemon service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
@@ -410,6 +474,14 @@ var Daemon_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "GetConfig",
|
||||
Handler: _Daemon_GetConfig_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ReloadConfig",
|
||||
Handler: _Daemon_ReloadConfig_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "AddPeer",
|
||||
Handler: _Daemon_AddPeer_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
|
Reference in New Issue
Block a user