Documentation ¶
Overview ¶
Package rpcs implements public API RPC handlers.
Index ¶
- Constants
- func CheckListingPerm(ctx context.Context, filter model.Filter, perm realms.Permission) error
- func ConfigureMigration(srv *prpc.Server, prx *pyproxy.Proxy)
- func FetchTaskRequest(ctx context.Context, taskID string) (*model.TaskRequest, error)
- func ServerInterceptor(cfg *cfg.Provider, services []string) grpcutil.UnifiedServerInterceptor
- func StartTaskListingRequest(ctx context.Context, req *TaskListingRequest) ([]*datastore.Query, error)
- func ValidateLimit(val int32) (int32, error)
- type BotsServer
- func (srv *BotsServer) CountBots(ctx context.Context, req *apipb.BotsCountRequest) (*apipb.BotsCount, error)
- func (*BotsServer) DeleteBot(ctx context.Context, req *apipb.BotRequest) (*apipb.DeleteResponse, error)
- func (*BotsServer) GetBot(ctx context.Context, req *apipb.BotRequest) (*apipb.BotInfo, error)
- func (s *BotsServer) GetBotDimensions(ctx context.Context, req *apipb.BotsDimensionsRequest) (*apipb.BotsDimensions, error)
- func (*BotsServer) ListBotEvents(ctx context.Context, req *apipb.BotEventsRequest) (*apipb.BotEventsResponse, error)
- func (s *BotsServer) ListBotTasks(ctx context.Context, req *apipb.BotTasksRequest) (*apipb.TaskListResponse, error)
- func (srv *BotsServer) ListBots(ctx context.Context, req *apipb.BotsRequest) (*apipb.BotInfoListResponse, error)
- type RequestState
- type SwarmingServer
- func (srv *SwarmingServer) GetDetails(ctx context.Context, _ *emptypb.Empty) (*apipb.ServerDetails, error)
- func (srv *SwarmingServer) GetPermissions(ctx context.Context, req *apipb.PermissionsRequest) (*apipb.ClientPermissions, error)
- func (srv *SwarmingServer) GetToken(ctx context.Context, _ *emptypb.Empty) (*apipb.BootstrapToken, error)
- type TaskBackend
- func (srv *TaskBackend) CancelTasks(ctx context.Context, req *bbpb.CancelTasksRequest) (*bbpb.CancelTasksResponse, error)
- func (srv *TaskBackend) CheckBuildbucket(ctx context.Context) error
- func (srv *TaskBackend) FetchTasks(ctx context.Context, req *bbpb.FetchTasksRequest) (*bbpb.FetchTasksResponse, error)
- func (srv *TaskBackend) ValidateConfigs(ctx context.Context, req *bbpb.ValidateConfigsRequest) (*bbpb.ValidateConfigsResponse, error)
- type TaskListingRequest
- type TasksServer
- func (*TasksServer) BatchGetResult(ctx context.Context, req *apipb.BatchGetResultRequest) (*apipb.BatchGetResultResponse, error)
- func (srv *TasksServer) CancelTask(ctx context.Context, req *apipb.TaskCancelRequest) (*apipb.CancelResponse, error)
- func (srv *TasksServer) CancelTasks(ctx context.Context, req *apipb.TasksCancelRequest) (*apipb.TasksCancelResponse, error)
- func (srv *TasksServer) CountTasks(ctx context.Context, req *apipb.TasksCountRequest) (*apipb.TasksCount, error)
- func (*TasksServer) GetRequest(ctx context.Context, req *apipb.TaskIdRequest) (*apipb.TaskRequestResponse, error)
- func (*TasksServer) GetResult(ctx context.Context, req *apipb.TaskIdWithPerfRequest) (*apipb.TaskResultResponse, error)
- func (*TasksServer) GetStdout(ctx context.Context, req *apipb.TaskIdWithOffsetRequest) (*apipb.TaskOutputResponse, error)
- func (srv *TasksServer) ListTaskRequests(ctx context.Context, req *apipb.TasksRequest) (*apipb.TaskRequestsResponse, error)
- func (srv *TasksServer) ListTaskStates(ctx context.Context, req *apipb.TaskStatesRequest) (*apipb.TaskStates, error)
- func (srv *TasksServer) ListTasks(ctx context.Context, req *apipb.TasksWithPerfRequest) (*apipb.TaskListResponse, error)
- func (srv *TasksServer) NewTask(ctx context.Context, req *apipb.NewTaskRequest) (*apipb.TaskRequestMetadataResponse, error)
Constants ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (*BotsServer) ListBotEvents(ctx context.Context, req *apipb.BotEventsRequest) (*apipb.BotEventsResponse, error)
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 ¶
func (srv *BotsServer) ListBots(ctx context.Context, req *apipb.BotsRequest) (*apipb.BotInfoListResponse, error)
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 ¶
func (srv *SwarmingServer) GetPermissions(ctx context.Context, req *apipb.PermissionsRequest) (*apipb.ClientPermissions, error)
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 ¶
func (srv *TaskBackend) CancelTasks(ctx context.Context, req *bbpb.CancelTasksRequest) (*bbpb.CancelTasksResponse, error)
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 ¶
func (srv *TaskBackend) FetchTasks(ctx context.Context, req *bbpb.FetchTasksRequest) (*bbpb.FetchTasksResponse, error)
FetchTasks implements bbpb.TaskBackendServer.
func (*TaskBackend) ValidateConfigs ¶
func (srv *TaskBackend) ValidateConfigs(ctx context.Context, req *bbpb.ValidateConfigsRequest) (*bbpb.ValidateConfigsResponse, error)
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 ¶
func (*TasksServer) BatchGetResult(ctx context.Context, req *apipb.BatchGetResultRequest) (*apipb.BatchGetResultResponse, error)
BatchGetResult implements the corresponding RPC method.
func (*TasksServer) CancelTask ¶
func (srv *TasksServer) CancelTask(ctx context.Context, req *apipb.TaskCancelRequest) (*apipb.CancelResponse, error)
CancelTask implements the corresponding RPC method.
func (*TasksServer) CancelTasks ¶
func (srv *TasksServer) CancelTasks(ctx context.Context, req *apipb.TasksCancelRequest) (*apipb.TasksCancelResponse, error)
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 ¶
func (*TasksServer) GetRequest(ctx context.Context, req *apipb.TaskIdRequest) (*apipb.TaskRequestResponse, error)
GetRequest fetches a model.TaskRequest for a given apipb.TaskIdRequest.
func (*TasksServer) GetResult ¶
func (*TasksServer) GetResult(ctx context.Context, req *apipb.TaskIdWithPerfRequest) (*apipb.TaskResultResponse, error)
GetResult implements the corresponding RPC method.
func (*TasksServer) GetStdout ¶
func (*TasksServer) GetStdout(ctx context.Context, req *apipb.TaskIdWithOffsetRequest) (*apipb.TaskOutputResponse, error)
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 ¶
func (srv *TasksServer) ListTasks(ctx context.Context, req *apipb.TasksWithPerfRequest) (*apipb.TaskListResponse, error)
ListTasks implements the corresponding RPC method.
func (*TasksServer) NewTask ¶
func (srv *TasksServer) NewTask(ctx context.Context, req *apipb.NewTaskRequest) (*apipb.TaskRequestMetadataResponse, error)
NewTask implements the corresponding RPC method.
Source Files ¶
- base.go
- bots_count_bots.go
- bots_delete_bot.go
- bots_get_bot.go
- bots_get_bot_dimensions.go
- bots_list_bot_events.go
- bots_list_bot_tasks.go
- bots_list_bots.go
- migration.go
- swarming_get_details.go
- swarming_get_permissions.go
- swarming_get_token.go
- taskbackend_cancel_tasks.go
- taskbackend_fetch_tasks.go
- taskbackend_validate_configs.go
- tasks_batch_get_result.go
- tasks_cancel_task.go
- tasks_cancel_tasks.go
- tasks_count_tasks.go
- tasks_get_request.go
- tasks_get_result.go
- tasks_get_stdout.go
- tasks_list_task_requests.go
- tasks_list_task_states.go
- tasks_list_tasks.go
- tasks_new_task.go