v1

package
v1.0.0-alpha.36 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AcceptHeader             = "Accept"
	ApplicationJsonHeaderVal = "application/json"
	DDApiKey                 = "DD-API-KEY"
	DDAppKey                 = "DD-APPLICATION-KEY"
	Query                    = "query"
	DDQueryEndpointPath      = "/api/v1/query"
	RateLimitLimit           = "X-RateLimit-Period"
	RateLimitPeriod          = "X-RateLimit-Period"
	RateLimitRemaining       = "X-RateLimit-Remaining"
	RateLimitReset           = "X-RateLimit-Reset"
	RateLimitName            = "X-RateLimit-Name"
)
View Source
const (
	InsertedStatus string = "inserted"
	ReplacedStatus string = "replaced"
	UpdatedStatus  string = "updated"
	DeletedStatus  string = "deleted"
	CreatedStatus  string = "created"
	DroppedStatus  string = "dropped"
)

Variables

View Source
var (
	ErrSearchIndexingFailed = fmt.Errorf("failed to index documents")
)
View Source
var (
	ReservedNamespaceNames = set.New(metadata.DefaultNamespaceName, "unknown")
)

Functions

func CreateSearchKey

func CreateSearchKey(table []byte, fdbKey []byte) (string, error)

func FlattenObjects

func FlattenObjects(data map[string]any) map[string]any

func PackSearchFields

func PackSearchFields(data *internal.TableData, collection *schema.DefaultCollection, id string) ([]byte, error)

func UnFlattenObjects

func UnFlattenObjects(flat map[string]any) map[string]any

func UnpackSearchFields

func UnpackSearchFields(doc map[string]interface{}, collection *schema.DefaultCollection) (string, *internal.TableData, map[string]interface{}, error)

Types

type Auth0

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

func (*Auth0) CreateApplication

func (*Auth0) DeleteApplication

func (*Auth0) GetAccessToken

func (a *Auth0) GetAccessToken(req *api.GetAccessTokenRequest) (*api.GetAccessTokenResponse, error)

type BaseQueryRunner

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

func NewBaseQueryRunner

func NewBaseQueryRunner(encoder metadata.Encoder, cdcMgr *cdc.Manager, txMgr *transaction.Manager, searchStore search.Store) *BaseQueryRunner

type CollectionQueryRunner

type CollectionQueryRunner struct {
	*BaseQueryRunner
	// contains filtered or unexported fields
}

func (*CollectionQueryRunner) Run

func (*CollectionQueryRunner) SetCreateOrUpdateCollectionReq

func (runner *CollectionQueryRunner) SetCreateOrUpdateCollectionReq(create *api.CreateOrUpdateCollectionRequest)

func (*CollectionQueryRunner) SetDescribeCollectionReq

func (runner *CollectionQueryRunner) SetDescribeCollectionReq(describe *api.DescribeCollectionRequest)

func (*CollectionQueryRunner) SetDropCollectionReq

func (runner *CollectionQueryRunner) SetDropCollectionReq(drop *api.DropCollectionRequest)

func (*CollectionQueryRunner) SetListCollectionReq

func (runner *CollectionQueryRunner) SetListCollectionReq(list *api.ListCollectionsRequest)

type ContentType

type ContentType string
const (
	JSON ContentType = "application/json"
)

type DatabaseQueryRunner

type DatabaseQueryRunner struct {
	*BaseQueryRunner
	// contains filtered or unexported fields
}

func (*DatabaseQueryRunner) Run

func (*DatabaseQueryRunner) SetCreateDatabaseReq

func (runner *DatabaseQueryRunner) SetCreateDatabaseReq(create *api.CreateDatabaseRequest)

func (*DatabaseQueryRunner) SetDescribeDatabaseReq

func (runner *DatabaseQueryRunner) SetDescribeDatabaseReq(describe *api.DescribeDatabaseRequest)

func (*DatabaseQueryRunner) SetDropDatabaseReq

func (runner *DatabaseQueryRunner) SetDropDatabaseReq(drop *api.DropDatabaseRequest)

func (*DatabaseQueryRunner) SetListDatabaseReq

func (runner *DatabaseQueryRunner) SetListDatabaseReq(list *api.ListDatabasesRequest)

