rpcs

package
v0.0.0-...-ff9afc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Overview

Package rpcs implements public API RPC handlers.

Index

Constants

View Source
const MaxOutputLength = 160 * model.ChunkSize

MaxOutputLength is the maximum (and default) amount of output to fetch, mostly for compatibility with previous behavior. See model.ChunkSize.

Variables

This section is empty.

Functions

func CheckListingPerm

func CheckListingPerm(ctx context.Context, filter model.Filter, perm realms.Permission) error

CheckListingPerm checks the caller can perform a listing using the given tags or dimensions filter.

It checks either the global ACL (if the filter doesn't specify any concrete pools to restrict the listing to) or ACLs of pools specified by the filter.

Returns nil if it is OK to proceed or a gRPC error to stop. The error should be returned by the RPC as is.

func ConfigureMigration

func ConfigureMigration(srv *prpc.Server, prx *pyproxy.Proxy)

ConfigureMigration sets up proxy rules that send a portion of pRPC traffic to the Python host.

Requests that hit the Go server are either handled by it or get proxied to the Python server, based on `traffic_migration` table in settings.cfg.

Additionally all listing RPCs that use cursors are routed based on the cursor format. The Go server doesn't understand the Python cursor and vice-versa, so a listing started on e.g. Python server should be resumed there.

func FetchTaskRequest

func FetchTaskRequest(ctx context.Context, taskID string) (*model.TaskRequest, error)

FetchTaskRequest fetches a task request given its ID.

Returns gRPC status errors, logs internal errors. Does not check ACLs yet. It is the caller's responsibility.

func ServerInterceptor

func ServerInterceptor(cfg *cfg.Provider, services []string) grpcutil.UnifiedServerInterceptor

ServerInterceptor returns an interceptor that initializes per-RPC context.

The interceptor is active only for selected gRPC services. All other RPCs are passed through unaffected.

The initialized context will have RequestState populated, use State(ctx) to get it.

func StartTaskListingRequest

func StartTaskListingRequest(ctx context.Context, req *TaskListingRequest) ([]*datastore.Query, error)

StartTaskListingRequest is a common part of all requests that list or count tasks with filtering by tags and state.

It checks ACLs based on what pools are queried and prepares datastore queries (to be run in parallel) that return the matching TaskResultSummary entities.

Returns gRPC errors. If the query is already known to produce no results at all (may happen when using time range filters with cursors), returns an empty list of queries.

func ValidateLimit

func ValidateLimit(val int32) (int32, error)

ValidateLimit validates a page size limit in listing queries.

Types

type BotsServer

type BotsServer struct {
	apipb.UnimplementedBotsServer

	// BotQuerySplitMode controls how "finely" to split BotInfo queries.
	BotQuerySplitMode model.SplitMode
	// BotsDimensionsCache caches aggregated bot dimensions sets.
	BotsDimensionsCache model.BotsDimensionsCache
}

BotsServer implements Bots gRPC service.

It exposes methods to view and manipulate state of Swarming bots. Individual RPCs are implemented in bots_*.go files.

func (*BotsServer) CountBots

func (srv *BotsServer) CountBots(ctx context.Context, req *apipb.BotsCountRequest) (*apipb.BotsCount, error)

CountBots implements the corresponding RPC method.

func (*BotsServer) DeleteBot

func (*BotsServer) DeleteBot(ctx context.Context, req *apipb.BotRequest) (*apipb.DeleteResponse, error)

DeleteBot implements the corresponding RPC method.

func (*BotsServer) GetBot

func (*BotsServer) GetBot(ctx context.Context, req *apipb.BotRequest) (*apipb.BotInfo, error)

GetBot implements the corresponding RPC method.

func (*BotsServer) GetBotDimensions

func (s *BotsServer) GetBotDimensions(ctx context.Context, req *apipb.BotsDimensionsRequest) (*apipb.BotsDimensions, error)

GetBotDimensions implements the corresponding RPC method.

func (*BotsServer) ListBotEvents

ListBotEvents implements the corresponding RPC method.

func (*BotsServer) ListBotTasks

func (s *BotsServer) ListBotTasks(ctx context.Context, req *apipb.BotTasksRequest) (*apipb.TaskListResponse, error)

ListBotTasks implements the corresponding RPC method.

func (*BotsServer) ListBots

ListBots implements the corresponding RPC method.

type RequestState

type RequestState struct {
	// Config is a snapshot of the server configuration when request started.
	Config *cfg.Config
	// ACL can be used to check ACLs.
	ACL *acls.Checker
}

RequestState carries stated scoped to a single RPC handler.

In production produced by ServerInterceptor. In tests can be injected into the context via MockRequestState(...).

Use State(ctx) to get the current value.

func State

func State(ctx context.Context) *RequestState

State accesses the per-request state in the context or panics if it is not there.

type SwarmingServer

type SwarmingServer struct {
	apipb.UnimplementedSwarmingServer

	// ServerVersion is the version of the executing binary.
	ServerVersion string
}

SwarmingServer implements Swarming gRPC service.

It is a collection of various RPCs that didn't fit other services. Individual RPCs are implemented in swarming_*.go files.

func (*SwarmingServer) GetDetails

func (srv *SwarmingServer) GetDetails(ctx context.Context, _ *emptypb.Empty) (*apipb.ServerDetails, error)

GetDetails implements the corresponding RPC method.

func (*SwarmingServer) GetPermissions

GetPermissions implements the corresponding RPC method.

func (*SwarmingServer) GetToken

func (srv *SwarmingServer) GetToken(ctx context.Context, _ *emptypb.Empty) (*apipb.BootstrapToken, error)

GetToken implements the corresponding RPC method.

type TaskBackend

type TaskBackend struct {
	bbpb.UnimplementedTaskBackendServer

	// BuildbucketTarget is "swarming://<swarming-cloud-project>".
	BuildbucketTarget string
	// BuildbucketAccount is the Buildbucket service account to expect calls from.
	BuildbucketAccount string
	// DisableBuildbucketCheck is true when running locally.
	DisableBuildbucketCheck bool

	TasksServer *TasksServer
}

TaskBackend implements bbpb.TaskBackendServer.

func (*TaskBackend) CancelTasks

CancelTasks implements bbpb.TaskBackendServer.

func (*TaskBackend) CheckBuildbucket

func (srv *TaskBackend) CheckBuildbucket(ctx context.Context) error

CheckBuildbucket returns a gRPC error if the caller is not Buildbucket.

func (*TaskBackend) FetchTasks

FetchTasks implements bbpb.TaskBackendServer.

func (*TaskBackend) ValidateConfigs

ValidateConfigs implements bbpb.TaskBackendServer.

type TaskListingRequest

type TaskListingRequest struct {
	// Permission that the caller must have in all requested pools.
	Perm realms.Permission
	// Start of the time range to query or nil if unlimited.
	Start *timestamppb.Timestamp
	// End of the time range to query or nil if unlimited.
	End *timestamppb.Timestamp
	// Filter on the task state.
	State apipb.StateQuery
	// How to sort the tasks.
	Sort apipb.SortQuery
	// Filter on the task tags.
	Tags []string
	// Serialized cursor.
	Cursor string
	// Expected kind of the cursor (ignored if there's no cursor).
	CursorKind cursorpb.RequestKind
	// How many entities each subquery can return at most (or 0 for unlimited).
	Limit int32
	// How to split complex queries into parallel queries.
	SplitMode model.SplitMode
}

TaskListingRequest describes details of a task listing request.

type TasksServer

type TasksServer struct {
	apipb.UnimplementedTasksServer

	// TaskQuerySplitMode controls how "finely" to split TaskResultSummary queries.
	TaskQuerySplitMode model.SplitMode

	// TaskLifecycleTasks is used to emit TQ tasks related to Swarming task lifecycle.
	TaskLifecycleTasks tasks.LifecycleTasks
}

TasksServer implements Tasks gRPC service.

It exposes methods to view and manipulate state of Swarming tasks. Individual RPCs are implemented in tasks_*.go files.

func (*TasksServer) BatchGetResult

BatchGetResult implements the corresponding RPC method.

func (*TasksServer) CancelTask

CancelTask implements the corresponding RPC method.

func (*TasksServer) CancelTasks

CancelTasks implements the corresponding RPC method.

func (*TasksServer) CountTasks

func (srv *TasksServer) CountTasks(ctx context.Context, req *apipb.TasksCountRequest) (*apipb.TasksCount, error)

CountTasks returns the latest task count for the given request.

func (*TasksServer) GetRequest

GetRequest fetches a model.TaskRequest for a given apipb.TaskIdRequest.

func (*TasksServer) GetResult

GetResult implements the corresponding RPC method.

func (*TasksServer) GetStdout

GetStdout implements the corresponding RPC method.

func (*TasksServer) ListTaskRequests

func (srv *TasksServer) ListTaskRequests(ctx context.Context, req *apipb.TasksRequest) (*apipb.TaskRequestsResponse, error)

ListTaskRequests implements the corresponding RPC method.

func (*TasksServer) ListTaskStates

func (srv *TasksServer) ListTaskStates(ctx context.Context, req *apipb.TaskStatesRequest) (*apipb.TaskStates, error)

ListTaskStates implements the corresponding RPC method.

func (*TasksServer) ListTasks

ListTasks implements the corresponding RPC method.

func (*TasksServer) NewTask

NewTask implements the corresponding RPC method.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL