api

package
v0.0.0-...-4c2d33b Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PropKeyInvalid = "invalid"
View Source
var TestDatadirRoot = filepath.Join(os.TempDir(), "catd_api_test")

Functions

func Master

func Master(datadir string, body io.Reader) (written int64, err error)

Master stores the incoming CatTracks in their original form (EXACTLY as posted; reading from the request body) in a file <datadir>/master.json.gz. Each call to Master appends to the file. The 'body' value is written in its entirety with a single newline following. Users of the master file should note that this results in lines which may be longer than bufio.MaxScanTokenSize, and should be prepared to handle this.

Types

type Cat

type Cat struct {
	CatID   conceptual.CatID
	DataDir string

	// Ok, actually we DO have to have/want a conn to state.
	// An API function might use another API function,
	// and they might want to share a state conn.
	State *state.CatState
	// contains filtered or unexported fields
}

Cat is the API representation of a cat. It does not reflect cat state. (Well, it can _reflect_ it, but not ~be~ it). It CAN reflect values about some (assumed, or inferred) cat, where data for the cat can come from some context, like a token (permissions), a CLI-flag, a URL parameter, or even an environment value. Anywhere cat data comes from, that is not the state of this app.

func NewCat

func NewCat(catID conceptual.CatID, datadir string, backend *params.CatRPCServices) (*Cat, error)

NewCat inits a new Cat, but it does not access state. The given datadir should be the CAT datadir (not the daemon datadir).

func (*Cat) CatActPipeline

func (c *Cat) CatActPipeline(ctx context.Context, in <-chan cattrack.CatTrack) error

func (*Cat) CleanTracks

func (c *Cat) CleanTracks(ctx context.Context, in <-chan cattrack.CatTrack) <-chan cattrack.CatTrack

CleanTracks probably doesn't need a cat. FIXME? Turn it loose (method to func; no cat needed).

func (*Cat) Close

func (c *Cat) Close() error

func (*Cat) ExportInfluxDB

func (c *Cat) ExportInfluxDB(tracks []cattrack.CatTrack) error

func (*Cat) GetDefaultRgeoIndexer

func (c *Cat) GetDefaultRgeoIndexer() (*reducer.CellIndexer, error)

func (*Cat) GetDefaultS2CellIndexer

func (c *Cat) GetDefaultS2CellIndexer() (*reducer.CellIndexer, error)

func (*Cat) ImprovedActTracks

func (c *Cat) ImprovedActTracks(ctx context.Context, in <-chan cattrack.CatTrack) <-chan cattrack.CatTrack

func (*Cat) IsRPCEnabled

func (c *Cat) IsRPCEnabled() bool

func (*Cat) IsRgeoRPCEnabled

func (c *Cat) IsRgeoRPCEnabled() bool

IsRgeoRPCEnabled returns true if the cat has an RPC client for rgeo. It does not check if the rgeo service is running, only if the client is configured.

func (*Cat) IsTilingRPCEnabled

func (c *Cat) IsTilingRPCEnabled() bool

func (*Cat) LockOrLoadState

func (c *Cat) LockOrLoadState(readOnly bool) error

LockOrLoadState makes sure a Cat has r|w CatState. If readOnly is false it will block unless already open.

func (*Cat) MustGetLapState

func (c *Cat) MustGetLapState() *lap.State

func (*Cat) MustGetNapState

func (c *Cat) MustGetNapState() *nap.State

func (*Cat) OffsetIndexer

func (c *Cat) OffsetIndexer(ctx context.Context, in <-chan cattrack.CatTrack) error

OffsetIndexer is a simple indexer that reduces tracks by count and time offsets.

func (*Cat) Populate

func (c *Cat) Populate(ctx context.Context, sort bool, in <-chan cattrack.CatTrack) error

Populate persists incoming CatTracks for one cat.

func (*Cat) PopulateReader

func (c *Cat) PopulateReader(ctx context.Context, sort bool, in io.Reader) (err error)

func (*Cat) ProducerPipelines

func (c *Cat) ProducerPipelines(ctx context.Context, in <-chan cattrack.CatTrack) error

func (*Cat) RGeoIndexTracks

func (c *Cat) RGeoIndexTracks(ctx context.Context, in <-chan cattrack.CatTrack) error

RGeoIndexTracks indexes incoming CatTracks for one cat.

func (*Cat) RgeoCollectLevel

func (c *Cat) RgeoCollectLevel(ctx context.Context, level int) ([]cattrack.CatTrack, error)

RgeoCollectLevel returns all indexed tracks for a given Rgeo level (dataset).

func (*Cat) RgeoDumpLevel

func (c *Cat) RgeoDumpLevel(wr io.Writer, level int) error

func (*Cat) S2CollectLevel