type DatabaseReader

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

func NewDatabaseReader

func NewDatabaseReader(ctx context.Context, tx transaction.Tx) *DatabaseReader

func (*DatabaseReader) FilteredRead

func (reader *DatabaseReader) FilteredRead(iterator Iterator, filter *filter.WrappedFilter) (Iterator, error)

FilteredRead returns an iterator that implicitly will be doing filtering on the iterator.

func (*DatabaseReader) KeyIterator

func (reader *DatabaseReader) KeyIterator(ikeys []keys.Key) (Iterator, error)

KeyIterator returns an iterator that iterates on a key or a set of keys.

func (*DatabaseReader) ScanIterator

func (reader *DatabaseReader) ScanIterator(from keys.Key) (Iterator, error)

ScanIterator only returns an iterator that has elements starting from.

func (*DatabaseReader) ScanTable

func (reader *DatabaseReader) ScanTable(table []byte) (Iterator, error)

ScanTable returns an iterator for all the rows in this table.

func (*DatabaseReader) StrictlyKeysFrom

func (reader *DatabaseReader) StrictlyKeysFrom(ikeys []keys.Key, from []byte) (Iterator, error)

StrictlyKeysFrom is an optimized version that takes input keys and filter out keys that are lower than the "from".

type Datadog

type Datadog struct {
	config.ObservabilityConfig
}

type DeleteQueryRunner

type DeleteQueryRunner struct {
	*BaseQueryRunner
	// contains filtered or unexported fields
}

func (*DeleteQueryRunner) Run

type FilterIterator

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

FilterIterator only returns elements that match the given predicate.

func NewFilterIterator

func NewFilterIterator(iterator Iterator, filter *filter.WrappedFilter) *FilterIterator

func (*FilterIterator) Interrupted

func (it *FilterIterator) Interrupted() error

func (*FilterIterator) Next

func (it *FilterIterator) Next(row *Row) bool

Next advances the iterator till the matching row found and then only fill the row object. In contrast to Iterator, filterable allows filtering during iterating of document. Underneath it is just using Iterator to iterate over rows to apply filter.

type FilterableSearchIterator

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

func NewFilterableSearchIterator

func NewFilterableSearchIterator(collection *schema.DefaultCollection, reader *pageReader, filter *filter.WrappedFilter, singlePage bool) *FilterableSearchIterator

func (*FilterableSearchIterator) Interrupted

func (it *FilterableSearchIterator) Interrupted() error

func (*FilterableSearchIterator) Next

func (it *FilterableSearchIterator) Next(row *Row) bool

type HitsResponse

type HitsResponse struct {
	Hits *[]tsApi.SearchResultHit
}

func NewHits

func NewHits() *HitsResponse

func (*HitsResponse) Append

func (h *HitsResponse) Append(hit tsApi.SearchResultHit)

func (*HitsResponse) Count

func (h *HitsResponse) Count() int

func (*HitsResponse) GetDocument

func (h *HitsResponse) GetDocument(idx int) (*map[string]interface{}, bool)

func (*HitsResponse) HasMoreHits

func (h *HitsResponse) HasMoreHits(idx int) bool

type InsertQueryRunner

type InsertQueryRunner struct {
	*BaseQueryRunner
	// contains filtered or unexported fields
}

func (*InsertQueryRunner) Run

type Iterator

type Iterator interface {
	// Next fills the next element in the iteration. Returns true if the Iterator has more element.
	Next(*Row) bool
	// Interrupted returns an error if iterator encounters any error.
	Interrupted() error
}

Iterator is to iterate over a single collection.

type KeyIterator

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

func NewKeyIterator

func NewKeyIterator(ctx context.Context, tx transaction.Tx, keys []keys.Key) (*KeyIterator, error)

func (*KeyIterator) Interrupted

func (k *KeyIterator) Interrupted() error

func (*KeyIterator) Next

func (k *KeyIterator) Next(row *Row) bool

type MetricsQueryResp

type MetricsQueryResp struct {
	FromDate int64                    `json:"from_date"`
	ToDate   int64                    `json:"to_date"`
	Query    string                   `json:"query"`
	Series   []MetricsQueryRespSeries `json:"series"`
}

type MetricsQueryRespSeries

