161 lines
7.5 KiB
Go
161 lines
7.5 KiB
Go
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
|
//
|
|
// Source: runner/v1/services.proto
|
|
|
|
package runnerv1connect
|
|
|
|
import (
|
|
v1 "code.gitea.io/bots-proto-go/runner/v1"
|
|
context "context"
|
|
errors "errors"
|
|
connect_go "github.com/bufbuild/connect-go"
|
|
http "net/http"
|
|
strings "strings"
|
|
)
|
|
|
|
// This is a compile-time assertion to ensure that this generated file and the connect package are
|
|
// compatible. If you get a compiler error that this constant is not defined, this code was
|
|
// generated with a version of connect newer than the one compiled into your binary. You can fix the
|
|
// problem by either regenerating this code with an older version of connect or updating the connect
|
|
// version compiled into your binary.
|
|
const _ = connect_go.IsAtLeastVersion0_1_0
|
|
|
|
const (
|
|
// RunnerServiceName is the fully-qualified name of the RunnerService service.
|
|
RunnerServiceName = "runner.v1.RunnerService"
|
|
)
|
|
|
|
// RunnerServiceClient is a client for the runner.v1.RunnerService service.
|
|
type RunnerServiceClient interface {
|
|
// Register register a new runner in server.
|
|
Register(context.Context, *connect_go.Request[v1.RegisterRequest]) (*connect_go.Response[v1.RegisterResponse], error)
|
|
// FetchTask requests the next available task for execution.
|
|
FetchTask(context.Context, *connect_go.Request[v1.FetchTaskRequest]) (*connect_go.Response[v1.FetchTaskResponse], error)
|
|
// UpdateTask updates the task status.
|
|
UpdateTask(context.Context, *connect_go.Request[v1.UpdateTaskRequest]) (*connect_go.Response[v1.UpdateTaskResponse], error)
|
|
// UpdateLog uploads log of the task.
|
|
UpdateLog(context.Context, *connect_go.Request[v1.UpdateLogRequest]) (*connect_go.Response[v1.UpdateLogResponse], error)
|
|
}
|
|
|
|
// NewRunnerServiceClient constructs a client for the runner.v1.RunnerService service. By default,
|
|
// it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and
|
|
// sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC()
|
|
// or connect.WithGRPCWeb() options.
|
|
//
|
|
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
|
|
// http://api.acme.com or https://acme.com/grpc).
|
|
func NewRunnerServiceClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) RunnerServiceClient {
|
|
baseURL = strings.TrimRight(baseURL, "/")
|
|
return &runnerServiceClient{
|
|
register: connect_go.NewClient[v1.RegisterRequest, v1.RegisterResponse](
|
|
httpClient,
|
|
baseURL+"/runner.v1.RunnerService/Register",
|
|
opts...,
|
|
),
|
|
fetchTask: connect_go.NewClient[v1.FetchTaskRequest, v1.FetchTaskResponse](
|
|
httpClient,
|
|
baseURL+"/runner.v1.RunnerService/FetchTask",
|
|
opts...,
|
|
),
|
|
updateTask: connect_go.NewClient[v1.UpdateTaskRequest, v1.UpdateTaskResponse](
|
|
httpClient,
|
|
baseURL+"/runner.v1.RunnerService/UpdateTask",
|
|
opts...,
|
|
),
|
|
updateLog: connect_go.NewClient[v1.UpdateLogRequest, v1.UpdateLogResponse](
|
|
httpClient,
|
|
baseURL+"/runner.v1.RunnerService/UpdateLog",
|
|
opts...,
|
|
),
|
|
}
|
|
}
|
|
|
|
// runnerServiceClient implements RunnerServiceClient.
|
|
type runnerServiceClient struct {
|
|
register *connect_go.Client[v1.RegisterRequest, v1.RegisterResponse]
|
|
fetchTask *connect_go.Client[v1.FetchTaskRequest, v1.FetchTaskResponse]
|
|
updateTask *connect_go.Client[v1.UpdateTaskRequest, v1.UpdateTaskResponse]
|
|
updateLog *connect_go.Client[v1.UpdateLogRequest, v1.UpdateLogResponse]
|
|
}
|
|
|
|
// Register calls runner.v1.RunnerService.Register.
|
|
func (c *runnerServiceClient) Register(ctx context.Context, req *connect_go.Request[v1.RegisterRequest]) (*connect_go.Response[v1.RegisterResponse], error) {
|
|
return c.register.CallUnary(ctx, req)
|
|
}
|
|
|
|
// FetchTask calls runner.v1.RunnerService.FetchTask.
|
|
func (c *runnerServiceClient) FetchTask(ctx context.Context, req *connect_go.Request[v1.FetchTaskRequest]) (*connect_go.Response[v1.FetchTaskResponse], error) {
|
|
return c.fetchTask.CallUnary(ctx, req)
|
|
}
|
|
|
|
// UpdateTask calls runner.v1.RunnerService.UpdateTask.
|
|
func (c *runnerServiceClient) UpdateTask(ctx context.Context, req *connect_go.Request[v1.UpdateTaskRequest]) (*connect_go.Response[v1.UpdateTaskResponse], error) {
|
|
return c.updateTask.CallUnary(ctx, req)
|
|
}
|
|
|
|
// UpdateLog calls runner.v1.RunnerService.UpdateLog.
|
|
func (c *runnerServiceClient) UpdateLog(ctx context.Context, req *connect_go.Request[v1.UpdateLogRequest]) (*connect_go.Response[v1.UpdateLogResponse], error) {
|
|
return c.updateLog.CallUnary(ctx, req)
|
|
}
|
|
|
|
// RunnerServiceHandler is an implementation of the runner.v1.RunnerService service.
|
|
type RunnerServiceHandler interface {
|
|
// Register register a new runner in server.
|
|
Register(context.Context, *connect_go.Request[v1.RegisterRequest]) (*connect_go.Response[v1.RegisterResponse], error)
|
|
// FetchTask requests the next available task for execution.
|
|
FetchTask(context.Context, *connect_go.Request[v1.FetchTaskRequest]) (*connect_go.Response[v1.FetchTaskResponse], error)
|
|
// UpdateTask updates the task status.
|
|
UpdateTask(context.Context, *connect_go.Request[v1.UpdateTaskRequest]) (*connect_go.Response[v1.UpdateTaskResponse], error)
|
|
// UpdateLog uploads log of the task.
|
|
UpdateLog(context.Context, *connect_go.Request[v1.UpdateLogRequest]) (*connect_go.Response[v1.UpdateLogResponse], error)
|
|
}
|
|
|
|
// NewRunnerServiceHandler builds an HTTP handler from the service implementation. It returns the
|
|
// path on which to mount the handler and the handler itself.
|
|
//
|
|
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
|
|
// and JSON codecs. They also support gzip compression.
|
|
func NewRunnerServiceHandler(svc RunnerServiceHandler, opts ...connect_go.HandlerOption) (string, http.Handler) {
|
|
mux := http.NewServeMux()
|
|
mux.Handle("/runner.v1.RunnerService/Register", connect_go.NewUnaryHandler(
|
|
"/runner.v1.RunnerService/Register",
|
|
svc.Register,
|
|
opts...,
|
|
))
|
|
mux.Handle("/runner.v1.RunnerService/FetchTask", connect_go.NewUnaryHandler(
|
|
"/runner.v1.RunnerService/FetchTask",
|
|
svc.FetchTask,
|
|
opts...,
|
|
))
|
|
mux.Handle("/runner.v1.RunnerService/UpdateTask", connect_go.NewUnaryHandler(
|
|
"/runner.v1.RunnerService/UpdateTask",
|
|
svc.UpdateTask,
|
|
opts...,
|
|
))
|
|
mux.Handle("/runner.v1.RunnerService/UpdateLog", connect_go.NewUnaryHandler(
|
|
"/runner.v1.RunnerService/UpdateLog",
|
|
svc.UpdateLog,
|
|
opts...,
|
|
))
|
|
return "/runner.v1.RunnerService/", mux
|
|
}
|
|
|
|
// UnimplementedRunnerServiceHandler returns CodeUnimplemented from all methods.
|
|
type UnimplementedRunnerServiceHandler struct{}
|
|
|
|
func (UnimplementedRunnerServiceHandler) Register(context.Context, *connect_go.Request[v1.RegisterRequest]) (*connect_go.Response[v1.RegisterResponse], error) {
|
|
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("runner.v1.RunnerService.Register is not implemented"))
|
|
}
|
|
|
|
func (UnimplementedRunnerServiceHandler) FetchTask(context.Context, *connect_go.Request[v1.FetchTaskRequest]) (*connect_go.Response[v1.FetchTaskResponse], error) {
|
|
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("runner.v1.RunnerService.FetchTask is not implemented"))
|
|
}
|
|
|
|
func (UnimplementedRunnerServiceHandler) UpdateTask(context.Context, *connect_go.Request[v1.UpdateTaskRequest]) (*connect_go.Response[v1.UpdateTaskResponse], error) {
|
|
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("runner.v1.RunnerService.UpdateTask is not implemented"))
|
|
}
|
|
|
|
func (UnimplementedRunnerServiceHandler) UpdateLog(context.Context, *connect_go.Request[v1.UpdateLogRequest]) (*connect_go.Response[v1.UpdateLogResponse], error) {
|
|
return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("runner.v1.RunnerService.UpdateLog is not implemented"))
|
|
}
|