Filip Troníček b94aec1263
Integrate reading from log files into Supervisor's terminal.Listen (#19863)
* Integrate reading from log files into Supervisor's `terminal.Listen`

* Try with GetOutput

* do not bubble down and fail

* remove debug stuff

* definitions and impl of `task.proto`

* codegen

* update endpoint

* Implement `ListenToOutput`

* Try with one API (🤞)

* stream beginning from where we left off

* Do not watch closed tasks

* move closing of worker channel

* simplify one-off reading

* codegen

* consolidate for loops, optimize watching

* remove extra line

It makes sense to group the offset definition with the function below it

* Gpl/ft/supervisor-listen-files (#19878)

* commit step 1

* 2nd

* Changes from joint code review

---------

Co-authored-by: Filip Troníček <filip@gitpod.io>

* Remove year bumps

---------

Co-authored-by: Gero Posmyk-Leinemann <gero@gitpod.io>
2024-06-12 21:37:08 +08:00

139 lines
4.5 KiB
Go

// Copyright (c) 2024 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License.AGPL.txt in the project root for license information.
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.20.1
// source: task.proto
package api
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// TaskServiceClient is the client API for TaskService service.
//
// 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 TaskServiceClient interface {
// Listens to the output of a given task
ListenToOutput(ctx context.Context, in *ListenToOutputRequest, opts ...grpc.CallOption) (TaskService_ListenToOutputClient, error)
}
type taskServiceClient struct {
cc grpc.ClientConnInterface
}
func NewTaskServiceClient(cc grpc.ClientConnInterface) TaskServiceClient {
return &taskServiceClient{cc}
}
func (c *taskServiceClient) ListenToOutput(ctx context.Context, in *ListenToOutputRequest, opts ...grpc.CallOption) (TaskService_ListenToOutputClient, error) {
stream, err := c.cc.NewStream(ctx, &TaskService_ServiceDesc.Streams[0], "/supervisor.TaskService/ListenToOutput", opts...)
if err != nil {
return nil, err
}
x := &taskServiceListenToOutputClient{stream}
if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err
}
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
return x, nil
}
type TaskService_ListenToOutputClient interface {
Recv() (*ListenToOutputResponse, error)
grpc.ClientStream
}
type taskServiceListenToOutputClient struct {
grpc.ClientStream
}
func (x *taskServiceListenToOutputClient) Recv() (*ListenToOutputResponse, error) {
m := new(ListenToOutputResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// TaskServiceServer is the server API for TaskService service.
// All implementations must embed UnimplementedTaskServiceServer
// for forward compatibility
type TaskServiceServer interface {
// Listens to the output of a given task
ListenToOutput(*ListenToOutputRequest, TaskService_ListenToOutputServer) error
mustEmbedUnimplementedTaskServiceServer()
}
// UnimplementedTaskServiceServer must be embedded to have forward compatible implementations.
type UnimplementedTaskServiceServer struct {
}
func (UnimplementedTaskServiceServer) ListenToOutput(*ListenToOutputRequest, TaskService_ListenToOutputServer) error {
return status.Errorf(codes.Unimplemented, "method ListenToOutput not implemented")
}
func (UnimplementedTaskServiceServer) mustEmbedUnimplementedTaskServiceServer() {}
// UnsafeTaskServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to TaskServiceServer will
// result in compilation errors.
type UnsafeTaskServiceServer interface {
mustEmbedUnimplementedTaskServiceServer()
}
func RegisterTaskServiceServer(s grpc.ServiceRegistrar, srv TaskServiceServer) {
s.RegisterService(&TaskService_ServiceDesc, srv)
}
func _TaskService_ListenToOutput_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(ListenToOutputRequest)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(TaskServiceServer).ListenToOutput(m, &taskServiceListenToOutputServer{stream})
}
type TaskService_ListenToOutputServer interface {
Send(*ListenToOutputResponse) error
grpc.ServerStream
}
type taskServiceListenToOutputServer struct {
grpc.ServerStream
}
func (x *taskServiceListenToOutputServer) Send(m *ListenToOutputResponse) error {
return x.ServerStream.SendMsg(m)
}
// TaskService_ServiceDesc is the grpc.ServiceDesc for TaskService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var TaskService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "supervisor.TaskService",
HandlerType: (*TaskServiceServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{
{
StreamName: "ListenToOutput",
Handler: _TaskService_ListenToOutput_Handler,
ServerStreams: true,
},
},
Metadata: "task.proto",
}