type MetricsQueryRespSeries struct {
	Metric   string `json:"metric"`
	FromDate int64  `json:"start"`
	ToDate   int64  `json:"end"`
	Scope    string `json:"scope"`

	PointList [][2]float64 `json:"pointlist"`
}

type NoopTxListener

type NoopTxListener struct{}

func (*NoopTxListener) OnPostCommit

func (*NoopTxListener) OnPreCommit

func (*NoopTxListener) OnRollback

type ObservableProvider

type ObservableProvider interface {
	QueryTimeSeriesMetrics(ctx context.Context, request *api.QueryTimeSeriesMetricsRequest) (*api.QueryTimeSeriesMetricsResponse, error)
}

type QueryRunner

type QueryRunner interface {
	Run(ctx context.Context, tx transaction.Tx, tenant *metadata.Tenant) (*Response, context.Context, error)
}

QueryRunner is responsible for executing the current query and return the response

type QueryRunnerFactory

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

QueryRunnerFactory is responsible for creating query runners for different queries

func NewQueryRunnerFactory

func NewQueryRunnerFactory(txMgr *transaction.Manager, cdcMgr *cdc.Manager, searchStore search.Store) *QueryRunnerFactory

NewQueryRunnerFactory returns QueryRunnerFactory object

func (*QueryRunnerFactory) GetCollectionQueryRunner

func (f *QueryRunnerFactory) GetCollectionQueryRunner() *CollectionQueryRunner

func (*QueryRunnerFactory) GetDatabaseQueryRunner

func (f *QueryRunnerFactory) GetDatabaseQueryRunner() *DatabaseQueryRunner

func (*QueryRunnerFactory) GetDeleteQueryRunner

func (f *QueryRunnerFactory) GetDeleteQueryRunner(r *api.DeleteRequest) *DeleteQueryRunner

func (*QueryRunnerFactory) GetInsertQueryRunner

func (f *QueryRunnerFactory) GetInsertQueryRunner(r *api.InsertRequest) *InsertQueryRunner

func (*QueryRunnerFactory) GetReplaceQueryRunner

func (f *QueryRunnerFactory) GetReplaceQueryRunner(r *api.ReplaceRequest) *ReplaceQueryRunner

func (*QueryRunnerFactory) GetSearchQueryRunner

func (f *QueryRunnerFactory) GetSearchQueryRunner(r *api.SearchRequest, streaming SearchStreaming) *SearchQueryRunner

GetSearchQueryRunner for executing Search

func (*QueryRunnerFactory) GetStreamingQueryRunner

func (f *QueryRunnerFactory) GetStreamingQueryRunner(r *api.ReadRequest, streaming Streaming) *StreamingQueryRunner

GetStreamingQueryRunner returns StreamingQueryRunner

func (*QueryRunnerFactory) GetSubscribeQueryRunner

func (f *QueryRunnerFactory) GetSubscribeQueryRunner(r *api.SubscribeRequest, streaming SubscribeStreaming) *SubscribeQueryRunner

GetSubscribeQueryRunner returns SubscribeQueryRunner

func (*QueryRunnerFactory) GetUpdateQueryRunner

func (f *QueryRunnerFactory) GetUpdateQueryRunner(r *api.UpdateRequest) *UpdateQueryRunner

type QuerySession

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

func (*QuerySession) Commit

func (s *QuerySession) Commit(versionMgr *metadata.VersionHandler, incVersion bool, err error) error

func (*QuerySession) Rollback

func (s *QuerySession) Rollback() error

func (*QuerySession) Run

func (s *QuerySession) Run(runner QueryRunner) (*Response, context.Context, error)

type ReadOnlyQueryRunner

type ReadOnlyQueryRunner interface {
	ReadOnly(ctx context.Context, tenant *metadata.Tenant) (*Response, context.Context, error)
}

ReadOnlyQueryRunner is the QueryRunner which decides inside the ReadOnly method if the query needs to be run inside a transaction or can opt to just execute the query. This interface allows caller to control the state of the transaction or can choose to execute without starting any transaction.

type ReadOnlySession

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

func (*ReadOnlySession) Run

type ReplaceQueryRunner

type ReplaceQueryRunner struct {
	*BaseQueryRunner
	// contains filtered or unexported fields
}

