cursor

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cursor provides access to cursor registry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cursor added in v1.5.0

type Cursor struct {
	DB         string
	Collection string
	Username   string
	ID         int64
	// contains filtered or unexported fields
}

Cursor allows clients to iterate over a result set.

It implements types.DocumentsIterator interface by wrapping another iterator with documents with additional metadata and registration in the registry.

Closing the cursor removes it from the registry.

func (*Cursor) Close added in v1.5.0

func (c *Cursor) Close()

Close implements types.DocumentsIterator interface.

func (*Cursor) Next added in v1.5.0

func (c *Cursor) Next() (struct{}, *types.Document, error)

Next implements types.DocumentsIterator interface.

type NewParams

type NewParams struct {
	Iter       types.DocumentsIterator
	DB         string
	Collection string
	Username   string
}

NewParams represent parameters for NewCursor.

type Registry

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

Registry stores cursors.

func NewRegistry

func NewRegistry(l *zap.Logger) *Registry

NewRegistry creates a new Registry.

func (*Registry) All added in v1.5.0

func (r *Registry) All() []*Cursor

All returns a shallow copy of all stored cursors.

func (*Registry) Close added in v1.5.0

func (r *Registry) Close()

Close waits for all cursors to be closed.

func (*Registry) Collect added in v1.5.0

func (r *Registry) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector.

func (*Registry) Describe added in v1.5.0

func (r *Registry) Describe(ch chan<- *prometheus.Desc)

Describe implements prometheus.Collector.

func (*Registry) Get added in v1.5.0

func (r *Registry) Get(id int64) *Cursor

Get returns stored cursor by ID, or nil.

func (*Registry) NewCursor added in v1.5.0

func (r *Registry) NewCursor(ctx context.Context, params *NewParams) *Cursor

NewCursor creates and stores a new cursor.

The cursor will be closed automatically when a given context is canceled, even if the cursor is not being used at that time.

Jump to

Keyboard shortcuts

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