github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/pkg/scheduler/schedulerpb/scheduler.proto (about)

     1  syntax = "proto3";
     2  
     3  package schedulerpb;
     4  
     5  import "github.com/gogo/protobuf/gogoproto/gogo.proto";
     6  import "github.com/weaveworks/common/httpgrpc/httpgrpc.proto";
     7  
     8  option go_package = "schedulerpb";
     9  option (gogoproto.marshaler_all) = true;
    10  option (gogoproto.unmarshaler_all) = true;
    11  
    12  // Scheduler interface exposed to Queriers.
    13  service SchedulerForQuerier {
    14    // After calling this method, both Querier and Scheduler enter a loop, in which querier waits for
    15    // "SchedulerToQuerier" messages containing HTTP requests and processes them. After processing the request,
    16    // querier signals that it is ready to accept another one by sending empty QuerierToScheduler message.
    17    //
    18    // Long-running loop is used to detect broken connection between scheduler and querier. This is important
    19    // for scheduler to keep a list of connected queriers up-to-date.
    20    rpc QuerierLoop(stream QuerierToScheduler) returns (stream SchedulerToQuerier) {}
    21  
    22    // The querier notifies the query-scheduler that it started a graceful shutdown.
    23    rpc NotifyQuerierShutdown(NotifyQuerierShutdownRequest) returns (NotifyQuerierShutdownResponse);
    24  }
    25  
    26  // Querier reports its own clientID when it connects, so that scheduler knows how many *different* queriers are connected.
    27  // To signal that querier is ready to accept another request, querier sends empty message.
    28  message QuerierToScheduler {
    29    string querierID = 1;
    30  }
    31  
    32  message SchedulerToQuerier {
    33    // Query ID as reported by frontend. When querier sends the response back to frontend (using frontendAddress),
    34    // it identifies the query by using this ID.
    35    uint64 queryID = 1;
    36    httpgrpc.HTTPRequest httpRequest = 2;
    37  
    38    // Where should querier send HTTP Response to (using FrontendForQuerier interface).
    39    string frontendAddress = 3;
    40  
    41    // User who initiated the request. Needed to send reply back to frontend.
    42    string userID = 4;
    43  
    44    // Whether query statistics tracking should be enabled. The response will include
    45    // statistics only when this option is enabled.
    46    bool statsEnabled = 5;
    47  }
    48  
    49  // Scheduler interface exposed to Frontend. Frontend can enqueue and cancel requests.
    50  service SchedulerForFrontend {
    51    // After calling this method, both Frontend and Scheduler enter a loop. Frontend will keep sending ENQUEUE and
    52    // CANCEL requests, and scheduler is expected to process them. Scheduler returns one response for each request.
    53    //
    54    // Long-running loop is used to detect broken connection between frontend and scheduler. This is important for both
    55    // parties... if connection breaks, frontend can cancel (and possibly retry on different scheduler) all pending
    56    // requests sent to this scheduler, while scheduler can cancel queued requests from given frontend.
    57    rpc FrontendLoop(stream FrontendToScheduler) returns (stream SchedulerToFrontend) {}
    58  }
    59  
    60  enum FrontendToSchedulerType {
    61    INIT = 0;
    62    ENQUEUE = 1;
    63    CANCEL = 2;
    64  }
    65  
    66  message FrontendToScheduler {
    67    FrontendToSchedulerType type = 1;
    68  
    69    // Used by INIT message. Will be put into all requests passed to querier.
    70    string frontendAddress = 2;
    71  
    72    // Used by ENQUEUE and CANCEL.
    73    // Each frontend manages its own queryIDs. Different frontends may use same set of query IDs.
    74    uint64 queryID = 3;
    75  
    76    // Following are used by ENQUEUE only.
    77    string userID = 4;
    78    httpgrpc.HTTPRequest httpRequest = 5;
    79    bool statsEnabled = 6;
    80  }
    81  
    82  enum SchedulerToFrontendStatus {
    83    OK = 0;
    84    TOO_MANY_REQUESTS_PER_TENANT = 1;
    85    ERROR = 2;
    86    SHUTTING_DOWN = 3;
    87  }
    88  
    89  message SchedulerToFrontend {
    90    SchedulerToFrontendStatus status = 1;
    91    string error = 2;
    92  }
    93  
    94  message NotifyQuerierShutdownRequest {
    95    string querierID = 1;
    96  }
    97  
    98  message NotifyQuerierShutdownResponse {}