Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
func NewCoordinator ¶
func NewCoordinator(logger log.Logger, store *Store, limits Limits, reg prometheus.Registerer) *Coordinator
func (*Coordinator) PollQuery ¶
PollQuery checks the status of an async query for the given tenant. Returns nil if the request is not found (caller should return NotFound).
func (*Coordinator) Register ¶
func (c *Coordinator) Register(ctx context.Context, tenantID string, resultCh <-chan QueryResult) (string, error)
Register reserves the per-tenant concurrency slot, persists the in-progress metadata, and starts watching resultCh. The caller is responsible for dispatching the query and sending its outcome on resultCh; the coordinator owns reads from the channel, store writes, and the heartbeat loop. Returns the assigned request ID, or an error if the slot could not be acquired.
type Handler ¶
type Handler struct {
querierv1connect.QuerierServiceHandler
// contains filtered or unexported fields
}
Handler decorates a QuerierServiceHandler with async query support for SelectMergeStacktraces. All other RPCs pass through to the embedded handler unchanged.
func NewHandler ¶
func NewHandler(next querierv1connect.QuerierServiceHandler, coordinator *Coordinator) *Handler
func (*Handler) SelectMergeStacktraces ¶
func (h *Handler) SelectMergeStacktraces( ctx context.Context, req *connect.Request[querierv1.SelectMergeStacktracesRequest], ) (*connect.Response[querierv1.SelectMergeStacktracesResponse], error)
SelectMergeStacktraces honors the request's optional Async field:
- Async == nil or Type == DISABLED: run synchronously, return the wrapped handler's response unchanged (Async stays nil).
- Async.RequestId != "": treat as a poll. All other request fields are ignored. The response carries only the Async metadata, plus the result payload on SUCCESS.
- Async.Type == FORCE with empty RequestId: dispatch in the background and return a response carrying only the Async metadata in IN_PROGRESS.
type Metadata ¶
type Metadata struct {
RequestID string `json:"request_id"`
TenantID string `json:"tenant_id"`
Status Status `json:"status"`
CreatedAt time.Time `json:"created_at"`
LastHeartbeat time.Time `json:"last_heartbeat,omitempty"`
ErrorMessage string `json:"error_message,omitempty"`
}
Metadata describes the state of a single async query. It is persisted as metadata.json alongside the query's result in object storage.
type QueryResult ¶
type QueryResult struct {
Response *querierv1.SelectMergeStacktracesResponse
Err error
}
QueryResult is the result of a query execution sent over a channel. On success, Response carries the raw SelectMergeStacktracesResponse from the wrapped handler (its Async field is unset); the coordinator/store own request_id and status.
type Result ¶
type Result struct {
Metadata Metadata
Response *querierv1.SelectMergeStacktracesResponse
}
Result bundles a query's Metadata with its decoded Response. Response is only populated when Metadata.Status is StatusSuccess.
type Status ¶
type Status string
Status represents the lifecycle state of an async query.
const ( // StatusInProgress indicates the query is still executing. StatusInProgress Status = "in_progress" // StatusSuccess indicates the query completed and a result is available. StatusSuccess Status = "success" // StatusFailure indicates the query failed; ErrorMessage holds the reason. StatusFailure Status = "failure" )
type Store ¶
Store persists async query state and results in object storage. It also runs as a dskit service that periodically removes expired entries.