cursor

package
v0.1.48 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Copyright 2018-2019 The logrange Authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cursor

type Cursor interface {
	model.Iterator
	Id() uint64

	// Offset moves the cursor position to backward (negative offset) of forward(positive offset)
	// from the current cursor position
	Offset(ctx context.Context, offs int)
	ApplyState(state State) error
	State(context.Context) State
	WaitNewData(ctx context.Context) error
}

type ItFactory added in v0.1.0

type ItFactory interface {
	// GetJournals returns map of journals by tags:partition.Journal or an error, if any. The returned journals
	// must be released after usage by Release() function
	GetJournals(ctx context.Context, tagsCond *lql.Source, maxLimit int) (map[tag.Line]journal.Journal, error)

	// GetJournal returns a journal by its source Id
	GetJournal(ctx context.Context, src string) (tag.Set, journal.Journal, error)

	// Iterator constructs new iterator for partition src. If the tmRange is provided the
	// iterator can utilize time-index for finding records
	Itearator(j journal.Journal, tmRange *model.TimeRange) journal.Iterator

	// Release releases the partition. Journal must not be used after the call
	Release(jn string)
}

ItFactory interface is used for creating new cursors.

func NewItFactory added in v0.1.0

func NewItFactory() ItFactory

NewItFactory provides ItFactory implementation which based on partition.Service

type Provider

type Provider interface {
	// GetOrCreate creates a new, or returns already exist cursor by its state (which contains cursor Id)
	GetOrCreate(ctx context.Context, state State, cache bool) (Cursor, error)

	// Release allows to release a cursor
	Release(ctx context.Context, curs Cursor) State
}

Provider interface provides interface for managing cursors

func NewProvider

func NewProvider() Provider

type State

type State struct {
	// Id the cursor state Id
	Id uint64

	// The Query contains the initial query for the cursor.
	Query string

	// Src allows to overwrite From tags, by specifying the source of partition. If it is nil, the
	// sources from the Query will be taken
	Src string

	// Pos indicates the position of the record which must be read next. If it is not empty, it
	// will be applied to the Query
	Pos string
}

State describes state of a cursor. This structure is used for creating new ones and for providing current state of a cursor

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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