func (*ReplaceQueryRunner) Run

type ReqOptions

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

ReqOptions are options used by queryLifecycle to execute a query

type Response

type Response struct {
	api.Response
	// contains filtered or unexported fields
}

Response is a wrapper on api.Response

type Row

type Row struct {
	Key  []byte
	Data *internal.TableData
}

type ScanIterator

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

func NewScanIterator

func NewScanIterator(ctx context.Context, tx transaction.Tx, from keys.Key) (*ScanIterator, error)

func (*ScanIterator) Interrupted

func (s *ScanIterator) Interrupted() error

func (*ScanIterator) Next

func (s *ScanIterator) Next(row *Row) bool

type SearchIndexer

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

func NewSearchIndexer

func NewSearchIndexer(searchStore search.Store, tenantMgr *metadata.TenantManager) *SearchIndexer

func (*SearchIndexer) OnPostCommit

func (i *SearchIndexer) OnPostCommit(ctx context.Context, tenant *metadata.Tenant, eventListener kv.EventListener) error

func (*SearchIndexer) OnPreCommit

func (*SearchIndexer) OnRollback

type SearchQueryRunner

type SearchQueryRunner struct {
	*BaseQueryRunner
	// contains filtered or unexported fields
}

SearchQueryRunner is a runner used for Queries that are reads and needs to return result in streaming fashion

func (*SearchQueryRunner) ReadOnly

func (runner *SearchQueryRunner) ReadOnly(ctx context.Context, tenant *metadata.Tenant) (*Response, context.Context, error)

ReadOnly on search query runner is implemented as search queries do not need to be inside a transaction; in fact, there is no need to start any transaction for search queries as they are simply forwarded to the indexing store.

type SearchReader

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

SearchReader is responsible for iterating on the search results. It uses pageReader internally to read page and then iterate on documents inside hits.

func NewSearchReader

func NewSearchReader(ctx context.Context, store search.Store, coll *schema.DefaultCollection, query *qsearch.Query) *SearchReader

func (*SearchReader) Iterator

func (reader *SearchReader) Iterator(collection *schema.DefaultCollection, filter *filter.WrappedFilter) *FilterableSearchIterator

func (*SearchReader) SinglePageIterator

func (reader *SearchReader) SinglePageIterator(collection *schema.DefaultCollection, filter *filter.WrappedFilter, pageNo int32) *FilterableSearchIterator

type SearchStreaming

type SearchStreaming interface {
	api.Tigris_SearchServer
}

type Service

type Service interface {
	RegisterHTTP(router chi.Router, inproc *inprocgrpc.Channel) error
	RegisterGRPC(grpc *grpc.Server) error
}

func GetRegisteredServices

func GetRegisteredServices(kvStore kv.KeyValueStore, searchStore search.Store, tenantMgr *metadata.TenantManager, txMgr *transaction.Manager) []Service

type Session

type Session interface {
	Create(ctx context.Context, trackVerInOwnTxn bool, instantVerTracking bool, track bool) (*QuerySession, error)
	Get(ctx context.Context) (*QuerySession, error)
	Remove(ctx context.Context) error
	ReadOnlyExecute(ctx context.Context, runner ReadOnlyQueryRunner, req *ReqOptions) (*Response, error)
	Execute(ctx context.Context, runner QueryRunner, req *ReqOptions) (*Response, error)
	// contains filtered or unexported methods
}

type SessionManager

type SessionManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSessionManager

func NewSessionManager(txMgr *transaction.Manager, tenantMgr *metadata.TenantManager, versionH *metadata.VersionHandler, listeners []TxListener, tenantTracker *metadata.CacheTracker) *SessionManager

func (*SessionManager) Create

func (sessMgr *SessionManager) Create(ctx context.Context, trackVerInOwnTxn bool, instantVerTracking bool, track bool) (*QuerySession, error)

Create returns the QuerySession after creating all the necessary elements that a query execution needs. It first creates or get a tenant, read the metadata version and based on that reload the tenant cache and then finally create a transaction which will be used to execute all the query in this session.

func (*SessionManager) CreateReadOnlySession

func (sessMgr *SessionManager) CreateReadOnlySession(ctx context.Context) (*ReadOnlySession, error)

