Documentation
¶
Overview ¶
Package cursor provides access to cursor registry.
The implementation of the cursor and registry is quite complicated and entangled. That's because there are many cases when cursor / iterator / underlying database connection must be closed to free resources, including when no handler and backend code is running; for example, when the client disconnects between `getMore` commands. At the same time, we want to shift complexity away from the handler and from backend implementations because they are already quite complex. The current design enables ease of use at the expense of the implementation complexity.
Index ¶
- type Cursor
- type NewParams
- type Registry
- func (r *Registry) All() []*Cursor
- func (r *Registry) Close()
- func (r *Registry) Collect(ch chan<- prometheus.Metric)
- func (r *Registry) Describe(ch chan<- *prometheus.Desc)
- func (r *Registry) Get(id int64) *Cursor
- func (r *Registry) NewCursor(ctx context.Context, iter types.DocumentsIterator, params *NewParams) *Cursor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cursor ¶ added in v1.5.0
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.
type NewParams ¶
type NewParams struct {
DB string
Collection string
Username string
ShowRecordID bool
// contains filtered or unexported fields
}
NewParams represent parameters for NewCursor.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores 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) NewCursor ¶ added in v1.5.0
func (r *Registry) NewCursor(ctx context.Context, iter types.DocumentsIterator, 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.