deletion

package
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2023 License: AGPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDeleteRequestNotFound = errors.New("could not find matching delete requests")

Functions

func TenantMiddleware

func TenantMiddleware(limits Limits, next http.Handler) http.Handler

Types

type CompactorClient

type CompactorClient interface {
	GetAllDeleteRequestsForUser(ctx context.Context, userID string) ([]DeleteRequest, error)
	GetCacheGenerationNumber(ctx context.Context, userID string) (string, error)
	Name() string
	Stop()
}

type DeleteRequest

type DeleteRequest struct {
	RequestID string              `json:"request_id"`
	StartTime model.Time          `json:"start_time"`
	EndTime   model.Time          `json:"end_time"`
	Query     string              `json:"query"`
	Status    DeleteRequestStatus `json:"status"`
	CreatedAt model.Time          `json:"created_at"`

	UserID      string `json:"-"`
	SequenceNum int64  `json:"-"`

	Metrics      *deleteRequestsManagerMetrics `json:"-"`
	DeletedLines int32                         `json:"-"`
	// contains filtered or unexported fields
}

func (*DeleteRequest) FilterFunction

func (d *DeleteRequest) FilterFunction(labels labels.Labels) (filter.Func, error)

FilterFunction returns a filter function that returns true if the given line should be deleted based on the DeleteRequest

func (*DeleteRequest) IsDeleted

func (d *DeleteRequest) IsDeleted(entry retention.ChunkEntry) (bool, filter.Func)

IsDeleted checks if the given ChunkEntry will be deleted by this DeleteRequest. It returns a filter.Func if the chunk is supposed to be deleted partially or the delete request contains line filters. If the filter.Func is nil, the whole chunk is supposed to be deleted.

func (*DeleteRequest) SetQuery

func (d *DeleteRequest) SetQuery(logQL string) error

type DeleteRequestClientMetrics

type DeleteRequestClientMetrics struct {
	// contains filtered or unexported fields
}

type DeleteRequestHandler

type DeleteRequestHandler struct {
	// contains filtered or unexported fields
}

DeleteRequestHandler provides handlers for delete requests

func NewDeleteRequestHandler

func NewDeleteRequestHandler(deleteStore DeleteRequestsStore, maxInterval time.Duration, registerer prometheus.Registerer) *DeleteRequestHandler

NewDeleteRequestHandler creates a DeleteRequestHandler

func (*DeleteRequestHandler) AddDeleteRequestHandler

func (dm *DeleteRequestHandler) AddDeleteRequestHandler(w http.ResponseWriter, r *http.Request)

AddDeleteRequestHandler handles addition of a new delete request

func (*DeleteRequestHandler) CancelDeleteRequestHandler

func (dm *DeleteRequestHandler) CancelDeleteRequestHandler(w http.ResponseWriter, r *http.Request)

CancelDeleteRequestHandler handles delete request cancellation

func (*DeleteRequestHandler) GetAllDeleteRequestsHandler

func (dm *DeleteRequestHandler) GetAllDeleteRequestsHandler(w http.ResponseWriter, r *http.Request)

GetAllDeleteRequestsHandler handles get all delete requests

func (*DeleteRequestHandler) GetCacheGenerationNumberHandler

func (dm *DeleteRequestHandler) GetCacheGenerationNumberHandler(w http.ResponseWriter, r *http.Request)

GetCacheGenerationNumberHandler handles requests for a user's cache generation number

type DeleteRequestStatus

type DeleteRequestStatus string
const (
	StatusReceived  DeleteRequestStatus = "received"
	StatusProcessed DeleteRequestStatus = "processed"

	DeleteRequestsTableName = "delete_requests"
)

type DeleteRequestsClient

type DeleteRequestsClient interface {
	GetAllDeleteRequestsForUser(ctx context.Context, userID string) ([]DeleteRequest, error)
	Stop()
}

func NewDeleteRequestsClient

func NewDeleteRequestsClient(compactorClient CompactorClient, deleteClientMetrics *DeleteRequestClientMetrics, clientType string, opts ...DeleteRequestsStoreOption) (DeleteRequestsClient, error)

func NewPerTenantDeleteRequestsClient

func NewPerTenantDeleteRequestsClient(c DeleteRequestsClient, l Limits) DeleteRequestsClient

type DeleteRequestsManager

type DeleteRequestsManager struct {
	// contains filtered or unexported fields
}

func NewDeleteRequestsManager

func NewDeleteRequestsManager(store DeleteRequestsStore, deleteRequestCancelPeriod time.Duration, batchSize int, limits Limits, registerer prometheus.Registerer) *DeleteRequestsManager

func (*DeleteRequestsManager) DropFromIndex

func (d *DeleteRequestsManager) DropFromIndex(_ retention.ChunkEntry, _ model.Time, _ model.Time) bool

func (*DeleteRequestsManager) Expired

func (*DeleteRequestsManager) IntervalMayHaveExpiredChunks

func (d *DeleteRequestsManager) IntervalMayHaveExpiredChunks(_ model.Interval, userID string) bool

func (*DeleteRequestsManager) MarkPhaseFailed

func (d *DeleteRequestsManager) MarkPhaseFailed()

func (*DeleteRequestsManager) MarkPhaseFinished

func (d *DeleteRequestsManager) MarkPhaseFinished()

func (*DeleteRequestsManager) MarkPhaseStarted

func (d *DeleteRequestsManager) MarkPhaseStarted()

func (*DeleteRequestsManager) MarkPhaseTimedOut

func (d *DeleteRequestsManager) MarkPhaseTimedOut()

func (*DeleteRequestsManager) Stop

func (d *DeleteRequestsManager) Stop()

type DeleteRequestsStore

type DeleteRequestsStore interface {
	AddDeleteRequestGroup(ctx context.Context, req []DeleteRequest) ([]DeleteRequest, error)
	GetDeleteRequestsByStatus(ctx context.Context, status DeleteRequestStatus) ([]DeleteRequest, error)
	GetAllDeleteRequestsForUser(ctx context.Context, userID string) ([]DeleteRequest, error)
	UpdateStatus(ctx context.Context, req DeleteRequest, newStatus DeleteRequestStatus) error
	GetDeleteRequestGroup(ctx context.Context, userID, requestID string) ([]DeleteRequest, error)
	RemoveDeleteRequests(ctx context.Context, req []DeleteRequest) error
	GetCacheGenerationNumber(ctx context.Context, userID string) (string, error)
	Stop()
	Name() string
}

func NewDeleteStore

func NewDeleteStore(workingDirectory string, indexStorageClient storage.Client) (DeleteRequestsStore, error)

NewDeleteStore creates a store for managing delete requests.

func NewNoOpDeleteRequestsStore

func NewNoOpDeleteRequestsStore() DeleteRequestsStore

type DeleteRequestsStoreOption

type DeleteRequestsStoreOption func(c *deleteRequestsClient)

func WithRequestClientCacheDuration

func WithRequestClientCacheDuration(d time.Duration) DeleteRequestsStoreOption

type GRPCRequestHandler

type GRPCRequestHandler struct {
	// contains filtered or unexported fields
}

func NewGRPCRequestHandler

func NewGRPCRequestHandler(deleteRequestsStore DeleteRequestsStore, limits Limits) *GRPCRequestHandler

func (*GRPCRequestHandler) GetCacheGenNumbers

func (*GRPCRequestHandler) GetDeleteRequests

type Limits

type Limits interface {
	DeletionMode(userID string) string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL