mirror of
https://github.com/hanzoai/o11y.git
synced 2026-10-15 12:58:33 +00:00
The five claim verbs need the address an operation will answer at, which is a root joined with a path. They used to ask the target for its prefix through a struct written to answer with one — and that struct existed for a second reason that has since gone: an operation with no declared id took a shape-derived one qualified by the prefix of the occurrence it answered under, so a plain group would have renamed every undeclared id. All 319 operations state their own id now, so a declared id survives composition verbatim and the group is just a group. The roots are this package's own constants, so each group carries the one it was made with and nothing can disagree about the address. The escape hatches name their whole address and register through Raw, which says which method each one answers. The test that measured the gap reached zero and said so; it now holds the property from the other side, that no operation goes undeclared. Co-authored-by: Hanzo Dev <[email protected]>
34 lines
1.3 KiB
Go
34 lines
1.3 KiB
Go
package queryprogress
|
|
|
|
import (
|
|
"log/slog"
|
|
|
|
datastore "github.com/hanzo-ds/go"
|
|
"github.com/hanzoai/o11y/pkg/query-service/model"
|
|
)
|
|
|
|
type QueryProgressTracker interface {
|
|
// Tells the tracker that query with id `queryId` has started.
|
|
// Progress can only be reported for and tracked for a query that is in progress.
|
|
// Returns a cleanup function that must be called after the query finishes.
|
|
ReportQueryStarted(queryId string) (postQueryCleanup func(), apiErr *model.ApiError)
|
|
|
|
// Report progress stats received from datastore for `queryId`
|
|
ReportQueryProgress(queryId string, chProgress *datastore.Progress) *model.ApiError
|
|
|
|
// Subscribe to progress updates for `queryId`
|
|
// The returned channel will produce `QueryProgress` instances representing
|
|
// the latest state of query progress stats. Also returns a function that
|
|
// can be called to unsubscribe before the query finishes, if needed.
|
|
SubscribeToQueryProgress(queryId string) (ch <-chan model.QueryProgress, unsubscribe func(), apiErr *model.ApiError)
|
|
}
|
|
|
|
func NewQueryProgressTracker(logger *slog.Logger) QueryProgressTracker {
|
|
// InMemory tracker is useful only for single replica query service setups.
|
|
// Multi replica setups must use a centralized store for tracking and subscribing to query progress
|
|
return &inMemoryQueryProgressTracker{
|
|
logger: logger,
|
|
queries: map[string]*queryTracker{},
|
|
}
|
|
}
|