util

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var QueryParallelism = 100

QueryParallelism is the maximum number of subqueries run in parallel per higher-level query

Functions

func DoParallelQueries

func DoParallelQueries(
	ctx context.Context, doSingleQuery DoSingleQuery, queries []index.Query,
	callback index.QueryPagesCallback,
) error

DoParallelQueries translates between our interface for query batching, and indexes that don't yet support batching.

func EnsureDirectory

func EnsureDirectory(dir string) error

EnsureDirectory makes sure directory is there, if not creates it if not

func EnsureDirectoryWithDefaultPermissions added in v3.1.0

func EnsureDirectoryWithDefaultPermissions(dir string, mode fs.FileMode) error

func GetParallelChunks

func GetParallelChunks(ctx context.Context, maxParallel int, chunks []chunk.Chunk, f func(context.Context, *chunk.DecodeContext, chunk.Chunk) (chunk.Chunk, error)) ([]chunk.Chunk, error)

GetParallelChunks fetches chunks in parallel (up to maxParallel).

func NewReadCloserWithContextCancelFunc

func NewReadCloserWithContextCancelFunc(readCloser io.ReadCloser, cancel context.CancelFunc) io.ReadCloser

func ReadSeeker added in v3.2.0

func ReadSeeker(r io.Reader) (io.ReadSeeker, error)

func RequirePermissions added in v3.1.0

func RequirePermissions(path string, required fs.FileMode) error

Types

type DoSingleQuery

type DoSingleQuery func(context.Context, index.Query, index.QueryPagesCallback) error

DoSingleQuery is the interface for indexes that don't support batching yet.

type ReadCloserWithContextCancelFunc

type ReadCloserWithContextCancelFunc struct {
	io.ReadCloser
	// contains filtered or unexported fields
}

ReadCloserWithContextCancelFunc helps with cancelling the context when closing a ReadCloser. NOTE: The consumer of ReadCloserWithContextCancelFunc should always call the Close method when it is done reading which otherwise could cause a resource leak.

func (ReadCloserWithContextCancelFunc) Close

Jump to

Keyboard shortcuts

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