cache

package
v0.1.51 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidID = errors.New("invalid ID: contains path traversal characters")

ErrInvalidID is returned when an ID contains path traversal characters.

Functions

func DiffIds

func DiffIds(remoteIds, cachedIds []string) (toFetch, toDelete []string)

DiffIds computes which IDs need to be fetched and which need to be deleted. Returns (toFetch, toDelete).

Types

type SpanCache

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

SpanCache manages local caching of spans (pre-app-start or global). Cache files are stored as protobuf-serialized .bin files named by span ID.

func NewSpanCache

func NewSpanCache(serviceID string, spanType SpanType) (*SpanCache, error)

NewSpanCache creates a new SpanCache for the given service ID and span type. The cache directory is: <os.UserCacheDir()>/tusk/<serviceID>/spans/<spanType>/

func (*SpanCache) DeleteSpans

func (c *SpanCache) DeleteSpans(ids []string) error

DeleteSpans removes the specified span IDs from cache.

func (*SpanCache) GetCachedIds

func (c *SpanCache) GetCachedIds() ([]string, error)

GetCachedIds returns the IDs of all cached spans by listing .bin files.

func (*SpanCache) LoadAllSpans

func (c *SpanCache) LoadAllSpans() ([]*core.Span, error)

LoadAllSpans loads all cached spans.

func (*SpanCache) LoadSpan

func (c *SpanCache) LoadSpan(id string) (*core.Span, error)

LoadSpan loads a single span from cache by ID.

func (*SpanCache) SaveSpans

func (c *SpanCache) SaveSpans(spans []*core.Span) error

SaveSpans saves multiple spans to cache.

type SpanType

type SpanType string

SpanType identifies the type of spans being cached.

const (
	// SpanTypePreAppStart is for pre-app-start spans.
	SpanTypePreAppStart SpanType = "preappstart"
	// SpanTypeGlobal is for global spans.
	SpanTypeGlobal SpanType = "global"
)

type TraceCache

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

TraceCache manages local caching of cloud trace tests. Cache files are stored as protobuf-serialized .bin files named by trace test ID.

func NewTraceCache

func NewTraceCache(serviceID string) (*TraceCache, error)

NewTraceCache creates a new TraceCache for the given service ID. The cache directory is: <os.UserCacheDir()>/tusk/<serviceID>/traces/

func (*TraceCache) DeleteTraces

func (c *TraceCache) DeleteTraces(ids []string) error

DeleteTraces removes the specified trace test IDs from cache.

func (*TraceCache) GetCachedIds

func (c *TraceCache) GetCachedIds() ([]string, error)

GetCachedIds returns the IDs of all cached trace tests by listing .bin files.

func (*TraceCache) LoadAllTraces

func (c *TraceCache) LoadAllTraces() ([]*backend.TraceTest, error)

LoadAllTraces loads all cached trace tests.

func (*TraceCache) LoadTrace

func (c *TraceCache) LoadTrace(id string) (*backend.TraceTest, error)

LoadTrace loads a single trace test from cache by ID.

func (*TraceCache) SaveTraces

func (c *TraceCache) SaveTraces(traces []*backend.TraceTest) error

SaveTraces saves multiple trace tests to cache.

Jump to

Keyboard shortcuts

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