// Copyright 2025 Google LLC All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package allocation;
option go_package = "./allocation";
import "google/rpc/status.proto";
import "proto/allocation/allocation.proto";
// [Stage: Dev]
// [FeatureFlag:ProcessorAllocator]
// The Processor service is used to process batches of allocation requests
// and is designed to be used in a pull model with gRPC streaming.
service Processor {
// StreamBatches processes a stream of ProcessorMessage requests and returns a stream of ProcessorMessage responses.
rpc StreamBatches(stream ProcessorMessage) returns (stream ProcessorMessage);
}
// The ProcessorMessage is used to send and receive messages between the client and server.
message ProcessorMessage {
// The client ID is used to identify the client that is sending the message.
string client_id = 1;
// The payload is a oneof field that can contain either a PullRequest, Batch, or BatchResponse.
oneof payload {
// A PullRequest is used to request a batch of allocation requests.
PullRequest pull = 2;
// A BatchRequest is used to send a batch of allocation requests.
BatchRequest batch_request = 3;
// A BatchResponse is used to send a response to a batch of allocation requests.
BatchResponse batch_response = 4;
}
}
// A PullRequest is used to request a batch of allocation requests.
message PullRequest {
string message = 1;
}
// BatchRequest to encapsulate multiple allocation requests
// This is used to send a batch of requests in a single gRPC call.
message BatchRequest {
// Unique batch ID for tracking
string batch_id = 1;
// List of allocation requests
repeated RequestWrapper requests = 2;
}
// RequestWrapper to encapsulate individual allocation requests
message RequestWrapper {
// Unique request ID for tracking
string request_id = 1;
// The actual allocation request
allocation.AllocationRequest request = 2;
}
// BatchResponse to encapsulate multiple allocation responses
message BatchResponse {
// Unique batch ID for tracking
string batch_id = 1;
// List of responses for each request in the batch
repeated ResponseWrapper responses = 2;
}
// ResponseWrapper to encapsulate individual allocation responses
message ResponseWrapper {
// Unique request ID for tracking
string request_id = 1;
// The actual allocation response
oneof result {
// Successful response
allocation.AllocationResponse response = 2;
// Error response
google.rpc.Status error = 3;
}
}