func (c *Cat) S2CollectLevel(ctx context.Context, level catS2.CellLevel) ([]cattrack.CatTrack, error)

S2CollectLevel returns all indexed tracks for a given S2 cell level.

func (*Cat) S2DumpLevel

func (c *Cat) S2DumpLevel(wr io.Writer, level catS2.CellLevel) error

S2CollectLevel writes all indexed tracks for a given S2 cell level.

func (*Cat) S2IndexTracks

func (c *Cat) S2IndexTracks(ctx context.Context, in <-chan cattrack.CatTrack) error

S2IndexTracks indexes incoming CatTracks for one cat.

func (*Cat) StoreLapState

func (c *Cat) StoreLapState(ls *lap.State) error

func (*Cat) StoreNapState

func (c *Cat) StoreNapState(ns *nap.State) error

func (*Cat) StoreSnaps

func (c *Cat) StoreSnaps(ctx context.Context, in <-chan cattrack.CatTrack) (out chan cattrack.CatTrack, errs chan error)

StoreSnaps returns a channel of potentially-transformed CatTracks and a channel of errors. Incoming cattrack Snaps are mutated/transformed -- stripping Base64 data, adding storage URLs -- and likewise forwarded to the output. Output is unbuffered and blocking, requires a consumer. Remember: Snaps for which the handler errors ARE ALSO forwarded to the output channel. This ensures that subsequent track handlers do not miss _any_ tracks because of any Snap logic issues. Errors are forwarded to the error channel. The handler is idempotent and can be run multiple times on the same input.

Cat Snaps are originally uploaded by the client encoded in base64 in a properties attribute 'imgB64'. This handler attempts to decode the data, store it locally as a .jpg, and then upload it to S3. If decoding fails, the original track is forwarded to the output channel unmodified. If upload is successful, the track is modified in-place to include the S3 URL in an attribute 'imgS3', and the original `imgB64` attribute is removed. If upload fails, the original track is forwarded to the output channel unmodified. If the cat handler finds that the snap already exists in the cat state, it is not uploaded again, nor transformed.

func (*Cat) StoreTracks

func (c *Cat) StoreTracks(ctx context.Context, in <-chan cattrack.CatTrack) (errCh chan error)

StoreTracks stores incoming CatTracks for one cat to disk.

func (*Cat) StoreTracksYYYYMM

func (c *Cat) StoreTracksYYYYMM(ctx context.Context, in <-chan cattrack.CatTrack) (errCh chan error)

func (*Cat) SubscribeFancyLogs

func (c *Cat) SubscribeFancyLogs()

func (*Cat) TrackLaps

func (c *Cat) TrackLaps(ctx context.Context, in <-chan cattrack.CatTrack) (*lap.State, <-chan cattrack.CatLap)

func (*Cat) TrackNaps

func (c *Cat) TrackNaps(ctx context.Context, in <-chan cattrack.CatTrack) <-chan cattrack.CatNap

func (*Cat) Unbacktrack

func (c *Cat) Unbacktrack(ctx context.Context, in <-chan cattrack.CatTrack) (<-chan cattrack.CatTrack, func() error)

Unbacktrack is a dangerous device. It prevents tracks from getting populated. It drops (filters) tracks that lie WITHIN a Cat/UUID's already-populated time window. This prevents the cat from back-filling tracks that were missed, if they fall within the already-seen window. But it enables Cat.Populate runs to run idempotently given the same data source.

func (*Cat) Validate

func (c *Cat) Validate(ctx context.Context, in <-chan cattrack.CatTrack) (valid chan cattrack.CatTrack, invalid chan cattrack.CatTrack)

type CatHandler

type CatHandler func(ctx context.Context, in <-chan cattrack.CatTrack) error

type TestCat

type TestCat Cat

func NewTestCatReader

func NewTestCatReader(t *testing.T, name, d string, backend *params.CatRPCServices) *TestCat

func NewTestCatWriter

func NewTestCatWriter(t *testing.T, name string, backend *params.CatRPCServices) *TestCat

NewTestCatWriter creates a new cat with a writable state in a temporary directory inside the TestDatadirRoot.

func (*TestCat) Cat

func (c *TestCat) Cat() *Cat

func (*TestCat) CloseAndDestroy

func (c *TestCat) CloseAndDestroy() error

type Window

type Window struct {
	First time.Time
	Last  time.Time
}

func (*Window) Contains

func (w *Window) Contains(t time.Time) bool

func (*Window) Duration

func (w *Window) Duration() time.Duration

func (*Window) Extend

func (w *Window) Extend(t time.Time)

func (*Window) ExtendFromWindow

func (w *Window) ExtendFromWindow(ww *Window)

func (*Window) String

func (w *Window) String() string

Jump to

Keyboard shortcuts

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