Documentation
¶
Overview ¶
Package capture implements datacapture for the builtin datamanger
Index ¶
- func DataCaptureConfigKey(resourceString, method string) string
- type Capture
- func (c *Capture) Close(ctx context.Context)
- func (c *Capture) FlushCollectors()
- func (c *Capture) Reconfigure(ctx context.Context, frameSystem framesystem.Service, ...)
- func (c *Capture) SetActiveSequences(active []datamanager.SequenceReading)
- func (c *Capture) SetCaptureConfigs(captureConfigReadings map[string]datamanager.CaptureConfigReading)
- type ClosedSequence
- type CollectorConfigsByResource
- type CollectorResolver
- type Config
- type MongoConfig
- type OpenSequence
- type ResolvedCollector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DataCaptureConfigKey ¶ added in v0.116.0
DataCaptureConfigKey returns the lookup key for a per-resource capture config map.
Types ¶
type Capture ¶ added in v0.44.0
type Capture struct {
// contains filtered or unexported fields
}
Capture polls data sources (resource/method pairs) and writes the responses files. There must be only one Capture per DataManager.
The lifecycle of a Capture is:
- New - Reconfigure (any number of times) - Close (any number of times).
func (*Capture) FlushCollectors ¶ added in v0.44.0
func (c *Capture) FlushCollectors()
FlushCollectors flushes collectors.
func (*Capture) Reconfigure ¶ added in v0.44.0
func (c *Capture) Reconfigure( ctx context.Context, frameSystem framesystem.Service, collectorConfigsByResource CollectorConfigsByResource, deps resource.Dependencies, config Config, )
Reconfigure reconfigures Capture. It is only called by the builtin data manager.
func (*Capture) SetActiveSequences ¶ added in v0.127.0
func (c *Capture) SetActiveSequences(active []datamanager.SequenceReading)
SetActiveSequences reconciles open sequences against the sensor's latest readings. Newly-opened sequences are written to <id>.progseq; ended ones are written to <id>.seq (and the matching .progseq is removed).
func (*Capture) SetCaptureConfigs ¶ added in v0.116.0
func (c *Capture) SetCaptureConfigs(captureConfigReadings map[string]datamanager.CaptureConfigReading)
SetCaptureConfigs applies dynamic per-resource capture configs without triggering a full Reconfigure. Only collectors whose effective config (default + override) has changed are restarted. Passing nil or an empty map reverts all collectors to their default machine configs.
Overrides may target resource/method pairs that are not in the static config. When that happens, the owning resource for the method is resolved from c.deps and a collector is built from the sensor reading. Methods that require additional_params (e.g. board.Analogs, board.Gpios) cannot be enabled this way.
type ClosedSequence ¶ added in v0.127.0
type ClosedSequence struct {
ID string
StartAt time.Time
EndAt time.Time
Resources []datamanager.ResourceMethod
SequenceTags []string
}
ClosedSequence is a sequence that ended and is awaiting upload.
type CollectorConfigsByResource ¶ added in v0.44.0
type CollectorConfigsByResource map[resource.Resource][]ResolvedCollector
CollectorConfigsByResource describes the data capture configuration of the resource/method pairs data capture should capture from. Each carries metadata produced once by ResolveCollector, so no later path re-resolves or re-keys from a raw config.
type CollectorResolver ¶ added in v1.17.0
type CollectorResolver struct {
// contains filtered or unexported fields
}
CollectorResolver resolves capture configs against a dependency set, indexing each resource's served APIs once so resolving many methods (and every capture-control poll) doesn't rebuild the index.
func NewCollectorResolver ¶ added in v1.17.0
func NewCollectorResolver(deps resource.Dependencies) *CollectorResolver
NewCollectorResolver indexes deps by short name for repeated resolution.
func (*CollectorResolver) Resolve ¶ added in v1.17.0
func (r *CollectorResolver) Resolve(cfg datamanager.DataCaptureConfig) (ResolvedCollector, resource.Resource, error)
Resolve resolves the resource serving cfg's capture method and returns it alongside a ResolvedCollector (the collector's metadata plus cfg pinned to the owning API). For a composite it picks the API that implements the method; for an ordinary resource it is the resource's own API. It errors if the method cannot be resolved to one API, or the resolved resource is missing from deps.
type Config ¶
type Config struct {
// CaptureDisabled if set to true disables all data capture collectors
CaptureDisabled bool
// CaptureDir defines where data capture should write capture files
CaptureDir string
// Tags defines the tags that should be added to capture file metadata
Tags []string
// MaximumCaptureFileSizeBytes defines the maximum size that in progress data capture
// (.prog) files should be allowed to grow to before they are convered into .capture
// files
MaximumCaptureFileSizeBytes int64
MongoConfig *MongoConfig
}
Config is the capture config.
type MongoConfig ¶ added in v0.50.0
type MongoConfig struct {
URI string `json:"uri"`
Database string `json:"database"`
Collection string `json:"collection"`
}
MongoConfig is the optional data capture mongo config.
func (MongoConfig) Equal ¶ added in v0.50.0
func (mc MongoConfig) Equal(o MongoConfig) bool
Equal returns true when both MongoConfigs are equal.
type OpenSequence ¶ added in v0.127.0
type OpenSequence struct {
ID string
StartAt time.Time
Resources []datamanager.ResourceMethod
SequenceTags []string
}
OpenSequence is a sequence whose entry is still in the sensor's readings.
type ResolvedCollector ¶ added in v1.17.0
type ResolvedCollector struct {
Metadata collectorMetadata
Config datamanager.DataCaptureConfig
}
ResolvedCollector pairs a collector's resolved identity (metadata) with its config. ResolveCollector is its only producer, so resolution and keying happen once and downstream sites reuse the metadata.