mirror of
https://github.com/langhuihui/monibuca.git
synced 2025-12-24 13:48:04 +08:00
feat: add task stop and restart api
This commit is contained in:
29
api.go
29
api.go
@@ -11,6 +11,7 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"m7s.live/v5/pkg/task"
|
||||
|
||||
@@ -163,7 +164,7 @@ func (s *Server) StreamInfo(ctx context.Context, req *pb.StreamSnapRequest) (res
|
||||
func (s *Server) TaskTree(context.Context, *emptypb.Empty) (res *pb.TaskTreeResponse, err error) {
|
||||
var fillData func(m task.ITask) *pb.TaskTreeData
|
||||
fillData = func(m task.ITask) (res *pb.TaskTreeData) {
|
||||
res = &pb.TaskTreeData{Id: m.GetTaskID(), State: uint32(m.GetState()), Type: uint32(m.GetTaskType()), Owner: m.GetOwnerType(), StartTime: timestamppb.New(m.GetTask().StartTime), Description: m.GetDescriptions()}
|
||||
res = &pb.TaskTreeData{Id: m.GetTaskID(), Pointer: uint64(uintptr(unsafe.Pointer(m.GetTask()))), State: uint32(m.GetState()), Type: uint32(m.GetTaskType()), Owner: m.GetOwnerType(), StartTime: timestamppb.New(m.GetTask().StartTime), Description: m.GetDescriptions()}
|
||||
if job, ok := m.(task.IJob); ok {
|
||||
if blockedTask := job.Blocked(); blockedTask != nil {
|
||||
res.Blocked = fillData(blockedTask)
|
||||
@@ -178,6 +179,24 @@ func (s *Server) TaskTree(context.Context, *emptypb.Empty) (res *pb.TaskTreeResp
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Server) StopTask(ctx context.Context, req *pb.RequestWithId64) (resp *pb.SuccessResponse, err error) {
|
||||
t := (*task.Task)(unsafe.Pointer(uintptr(req.Id)))
|
||||
if t == nil {
|
||||
return nil, pkg.ErrNotFound
|
||||
}
|
||||
t.Stop(task.ErrStopByUser)
|
||||
return &pb.SuccessResponse{}, nil
|
||||
}
|
||||
|
||||
func (s *Server) RestartTask(ctx context.Context, req *pb.RequestWithId64) (resp *pb.SuccessResponse, err error) {
|
||||
t := (*task.Task)(unsafe.Pointer(uintptr(req.Id)))
|
||||
if t == nil {
|
||||
return nil, pkg.ErrNotFound
|
||||
}
|
||||
t.Stop(task.ErrRestart)
|
||||
return &pb.SuccessResponse{}, nil
|
||||
}
|
||||
|
||||
func (s *Server) GetRecording(ctx context.Context, req *emptypb.Empty) (resp *pb.RecordingListResponse, err error) {
|
||||
if s.DB == nil {
|
||||
err = pkg.ErrNoDB
|
||||
@@ -373,20 +392,20 @@ func (s *Server) VideoTrackSnap(ctx context.Context, req *pb.StreamSnapRequest)
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Server) Restart(ctx context.Context, req *pb.RequestWithId) (res *emptypb.Empty, err error) {
|
||||
func (s *Server) Restart(ctx context.Context, req *pb.RequestWithId) (res *pb.SuccessResponse, err error) {
|
||||
if s, ok := Servers.Get(req.Id); ok {
|
||||
s.Stop(pkg.ErrRestart)
|
||||
}
|
||||
return empty, err
|
||||
return &pb.SuccessResponse{}, err
|
||||
}
|
||||
|
||||
func (s *Server) Shutdown(ctx context.Context, req *pb.RequestWithId) (res *emptypb.Empty, err error) {
|
||||
func (s *Server) Shutdown(ctx context.Context, req *pb.RequestWithId) (res *pb.SuccessResponse, err error) {
|
||||
if s, ok := Servers.Get(req.Id); ok {
|
||||
s.Stop(task.ErrStopByUser)
|
||||
} else {
|
||||
return nil, pkg.ErrNotFound
|
||||
}
|
||||
return empty, err
|
||||
return &pb.SuccessResponse{}, err
|
||||
}
|
||||
|
||||
func (s *Server) ChangeSubscribe(ctx context.Context, req *pb.ChangeSubscribeRequest) (res *pb.SuccessResponse, err error) {
|
||||
|
||||
1272
pb/global.pb.go
1272
pb/global.pb.go
File diff suppressed because it is too large
Load Diff
@@ -190,6 +190,110 @@ func local_request_Api_TaskTree_0(ctx context.Context, marshaler runtime.Marshal
|
||||
|
||||
}
|
||||
|
||||
func request_Api_StopTask_0(ctx context.Context, marshaler runtime.Marshaler, client ApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq RequestWithId64
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
||||
}
|
||||
|
||||
protoReq.Id, err = runtime.Uint64(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||
}
|
||||
|
||||
msg, err := client.StopTask(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Api_StopTask_0(ctx context.Context, marshaler runtime.Marshaler, server ApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq RequestWithId64
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
||||
}
|
||||
|
||||
protoReq.Id, err = runtime.Uint64(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||
}
|
||||
|
||||
msg, err := server.StopTask(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Api_RestartTask_0(ctx context.Context, marshaler runtime.Marshaler, client ApiClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq RequestWithId64
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
||||
}
|
||||
|
||||
protoReq.Id, err = runtime.Uint64(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||
}
|
||||
|
||||
msg, err := client.RestartTask(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Api_RestartTask_0(ctx context.Context, marshaler runtime.Marshaler, server ApiServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq RequestWithId64
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["id"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
|
||||
}
|
||||
|
||||
protoReq.Id, err = runtime.Uint64(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
|
||||
}
|
||||
|
||||
msg, err := server.RestartTask(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Api_StreamList_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
@@ -1379,6 +1483,56 @@ func RegisterApiHandlerServer(ctx context.Context, mux *runtime.ServeMux, server
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_Api_StopTask_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
var err error
|
||||
var annotatedContext context.Context
|
||||
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/global.Api/StopTask", runtime.WithHTTPPathPattern("/api/task/stop/{id}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Api_StopTask_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Api_StopTask_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_Api_RestartTask_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
var err error
|
||||
var annotatedContext context.Context
|
||||
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/global.Api/RestartTask", runtime.WithHTTPPathPattern("/api/task/restart/{id}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Api_RestartTask_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Api_RestartTask_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Api_StreamList_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@@ -2080,6 +2234,50 @@ func RegisterApiHandlerClient(ctx context.Context, mux *runtime.ServeMux, client
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_Api_StopTask_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
var err error
|
||||
var annotatedContext context.Context
|
||||
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/global.Api/StopTask", runtime.WithHTTPPathPattern("/api/task/stop/{id}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Api_StopTask_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Api_StopTask_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("POST", pattern_Api_RestartTask_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
var err error
|
||||
var annotatedContext context.Context
|
||||
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/global.Api/RestartTask", runtime.WithHTTPPathPattern("/api/task/restart/{id}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Api_RestartTask_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Api_RestartTask_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Api_StreamList_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
@@ -2578,6 +2776,10 @@ var (
|
||||
|
||||
pattern_Api_TaskTree_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "task", "tree"}, ""))
|
||||
|
||||
pattern_Api_StopTask_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "task", "stop", "id"}, ""))
|
||||
|
||||
pattern_Api_RestartTask_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "task", "restart", "id"}, ""))
|
||||
|
||||
pattern_Api_StreamList_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "stream", "list"}, ""))
|
||||
|
||||
pattern_Api_WaitList_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "stream", "waitlist"}, ""))
|
||||
@@ -2634,6 +2836,10 @@ var (
|
||||
|
||||
forward_Api_TaskTree_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Api_StopTask_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Api_RestartTask_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Api_StreamList_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Api_WaitList_0 = runtime.ForwardResponseMessage
|
||||
|
||||
@@ -18,12 +18,12 @@ service api {
|
||||
get: "/api/summary"
|
||||
};
|
||||
}
|
||||
rpc Shutdown (RequestWithId) returns (google.protobuf.Empty) {
|
||||
rpc Shutdown (RequestWithId) returns (SuccessResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/shutdown/{id}"
|
||||
};
|
||||
}
|
||||
rpc Restart (RequestWithId) returns (google.protobuf.Empty) {
|
||||
rpc Restart (RequestWithId) returns (SuccessResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/restart/{id}"
|
||||
};
|
||||
@@ -33,6 +33,16 @@ service api {
|
||||
get: "/api/task/tree"
|
||||
};
|
||||
}
|
||||
rpc StopTask (RequestWithId64) returns (SuccessResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/task/stop/{id}"
|
||||
};
|
||||
}
|
||||
rpc RestartTask (RequestWithId64) returns (SuccessResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/task/restart/{id}"
|
||||
};
|
||||
}
|
||||
rpc StreamList (StreamListRequest) returns (StreamListResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/api/stream/list"
|
||||
@@ -245,6 +255,7 @@ message TaskTreeData {
|
||||
repeated TaskTreeData children = 6;
|
||||
uint32 state = 7;
|
||||
TaskTreeData blocked = 8;
|
||||
uint64 pointer = 9;
|
||||
}
|
||||
|
||||
message TaskTreeResponse {
|
||||
@@ -359,6 +370,10 @@ message RequestWithId {
|
||||
uint32 id = 1;
|
||||
}
|
||||
|
||||
message RequestWithId64 {
|
||||
uint64 id = 1;
|
||||
}
|
||||
|
||||
message ChangeSubscribeRequest {
|
||||
uint32 id = 1;
|
||||
string streamPath = 2;
|
||||
|
||||
@@ -25,9 +25,11 @@ const _ = grpc.SupportPackageIsVersion7
|
||||
type ApiClient interface {
|
||||
SysInfo(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*SysInfoResponse, error)
|
||||
Summary(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*SummaryResponse, error)
|
||||
Shutdown(ctx context.Context, in *RequestWithId, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
Restart(ctx context.Context, in *RequestWithId, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
Shutdown(ctx context.Context, in *RequestWithId, opts ...grpc.CallOption) (*SuccessResponse, error)
|
||||
Restart(ctx context.Context, in *RequestWithId, opts ...grpc.CallOption) (*SuccessResponse, error)
|
||||
TaskTree(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*TaskTreeResponse, error)
|
||||
StopTask(ctx context.Context, in *RequestWithId64, opts ...grpc.CallOption) (*SuccessResponse, error)
|
||||
RestartTask(ctx context.Context, in *RequestWithId64, opts ...grpc.CallOption) (*SuccessResponse, error)
|
||||
StreamList(ctx context.Context, in *StreamListRequest, opts ...grpc.CallOption) (*StreamListResponse, error)
|
||||
WaitList(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*StreamWaitListResponse, error)
|
||||
StreamInfo(ctx context.Context, in *StreamSnapRequest, opts ...grpc.CallOption) (*StreamInfoResponse, error)
|
||||
@@ -78,8 +80,8 @@ func (c *apiClient) Summary(ctx context.Context, in *emptypb.Empty, opts ...grpc
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *apiClient) Shutdown(ctx context.Context, in *RequestWithId, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
out := new(emptypb.Empty)
|
||||
func (c *apiClient) Shutdown(ctx context.Context, in *RequestWithId, opts ...grpc.CallOption) (*SuccessResponse, error) {
|
||||
out := new(SuccessResponse)
|
||||
err := c.cc.Invoke(ctx, "/global.api/Shutdown", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -87,8 +89,8 @@ func (c *apiClient) Shutdown(ctx context.Context, in *RequestWithId, opts ...grp
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *apiClient) Restart(ctx context.Context, in *RequestWithId, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
out := new(emptypb.Empty)
|
||||
func (c *apiClient) Restart(ctx context.Context, in *RequestWithId, opts ...grpc.CallOption) (*SuccessResponse, error) {
|
||||
out := new(SuccessResponse)
|
||||
err := c.cc.Invoke(ctx, "/global.api/Restart", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -105,6 +107,24 @@ func (c *apiClient) TaskTree(ctx context.Context, in *emptypb.Empty, opts ...grp
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *apiClient) StopTask(ctx context.Context, in *RequestWithId64, opts ...grpc.CallOption) (*SuccessResponse, error) {
|
||||
out := new(SuccessResponse)
|
||||
err := c.cc.Invoke(ctx, "/global.api/StopTask", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *apiClient) RestartTask(ctx context.Context, in *RequestWithId64, opts ...grpc.CallOption) (*SuccessResponse, error) {
|
||||
out := new(SuccessResponse)
|
||||
err := c.cc.Invoke(ctx, "/global.api/RestartTask", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *apiClient) StreamList(ctx context.Context, in *StreamListRequest, opts ...grpc.CallOption) (*StreamListResponse, error) {
|
||||
out := new(StreamListResponse)
|
||||
err := c.cc.Invoke(ctx, "/global.api/StreamList", in, out, opts...)
|
||||
@@ -309,9 +329,11 @@ func (c *apiClient) GetRecording(ctx context.Context, in *emptypb.Empty, opts ..
|
||||
type ApiServer interface {
|
||||
SysInfo(context.Context, *emptypb.Empty) (*SysInfoResponse, error)
|
||||
Summary(context.Context, *emptypb.Empty) (*SummaryResponse, error)
|
||||
Shutdown(context.Context, *RequestWithId) (*emptypb.Empty, error)
|
||||
Restart(context.Context, *RequestWithId) (*emptypb.Empty, error)
|
||||
Shutdown(context.Context, *RequestWithId) (*SuccessResponse, error)
|
||||
Restart(context.Context, *RequestWithId) (*SuccessResponse, error)
|
||||
TaskTree(context.Context, *emptypb.Empty) (*TaskTreeResponse, error)
|
||||
StopTask(context.Context, *RequestWithId64) (*SuccessResponse, error)
|
||||
RestartTask(context.Context, *RequestWithId64) (*SuccessResponse, error)
|
||||
StreamList(context.Context, *StreamListRequest) (*StreamListResponse, error)
|
||||
WaitList(context.Context, *emptypb.Empty) (*StreamWaitListResponse, error)
|
||||
StreamInfo(context.Context, *StreamSnapRequest) (*StreamInfoResponse, error)
|
||||
@@ -347,15 +369,21 @@ func (UnimplementedApiServer) SysInfo(context.Context, *emptypb.Empty) (*SysInfo
|
||||
func (UnimplementedApiServer) Summary(context.Context, *emptypb.Empty) (*SummaryResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Summary not implemented")
|
||||
}
|
||||
func (UnimplementedApiServer) Shutdown(context.Context, *RequestWithId) (*emptypb.Empty, error) {
|
||||
func (UnimplementedApiServer) Shutdown(context.Context, *RequestWithId) (*SuccessResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Shutdown not implemented")
|
||||
}
|
||||
func (UnimplementedApiServer) Restart(context.Context, *RequestWithId) (*emptypb.Empty, error) {
|
||||
func (UnimplementedApiServer) Restart(context.Context, *RequestWithId) (*SuccessResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Restart not implemented")
|
||||
}
|
||||
func (UnimplementedApiServer) TaskTree(context.Context, *emptypb.Empty) (*TaskTreeResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method TaskTree not implemented")
|
||||
}
|
||||
func (UnimplementedApiServer) StopTask(context.Context, *RequestWithId64) (*SuccessResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method StopTask not implemented")
|
||||
}
|
||||
func (UnimplementedApiServer) RestartTask(context.Context, *RequestWithId64) (*SuccessResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RestartTask not implemented")
|
||||
}
|
||||
func (UnimplementedApiServer) StreamList(context.Context, *StreamListRequest) (*StreamListResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method StreamList not implemented")
|
||||
}
|
||||
@@ -525,6 +553,42 @@ func _Api_TaskTree_Handler(srv interface{}, ctx context.Context, dec func(interf
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Api_StopTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(RequestWithId64)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ApiServer).StopTask(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/global.api/StopTask",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ApiServer).StopTask(ctx, req.(*RequestWithId64))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Api_RestartTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(RequestWithId64)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ApiServer).RestartTask(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/global.api/RestartTask",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ApiServer).RestartTask(ctx, req.(*RequestWithId64))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Api_StreamList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(StreamListRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -948,6 +1012,14 @@ var Api_ServiceDesc = grpc.ServiceDesc{
|
||||
MethodName: "TaskTree",
|
||||
Handler: _Api_TaskTree_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "StopTask",
|
||||
Handler: _Api_StopTask_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "RestartTask",
|
||||
Handler: _Api_RestartTask_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "StreamList",
|
||||
Handler: _Api_StreamList_Handler,
|
||||
|
||||
@@ -22,6 +22,7 @@ var (
|
||||
ErrAutoStop = errors.New("auto stop")
|
||||
ErrRetryRunOut = errors.New("retry out")
|
||||
ErrStopByUser = errors.New("stop by user")
|
||||
ErrRestart = errors.New("restart")
|
||||
ErrTaskComplete = errors.New("complete")
|
||||
ErrExit = errors.New("exit")
|
||||
ErrPanic = errors.New("panic")
|
||||
@@ -274,7 +275,7 @@ func (task *Task) checkRetry(err error) bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return false
|
||||
return errors.Is(err, ErrRestart)
|
||||
}
|
||||
|
||||
func (task *Task) start() bool {
|
||||
|
||||
Reference in New Issue
Block a user