func (*SessionManager) Execute

func (sessMgr *SessionManager) Execute(ctx context.Context, runner QueryRunner, req *ReqOptions) (*Response, error)

Execute is responsible to execute a query. In a way this method is managing the lifecycle of a query. For implicit transaction everything is done in this method. For explicit transaction, a session may already exist, so it only needs to run without calling Commit/Rollback.

func (*SessionManager) Get

func (sessMgr *SessionManager) Get(ctx context.Context) (*QuerySession, error)

func (*SessionManager) ReadOnlyExecute

func (sessMgr *SessionManager) ReadOnlyExecute(ctx context.Context, runner ReadOnlyQueryRunner, req *ReqOptions) (*Response, error)

func (*SessionManager) Remove

func (sessMgr *SessionManager) Remove(ctx context.Context) error

type SessionManagerWithMetrics

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

func NewSessionManagerWithMetrics

func NewSessionManagerWithMetrics(txMgr *transaction.Manager, tenantMgr *metadata.TenantManager, versionH *metadata.VersionHandler, listeners []TxListener, tenantTracker *metadata.CacheTracker) *SessionManagerWithMetrics

func (SessionManagerWithMetrics) Create

func (m SessionManagerWithMetrics) Create(ctx context.Context, trackVerInOwnTxn bool, instantVerTracking bool, track bool) (qs *QuerySession, err error)

func (SessionManagerWithMetrics) Execute

func (m SessionManagerWithMetrics) Execute(ctx context.Context, runner QueryRunner, req *ReqOptions) (resp *Response, err error)

func (SessionManagerWithMetrics) Get

func (SessionManagerWithMetrics) ReadOnlyExecute

func (m SessionManagerWithMetrics) ReadOnlyExecute(ctx context.Context, runner ReadOnlyQueryRunner, req *ReqOptions) (resp *Response, err error)

func (SessionManagerWithMetrics) Remove

func (m SessionManagerWithMetrics) Remove(ctx context.Context) (err error)

type Streaming

type Streaming interface {
	api.Tigris_ReadServer
}

Streaming is a wrapper interface for passing around for streaming reads

type StreamingQueryRunner

type StreamingQueryRunner struct {
	*BaseQueryRunner
	// contains filtered or unexported fields
}

StreamingQueryRunner is a runner used for Queries that are reads and needs to return result in streaming fashion

func (*StreamingQueryRunner) ReadOnly

func (runner *StreamingQueryRunner) ReadOnly(ctx context.Context, tenant *metadata.Tenant) (*Response, context.Context, error)

ReadOnly is used by the read query runner to handle long-running reads. This method operates by starting a new transaction when needed which means a single user request may end up creating multiple read only transactions.

func (*StreamingQueryRunner) Run

Run is responsible for running the read in the transaction started by the session manager. This doesn't do any retry if we see ErrTransactionMaxDurationReached which is expected because we do not expect caller to do long reads in an explicit transaction.

type SubscribeQueryRunner

type SubscribeQueryRunner struct {
	*BaseQueryRunner
	// contains filtered or unexported fields
}

func (*SubscribeQueryRunner) Run

type SubscribeStreaming

type SubscribeStreaming interface {
	api.Tigris_SubscribeServer
}

type TxListener

type TxListener interface {
	// OnPreCommit is called before committing the transaction. This means this method is useful when an operation needs
	// to guarantee transaction atomicity. Error returned by this method will roll back the user transaction.
	OnPreCommit(context.Context, *metadata.Tenant, transaction.Tx, kv.EventListener) error
	// OnPostCommit is called after committing the transaction. This means the transaction is complete and any post
	// activity can happen as part of this implementation.
	OnPostCommit(context.Context, *metadata.Tenant, kv.EventListener) error
	// OnRollback is called when the user transaction is rolled back.
	OnRollback(context.Context, *metadata.Tenant, kv.EventListener)
}

TxListener allows listening to a transaction outcome and process the events that is passed in the param accordingly.

type UpdateQueryRunner

type UpdateQueryRunner struct {
	*BaseQueryRunner
	// contains filtered or unexported fields
}

func (*UpdateQueryRunner) Run

Jump to

Keyboard shortcuts

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