Documentation
¶
Index ¶
- Constants
- type Config
- type DatasetSpec
- type Driver
- func (d *Driver) BulkWriter(dataset store.Dataset) (store.BulkWriter, error)
- func (d *Driver) Count(ctx context.Context, s store.Scope, filters []store.Filter) (int64, error)
- func (d *Driver) CountInWindow(ctx context.Context, s store.Scope, filters []store.Filter, ...) (int64, error)
- func (d *Driver) DescribeFields(ctx context.Context, s store.Scope) ([]store.Field, error)
- func (d *Driver) Dialect() string
- func (d *Driver) Drop(ctx context.Context, s store.Scope) (int64, error)
- func (d *Driver) FetchByID(ctx context.Context, s store.Scope, id string) (json.RawMessage, error)
- func (d *Driver) FetchN(ctx context.Context, s store.Scope, filters []store.Filter, n int) ([]json.RawMessage, error)
- func (d *Driver) FetchPage(ctx context.Context, s store.Scope, filters []store.Filter, page store.Page) ([]json.RawMessage, int64, error)
- func (d *Driver) FetchQuery(ctx context.Context, s store.Scope, sql string) ([]json.RawMessage, error)
- func (d *Driver) Flush(ctx context.Context, dataset store.Dataset) error
- func (d *Driver) GroupBy(ctx context.Context, s store.Scope, fields []string, filters []store.Filter, ...) ([]store.Group, error)
- func (d *Driver) Health(ctx context.Context) (store.Health, error)
- func (d *Driver) Insert(ctx context.Context, s store.Scope, id string, doc any) error
- func (d *Driver) RawQuery(ctx context.Context, s store.Scope, query string) ([]map[string]any, error)
- func (d *Driver) Retention(ctx context.Context, dataset store.Dataset) (store.Retention, error)
- func (d *Driver) SetRetention(ctx context.Context, dataset store.Dataset, r store.Retention) error
- func (d *Driver) Timeline(ctx context.Context, s store.Scope, filters []store.Filter, iv store.Interval) ([]store.Point, error)
- func (d *Driver) TimelineByField(ctx context.Context, s store.Scope, field string, filters []store.Filter, ...) ([]store.Series, error)
- func (d *Driver) TopValues(ctx context.Context, s store.Scope, field string, filters []store.Filter, ...) ([]store.Bucket, error)
- func (d *Driver) UpdateWhere(ctx context.Context, s store.Scope, filters []store.Filter, ...) (int64, error)
- func (d *Driver) Usage(ctx context.Context) ([]store.DatasetUsage, error)
- type Layout
- type SpecLayout
- func (l SpecLayout) DataTypeOf(ds store.Dataset, index string) string
- func (l SpecLayout) DataTypeOfPattern(ds store.Dataset, pattern string) (dataType string, ok bool)
- func (l SpecLayout) Datasets() []store.Dataset
- func (l SpecLayout) ReadIndices(s store.Scope) ([]string, error)
- func (l SpecLayout) WriteIndex(s store.Scope, now time.Time) (string, error)
Constants ¶
const DialectSQL = "opensearch-sql"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Layout Layout
// TenantField is required: a default would let a typo silently disable
// tenant isolation.
TenantField string
TimestampField string // defaults to @timestamp
RetentionPolicyID string // ISM policy; empty disables Retention
// TextFields names, per dataset, the field holding a record's raw text,
// which is what OpSearch reads. A dataset missing here has no text to
// search and OpSearch on it is an error, not an empty result.
TextFields map[store.Dataset]string
}
type DatasetSpec ¶
type DatasetSpec struct {
Prefix string
IncludeDataType bool
// DateFormat is a Go time layout; empty means the index does not roll.
DateFormat string
}
DatasetSpec describes one dataset as "<prefix>[-<dataType>][-<date>]".
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver holds no connection: the os package keeps a process-wide client.
func (*Driver) BulkWriter ¶
func (*Driver) CountInWindow ¶
func (*Driver) DescribeFields ¶
func (*Driver) Drop ¶
Drop deletes by query rather than dropping indices, so a scoped delete can never reach another tenant's records sharing the same index.
func (*Driver) FetchQuery ¶
func (d *Driver) FetchQuery(ctx context.Context, s store.Scope, sql string) ([]json.RawMessage, error)
FetchQuery is RawQuery under the agnostic name
func (*Driver) RawQuery ¶
func (d *Driver) RawQuery(ctx context.Context, s store.Scope, query string) ([]map[string]any, error)
RawQuery runs caller-supplied query text. It requires store.AllTenants because the driver cannot inject a tenant predicate into text it did not build — refusing is the only honest option, and it forces the caller to acknowledge that the query reads across tenants.
func (*Driver) Retention ¶
Retention reads one ISM policy, so every dataset it covers reports the same.
func (*Driver) SetRetention ¶
SetRetention patches the deleting transition of the raw policy document and writes it back, so fields this package does not model survive the round trip.
func (*Driver) TimelineByField ¶
func (*Driver) UpdateWhere ¶
type Layout ¶
type Layout interface {
ReadIndices(s store.Scope) ([]string, error)
WriteIndex(s store.Scope, now time.Time) (string, error)
Datasets() []store.Dataset
DataTypeOf(ds store.Dataset, index string) string
}
Layout maps datasets to physical indices. The application supplies one.
type SpecLayout ¶
type SpecLayout map[store.Dataset]DatasetSpec
SpecLayout covers any prefix-and-date naming scheme without writing code.
func (SpecLayout) DataTypeOf ¶
func (l SpecLayout) DataTypeOf(ds store.Dataset, index string) string
DataTypeOf strips the prefix and the segments the date format contributes.
func (SpecLayout) DataTypeOfPattern ¶
DataTypeOfPattern is the reverse of ReadIndices: given an index pattern as a v11 rule writes it ("v11-log-deceptive-bytes-*"), it names the dataType that pattern reads. A pattern covering every dataType ("v11-log-*") reports an empty one. ok is false for a pattern that is not of this dataset's shape — a different prefix, or a wildcard anywhere but the end — so that an unknown pattern is refused rather than read as something it is not.
func (SpecLayout) Datasets ¶
func (l SpecLayout) Datasets() []store.Dataset
func (SpecLayout) ReadIndices ¶
func (l SpecLayout) ReadIndices(s store.Scope) ([]string, error)